Changeset b1d8092


Ignore:
Timestamp:
Feb 17, 2010, 11:15:27 AM (15 years ago)
Author:
Tillmann Crueger <crueger@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
326a43b
Parents:
7ba324 (diff), 354859 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'StructureRefactoring' into QT4Refactoring

Conflicts:

molecuilder/src/Makefile.am
molecuilder/src/builder.cpp
molecuilder/src/unittests/Makefile.am

Files:
15 added
14 edited
2 moved

Legend:

Unmodified
Added
Removed
  • configure.ac

    r7ba324 rb1d8092  
    2727
    2828# Boost libraries
    29 #AX_BOOST_BASE([1.33.1])
     29AX_BOOST_BASE([1.33.1])
    3030#AX_BOOST_PROGRAM_OPTIONS
    3131#AX_BOOST_FOREACH
    3232#AX_BOOST_FILESYSTEM
    33 #AX_BOOST_THREAD
     33AX_BOOST_THREAD
    3434#AX_BOOST_PROGRAM_OPTIONS
    3535#AX_BOOST_SERIALIZATION
  • src/Legacy/oldmenu.cpp

    r7ba324 rb1d8092  
    77 */
    88
    9 #include "menu.hpp"
     9#include "Legacy/oldmenu.hpp"
    1010#include "analysis_correlation.hpp"
    1111#include "atom.hpp"
  • src/Makefile.am

    r7ba324 rb1d8092  
    1212
    1313PATTERNSOURCE = Patterns/Observer.cpp
    14 PATTERNHEADER = Patterns/Observer.hpp
     14PATTERNHEADER = Patterns/Observer.hpp Patterns/Cacheable.hpp
    1515
    1616VIEWSOURCE = Views/View.cpp Views/StringView.cpp Views/MethodStringView.cpp Views/StreamStringView.cpp
     
    2323UIHEADER = ${ACTIONSHEADER} ${VIEWHEADER} ${MENUHEADER} UIElements/TextUIFactory.hpp UIElements/MainWindow.hpp UIElements/TextWindow.hpp UIElements/Dialog.hpp UIElements/TextDialog.hpp
    2424
     25
    2526FACTORYSOURCE = UIElements/UIFactory.cpp
    2627FACTORYHEADER = UIElements/UIFactory.hpp
    2728
     29# all these files are only used for legacy reasons while the transition is in progress
     30# they are only needed to keep the program usable at any point of the transition and will be
     31# deleted once everything is fully refactored
     32LEGACYSOURCE = Legacy/oldmenu.cpp
     33LEGACYHEADER = Legacy/oldmenu.hpp
     34
     35
    2836QTUIMOC_HEADER = UIElements/QT4/QTMainWindow.hpp UIElements/QT4/QTDialog.hpp Menu/QT4/QTMenu.hpp  Views/QT4/QTMoleculesView.hpp Views/QT4/GLMoleculeView.hpp
    2937QTUIMOC_TARGETS = QTMainWindow.moc.cpp QTMenu.moc.cpp QTDialog.moc.cpp QTMoleculesView.moc.cpp GLMoleculeView.moc.cpp
     38
     39DESCRIPTORSOURCE = Descriptors/AtomDescriptor.cpp Descriptors/AtomIdDescriptor.cpp
     40DESCRIPTORHEADER = Descriptors/AtomDescriptor.hpp Descriptors/AtomIdDescriptor.hpp
    3041
    3142QTUISOURCE = ${QTUIMOC_TARGETS} UIElements/QT4/QTMainWindow.cpp UIElements/QT4/QTDialog.cpp UIElements/QT4/QTUIFactory.cpp Menu/QT4/QTMenu.cpp Views/QT4/QTMoleculesView.cpp Views/QT4/GLMoleculeView.cpp
     
    3445QTUI_DEFS =
    3546
    36 SOURCE = ${ANALYSISSOURCE} ${ATOMSOURCE} ${PATTERNSOURCE} bond.cpp bondgraph.cpp boundary.cpp config.cpp element.cpp ellipsoid.cpp errorlogger.cpp graph.cpp helpers.cpp info.cpp leastsquaremin.cpp linkedcell.cpp log.cpp logger.cpp memoryusageobserver.cpp moleculelist.cpp molecule.cpp molecule_dynamics.cpp molecule_fragmentation.cpp molecule_geometry.cpp molecule_graph.cpp molecule_pointcloud.cpp parser.cpp periodentafel.cpp tesselation.cpp tesselationhelpers.cpp vector.cpp verbose.cpp menu.cpp
    37 HEADER = ${ANALYSISHEADER} ${ATOMHEADER} ${PATTERNHEADER} bond.hpp bondgraph.hpp boundary.hpp config.hpp defs.hpp element.hpp ellipsoid.hpp errorlogger.hpp graph.hpp helpers.hpp info.hpp leastsquaremin.hpp linkedcell.hpp lists.hpp log.hpp logger.hpp memoryallocator.hpp memoryusageobserver.hpp molecule.hpp molecule_template.hpp parser.hpp periodentafel.hpp stackclass.hpp tesselation.hpp tesselationhelpers.hpp vector.hpp verbose.hpp menu.hpp
     47SOURCE = ${ANALYSISSOURCE} ${ATOMSOURCE} ${PATTERNSOURCE} ${DESCRIPTORSOURCE} bond.cpp bondgraph.cpp boundary.cpp config.cpp element.cpp ellipsoid.cpp errorlogger.cpp graph.cpp helpers.cpp info.cpp leastsquaremin.cpp linkedcell.cpp log.cpp logger.cpp memoryusageobserver.cpp moleculelist.cpp molecule.cpp molecule_dynamics.cpp molecule_fragmentation.cpp molecule_geometry.cpp molecule_graph.cpp molecule_pointcloud.cpp parser.cpp periodentafel.cpp tesselation.cpp tesselationhelpers.cpp vector.cpp verbose.cpp World.cpp
     48HEADER = ${ANALYSISHEADER} ${ATOMHEADER} ${PATTERNHEADER} ${DESCRIPTORHEADER} ${LEGACYHEADER} bond.hpp bondgraph.hpp boundary.hpp config.hpp defs.hpp element.hpp ellipsoid.hpp errorlogger.hpp graph.hpp helpers.hpp info.hpp leastsquaremin.hpp linkedcell.hpp lists.hpp log.hpp logger.hpp memoryallocator.hpp memoryusageobserver.hpp molecule.hpp molecule_template.hpp parser.hpp periodentafel.hpp stackclass.hpp tesselation.hpp tesselationhelpers.hpp vector.hpp verbose.hpp World.hpp
     49
    3850
    3951BOOST_LIB = $(BOOST_LDFLAGS) $(BOOST_MPL_LIB)
     52GUI_LIBS = ${QT_LDADD} ${QT_LIB_GUI} -lQtOpenGL ${GLU_LIBS}
    4053INCLUDES = -I$(top_srcdir)/src/unittests
    4154
     
    4356bin_PROGRAMS = molecuilder molecuildergui joiner analyzer
    4457molecuilderdir = ${bindir}
     58
     59#libmolecuilder_a_CXXFLAGS = -DNO_CACHING
    4560libmolecuilder_a_SOURCES = ${SOURCE} ${HEADER}
     61
    4662libmenu_a_SOURCES = ${UISOURCE} ${UIHEADER}
     63
    4764libgslwrapper_a_SOURCES = ${LINALGSOURCE} ${LINALGHEADER}
     65
    4866molecuilder_DATA = elements.db valence.db orbitals.db Hbonddistance.db Hbondangle.db
     67
     68molecuilder_CXXFLAGS = $(BOOST_CPPFLAGS)
     69#molecuilder_CXXFLAGS += -DNO_CACHING
    4970molecuilder_LDFLAGS = $(BOOST_LIB)
    50 molecuilder_SOURCES = ${FACTORYSOURCE} menu.cpp builder.cpp
     71molecuilder_SOURCES = ${FACTORYSOURCE} ${LEGACYSOURCE} builder.cpp
    5172molecuilder_SOURCES += $(srcdir)/version.c
    52 molecuilder_LDADD = libmolecuilder.a libgslwrapper.a libmenu.a
     73molecuilder_LDADD = libmolecuilder.a libgslwrapper.a libmenu.a ${BOOST_THREAD_LIB}
     74
    5375#Stuff for building the GUI using QT
    54 molecuildergui_SOURCES = ${QTUISOURCE} ${FACTORYSOURCE} menu.cpp builder.cpp
     76molecuildergui_SOURCES = ${QTUISOURCE} ${FACTORYSOURCE} ${LEGACYSOURCE} builder.cpp
    5577molecuildergui_SOURCES += $(srcdir)/version.c
    5678molecuildergui_CXXFLAGS = ${QT_CXXFLAGS} ${GLU_CXXFLAGS} -DUSE_GUI_QT
    5779molecuildergui_LDFLAGS = $(BOOST_LIB) ${QT_LDFLAGS} ${GLU_LDFLAGS}
    58 molecuildergui_LDADD = libmolecuilder.a libgslwrapper.a libmenu.a ${QT_LDADD} ${QT_LIB_GUI} -lQtOpenGL ${GLU_LIBS}
     80molecuildergui_LDADD = libmolecuilder.a libgslwrapper.a libmenu.a ${BOOST_THREAD_LIB} ${GUI_LIBS}
     81
    5982joiner_SOURCES = joiner.cpp datacreator.cpp parser.cpp datacreator.hpp helpers.hpp parser.hpp periodentafel.hpp
    60 joiner_LDADD = libmolecuilder.a
     83joiner_LDADD = libmolecuilder.a $(BOOST_LIB) ${BOOST_THREAD_LIB}
     84
    6185analyzer_SOURCES = analyzer.cpp datacreator.cpp parser.cpp helpers.hpp periodentafel.hpp parser.hpp datacreator.hpp
    62 analyzer_LDADD = libmolecuilder.a
     86analyzer_LDADD = libmolecuilder.a $(BOOST_LIB) ${BOOST_THREAD_LIB}
    6387
    6488#Rules needed for QT4
  • src/Patterns/Observer.cpp

    r7ba324 rb1d8092  
    1010
    1111#include <iostream>
     12#include <cassert>
    1213
    1314using namespace std;
     
    2425
    2526map<Observable*, int> Observable::depth;
    26 multimap<Observable*,Observer*> Observable::callTable;
     27map<Observable*,multimap<int,Observer*>*> Observable::callTable;
    2728set<Observable*> Observable::busyObservables;
    2829
     
    5253}
    5354
     55Observable::_Observable_protector::_Observable_protector(Observable *_protege) :
     56  protege(_protege)
     57{
     58  start_observer_internal(protege);
     59}
     60
     61Observable::_Observable_protector::~_Observable_protector()
     62{
     63  finish_observer_internal(protege);
     64}
     65
    5466/************* Notification mechanism for observables **************/
    5567
    56 typedef multimap<Observable*,Observer*>::iterator callIterator;
    57 typedef pair<callIterator, callIterator> iteratorRange;
    5868
    5969void Observable::notifyAll() {
     
    6474  // and call all observers
    6575  if(callTable.count(this)) {
    66      iteratorRange callerRange = callTable.equal_range(this);
    67      callIterator iter;
    68      for(iter=callerRange.first;iter!=callerRange.second;iter++){
    69        (*iter).second->update(this);
    70      }
     76    // elements are stored sorted by keys in the multimap
     77    // so iterating over it gives us a the callees sorted by
     78    // the priorities
     79    callees_t *callees = callTable[this];
     80    callees_t::iterator iter;
     81    for(iter=callees->begin();iter!=callees->end();iter++){
     82      (*iter).second->update(this);
     83    }
    7184  }
    7285  // done with notification, we can leave the set of busy subjects
     
    97110
    98111// methods to sign-on and off
    99 void Observable::signOn(Observer *target) {
     112void Observable::signOn(Observer *target,int priority) {
     113  assert(priority>=-20 && priority<=+20 && "Priority out of range [-20:+20]");
    100114  bool res = false;
    101   iteratorRange callerRange = callTable.equal_range(this);
    102   callIterator iter;
    103   for(iter=callerRange.first;iter!=callerRange.second;iter++){
     115  callees_t *callees = 0;
     116  if(callTable.count(this)){
     117    callees = callTable[this];
     118  }
     119  else {
     120    callees = new multimap<int,Observer*>;
     121    callTable.insert(pair<Observable*,callees_t*>(this,callees));
     122  }
     123
     124  callees_t::iterator iter;
     125  for(iter=callees->begin();iter!=callees->end();iter++){
    104126    res |= ((*iter).second == target);
    105127  }
    106128  if(!res)
    107     callTable.insert(pair<Observable*,Observer*>(this,target));
     129    callees->insert(pair<int,Observer*>(priority,target));
    108130}
    109131
    110132void Observable::signOff(Observer *target) {
    111   iteratorRange callerRange = callTable.equal_range(this);
    112   callIterator iter;
    113   for(iter=callerRange.first;iter!=callerRange.second;iter++) {
     133  assert(callTable.count(this) && "SignOff called for an Observable without Observers.");
     134  callees_t *callees = callTable[this];
     135  callees_t::iterator iter;
     136  for(iter=callees->begin();iter!=callees->end();iter++) {
    114137    if((*iter).second == target)
    115       callTable.erase(iter);
     138      callees->erase(iter);
     139  }
     140  if(callees->empty()){
     141    callTable.erase(this);
     142    delete callees;
    116143  }
    117144}
     
    127154Observable::~Observable()
    128155{
    129   // delete all entries for this observable
    130   iteratorRange callerRange = callTable.equal_range(this);
    131   callIterator iter;
    132   for(iter=callerRange.first;iter!=callerRange.second;iter++){
    133     (*iter).second->subjectKilled(this);
     156  if(callTable.count(this)) {
     157    // delete all entries for this observable
     158    callees_t *callees = callTable[this];
     159    callees_t::iterator iter;
     160    for(iter=callees->begin();iter!=callees->end();iter++){
     161      (*iter).second->subjectKilled(this);
     162    }
     163    callTable.erase(this);
     164    delete callees;
    134165  }
    135   callTable.erase(callerRange.first,callerRange.second);
    136166}
    137167
  • src/Patterns/Observer.hpp

    r7ba324 rb1d8092  
    1616 *
    1717 * Observers register themselves with the observables to be notified when something changes.
    18  * In the Observable code that changes attributes should be wrapped in
    19  * START_OBSERVER ... END_OBSERVER blocks. If other methods are called that also contain
    20  * Observation blocks from there, these functions wont trigger notifications. Only the end
    21  * of the final observation block triggers the update of Observers.
     18 * In the Observable code that changes attributes should be started with OBSERVE;. This macro
     19 * locks the observer mechanism while changes are done. At the end of the scope in which the
     20 * macro was placed the lock is released. When the last lock is released all changes are
     21 * propagated to the observers.
    2222 *
    2323 * Each observerable can have sub-observables. When one of these sub-observables changes and
     
    4747  virtual ~Observable();
    4848
    49   virtual void signOn(Observer *target);
     49  virtual void signOn(Observer *target, int priority=0);
    5050  virtual void signOff(Observer *target);
    5151
     
    5959  /**
    6060   * Internal method.
    61    * Do not call directly. Use START_OBSERVER macro instead
     61   * Do not call directly. Use OBSERVE macro instead
    6262   */
    6363  static void start_observer_internal(Observable *publisher);
    6464  /**
    6565   * Internal method.
    66    * Do not call directly. Use FINISH_OBSERVER macro instead
     66   * Do not call directly. Use OBSERVE macro instead
    6767   */
    6868  static void finish_observer_internal(Observable *publisher);
    6969
    7070private:
     71  typedef std::multimap<int,Observer*> callees_t;
    7172  static std::map<Observable*, int> depth;
    72   static std::multimap<Observable*,Observer*> callTable;
     73  static std::map<Observable*,callees_t*> callTable;
    7374  static std::set<Observable*> busyObservables;
     75
     76  // Structure for RAII-Style notification
     77protected:
     78  class _Observable_protector {
     79  public:
     80    _Observable_protector(Observable *);
     81    ~_Observable_protector();
     82  private:
     83    Observable *protege;
     84  };
    7485};
    7586
    76 
    77 
    78 #define START_OBSERVER Observable::start_observer_internal(this);do{do{}while(0)
    79 #define FINISH_OBSERVER }while(0);Observable::finish_observer_internal(this)
     87// extra macro is necessary to work with __LINE__
     88#define PASTE(a,b) PASTE_HELPER(a,b)
     89#define PASTE_HELPER(a,b) a ## b
     90#define OBSERVE Observable::_Observable_protector PASTE(_scope_obs_protector_,__LINE__)(this)
     91// deprecated macros from before RAII was used
     92//#define START_OBSERVER Observable::start_observer_internal(this);do{do{}while(0)
     93//#define FINISH_OBSERVER }while(0);Observable::finish_observer_internal(this)
     94//#define RETURN_OBSERVER( retval ) do{Observable::finish_observer_internal(this); return (retval);}while(0)
    8095#endif /* OBSERVER_HPP_ */
  • src/UIElements/TextWindow.cpp

    r7ba324 rb1d8092  
    2828#include "periodentafel.hpp"
    2929
    30 #include "../menu.hpp"
     30#include "Legacy/oldmenu.hpp"
    3131
    3232#include "Menu/Menu.hpp"
  • src/atom.cpp

    r7ba324 rb1d8092  
    1313#include "parser.hpp"
    1414#include "vector.hpp"
     15#include "World.hpp"
    1516
    1617/************************************* Functions for class atom *************************************/
     
    2122atom::atom() : previous(NULL), next(NULL), father(this), sort(&nr)
    2223{
     24  World::get()->registerAtom(this);
    2325  node = &x;  // TesselPoint::x can only be referenced from here
    2426};
     
    2830atom::atom(atom *pointer) : previous(NULL), next(NULL), father(pointer), sort(&nr)
    2931{
     32  World::get()->registerAtom(this);
    3033  type = pointer->type;  // copy element of atom
    3134  x.CopyVector(&pointer->x); // copy coordination
     
    4043atom::~atom()
    4144{
     45  World::get()->unregisterAtom(this);
    4246  unlink(this);
    4347};
  • src/atom_particleinfo.cpp

    r7ba324 rb1d8092  
    2020};
    2121
     22int ParticleInfo::getId() {
     23  return nr;
     24}
     25
    2226ostream & operator << (ostream &ost, const ParticleInfo &a)
    2327{
  • src/atom_particleinfo.hpp

    r7ba324 rb1d8092  
    3535  ostream & operator << (ostream &ost) const;
    3636
     37  virtual int getId();
     38
    3739private:
    3840};
  • src/builder.cpp

    r7ba324 rb1d8092  
    7676#include "Actions/MethodAction.hpp"
    7777#include "Actions/small_actions.hpp"
     78#include "World.hpp"
    7879#include "version.h"
    7980
     
    21662167/********************************************** Main routine **************************************/
    21672168
     2169void cleanUp(config *configuration){
     2170  World::destroy();
     2171  delete(configuration);
     2172  Log() << Verbose(0) <<  "Maximum of allocated memory: "
     2173    << MemoryUsageObserver::getInstance()->getMaximumUsedMemory() << endl;
     2174  Log() << Verbose(0) <<  "Remaining non-freed memory: "
     2175    << MemoryUsageObserver::getInstance()->getUsedMemorySize() << endl;
     2176  MemoryUsageObserver::purgeInstance();
     2177  logger::purgeInstance();
     2178  errorLogger::purgeInstance();
     2179  UIFactory::purgeInstance();
     2180  ActionRegistry::purgeRegistry();
     2181}
     2182
    21682183int main(int argc, char **argv)
    21692184{
    2170   periodentafel *periode = new periodentafel;
    2171     MoleculeListClass *molecules = new MoleculeListClass;
    21722185    molecule *mol = NULL;
    21732186    config *configuration = new config;
     
    21802193    setVerbosity(0);
    21812194    /* structure of ParseCommandLineOptions will be refactored later */
    2182     j = ParseCommandLineOptions(argc, argv, molecules, periode, *configuration, ConfigFileName);
     2195    j = ParseCommandLineOptions(argc, argv,  World::get()->getMolecules(), World::get()->getPeriode(), *configuration, ConfigFileName);
    21832196    switch (j){
    21842197        case 255:
    21852198        case 2:
    21862199        case 1:
    2187             delete (molecules);
    2188             delete (periode);
    2189             delete (configuration);
    2190             Log() << Verbose(0) << "Maximum of allocated memory: " << MemoryUsageObserver::getInstance()->getMaximumUsedMemory() << endl;
    2191             Log() << Verbose(0) << "Remaining non-freed memory: " << MemoryUsageObserver::getInstance()->getUsedMemorySize() << endl;
    2192             MemoryUsageObserver::getInstance()->purgeInstance();
    2193             logger::purgeInstance();
    2194             errorLogger::purgeInstance();
     2200            cleanUp(configuration);
    21952201            return (j == 1 ? 0 : j);
    21962202        default:
    21972203            break;
    21982204    }
    2199     if(molecules->ListOfMolecules.size() == 0){
    2200         mol = new molecule(periode);
     2205    if(World::get()->numMolecules() == 0){
     2206        mol = World::get()->createMolecule();
    22012207        if(mol->cell_size[0] == 0.){
    22022208            Log() << Verbose(0) << "enter lower tridiagonal form of basis matrix" << endl << endl;
     
    22062212            }
    22072213        }
    2208 
    22092214        mol->ActiveFlag = true;
    2210         molecules->insert(mol);
    22112215    }
    22122216
     
    22242228      UIFactory::makeUserInterface(UIFactory::Text);
    22252229#endif
    2226       MainWindow *mainWindow = UIFactory::get()->makeMainWindow(populaters,molecules, configuration, periode, ConfigFileName);
     2230      MainWindow *mainWindow = UIFactory::get()->makeMainWindow(populaters,World::get()->getMolecules(), configuration, World::get()->getPeriode(), ConfigFileName);
    22272231      mainWindow->display();
    22282232
     
    22302234    }
    22312235
    2232     if(periode->StorePeriodentafel(configuration->databasepath))
     2236    if(World::get()->getPeriode()->StorePeriodentafel(configuration->databasepath))
    22332237        Log() << Verbose(0) << "Saving of elements.db successful." << endl;
    22342238
     
    22362240        Log() << Verbose(0) << "Saving of elements.db failed." << endl;
    22372241
    2238     delete (molecules);
    2239     delete(periode);
    2240   delete(configuration);
    2241 
    2242 
    2243 
    2244   Log() << Verbose(0) <<  "Maximum of allocated memory: "
    2245     << MemoryUsageObserver::getInstance()->getMaximumUsedMemory() << endl;
    2246   Log() << Verbose(0) <<  "Remaining non-freed memory: "
    2247     << MemoryUsageObserver::getInstance()->getUsedMemorySize() << endl;
    2248   MemoryUsageObserver::purgeInstance();
    2249   logger::purgeInstance();
    2250   errorLogger::purgeInstance();
    2251   UIFactory::purgeInstance();
    2252   ActionRegistry::purgeRegistry();
     2242  cleanUp(configuration);
    22532243  return (0);
    22542244}
  • src/molecule.cpp

    r7ba324 rb1d8092  
    66
    77#include <cstring>
     8#include <boost/bind.hpp>
    89
    910#include "atom.hpp"
     
    3233  first(new bond(start, end, 1, -1)), last(new bond(start, end, 1, -1)), MDSteps(0), AtomCount(0),
    3334  BondCount(0), ElementCount(0), NoNonHydrogen(0), NoNonBonds(0), NoCyclicBonds(0), BondDistance(0.),
    34   ActiveFlag(false), IndexNr(-1), last_atom(0), InternalPointer(start)
     35  ActiveFlag(false), IndexNr(-1), last_atom(0), InternalPointer(start),
     36  formula(this,boost::bind(&molecule::calcFormula,this))
    3537{
    3638  // init atom chain list
     
    6971
    7072void molecule::setName(const std::string _name){
    71   START_OBSERVER;
     73  OBSERVE;
    7274  strncpy(name,_name.c_str(),MAXSTRINGSIZE);
    73   FINISH_OBSERVER;
     75}
     76
     77const std::string molecule::getFormula(){
     78  return *formula;
     79}
     80
     81std::string molecule::calcFormula(){
     82  int Counts[MAX_ELEMENTS];
     83  stringstream sstr;
     84  for (int j = 0; j<MAX_ELEMENTS;j++)
     85    Counts[j] = 0;
     86  for(atom *Walker = start; Walker != end; Walker = Walker->next) {
     87    Counts[Walker->type->Z]++;
     88  }
     89  for(element* Elemental = elemente->end; Elemental != elemente->start; Elemental = Elemental->previous) {
     90    if (Counts[Elemental->Z] != 0)
     91      sstr << Elemental->symbol << Counts[Elemental->Z];
     92  }
     93  return sstr.str();
    7494}
    7595
     
    82102bool molecule::AddAtom(atom *pointer)
    83103{
     104  bool retval = false;
     105  OBSERVE;
    84106  if (pointer != NULL) {
    85107    pointer->sort = &pointer->nr;
     
    98120      }
    99121    }
    100     return add(pointer, end);
    101   } else
    102     return false;
     122    retval = add(pointer, end);
     123  }
     124  return retval;
    103125};
    104126
     
    110132atom * molecule::AddCopyAtom(atom *pointer)
    111133{
     134  atom *retval = NULL;
     135  OBSERVE;
    112136  if (pointer != NULL) {
    113137    atom *walker = new atom(pointer);
     
    119143      NoNonHydrogen++;
    120144    AtomCount++;
    121     return walker;
    122   } else
    123     return NULL;
     145    retval=walker;
     146  }
     147  return retval;
    124148};
    125149
     
    160184bool molecule::AddHydrogenReplacementAtom(bond *TopBond, atom *BottomOrigin, atom *TopOrigin, atom *TopReplacement, bool IsAngstroem)
    161185{
     186  bool AllWentWell = true;    // flag gathering the boolean return value of molecule::AddAtom and other functions, as return value on exit
     187  OBSERVE;
    162188  double bondlength;  // bond length of the bond to be replaced/cut
    163189  double bondangle;  // bond angle of the bond to be replaced/cut
    164190  double BondRescale;   // rescale value for the hydrogen bond length
    165   bool AllWentWell = true;    // flag gathering the boolean return value of molecule::AddAtom and other functions, as return value on exit
    166191  bond *FirstBond = NULL, *SecondBond = NULL; // Other bonds in double bond case to determine "other" plane
    167192  atom *FirstOtherAtom = NULL, *SecondOtherAtom = NULL, *ThirdOtherAtom = NULL; // pointer to hydrogen atoms to be added
     
    425450bool molecule::AddXYZFile(string filename)
    426451{
     452
    427453  istringstream *input = NULL;
    428454  int NumberOfAtoms = 0; // atom number in xyz read
     
    438464    return false;
    439465
     466  OBSERVE;
    440467  getline(xyzfile,line,'\n'); // Read numer of atoms in file
    441468  input = new istringstream(line);
  • src/molecule.hpp

    r7ba324 rb1d8092  
    3333#include "tesselation.hpp"
    3434#include "Patterns/Observer.hpp"
     35#include "Patterns/Cacheable.hpp"
    3536
    3637/****************************************** forward declarations *****************************/
     
    105106    char name[MAXSTRINGSIZE];         //!< arbitrary name
    106107
     108  private:
     109    Cacheable<string> formula;
     110
    107111public:
    108112  molecule(const periodentafel * const teil);
     
    112116  const std::string getName();
    113117  void setName(const std::string);
     118  const std::string getFormula();
     119  std::string calcFormula();
    114120
    115121  // re-definition of virtual functions from PointCloud
  • src/moleculelist.cpp

    r7ba324 rb1d8092  
    5050void MoleculeListClass::insert(molecule *mol)
    5151{
    52   START_OBSERVER;
     52  OBSERVE;
    5353  mol->IndexNr = MaxIndex++;
    5454  ListOfMolecules.push_back(mol);
    5555  mol->signOn(this);
    56   FINISH_OBSERVER;
    5756};
    5857
     
    892891
    893892void MoleculeListClass::createNewMolecule(periodentafel *periode) {
    894   START_OBSERVER;
     893  OBSERVE;
    895894  molecule *mol = NULL;
    896895  mol = new molecule(periode);
    897896  insert(mol);
    898   FINISH_OBSERVER;
    899897};
    900898
  • src/unittests/Makefile.am

    r7ba324 rb1d8092  
    2929  VectorUnitTest \
    3030  ObserverTest \
    31   ${MENUTESTS}
    32 
    33  
     31  CacheableTest \
     32  DescriptorUnittest \
     33  ${MENUTESTS} 
     34   
    3435check_PROGRAMS = $(TESTS)
    3536noinst_PROGRAMS = $(TESTS)
    3637
     38GSLLIBS = ../libgslwrapper.a
     39ALLLIBS = ../libmolecuilder.a ${GSLLIBS} $(BOOST_LIB) ${BOOST_THREAD_LIB}
     40
    3741ActOnAllUnitTest_SOURCES = ../test/ActOnAllTest.hpp ActOnAllUnitTest.cpp ActOnAllUnitTest.hpp
    38 ActOnAllUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
     42ActOnAllUnitTest_LDADD = ${ALLLIBS}
    3943
    4044AnalysisBondsUnitTests_SOURCES = analysisbondsunittest.cpp analysisbondsunittest.hpp
    41 AnalysisBondsUnitTests_LDADD = ../libmolecuilder.a ../libgslwrapper.a
     45AnalysisBondsUnitTests_LDADD = ${ALLLIBS}
    4246
    4347AnalysisCorrelationToPointUnitTest_SOURCES = analysis_correlation.hpp AnalysisCorrelationToPointUnitTest.cpp AnalysisCorrelationToPointUnitTest.hpp
    44 AnalysisCorrelationToPointUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
     48AnalysisCorrelationToPointUnitTest_LDADD = ${ALLLIBS}
    4549
    4650AnalysisCorrelationToSurfaceUnitTest_SOURCES = analysis_correlation.hpp AnalysisCorrelationToSurfaceUnitTest.cpp AnalysisCorrelationToSurfaceUnitTest.hpp
    47 AnalysisCorrelationToSurfaceUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
     51AnalysisCorrelationToSurfaceUnitTest_LDADD = ${ALLLIBS}
    4852
    4953AnalysisPairCorrelationUnitTest_SOURCES = analysis_correlation.hpp AnalysisPairCorrelationUnitTest.cpp AnalysisPairCorrelationUnitTest.hpp
    50 AnalysisPairCorrelationUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
     54AnalysisPairCorrelationUnitTest_LDADD = ${ALLLIBS}
    5155
    5256BondGraphUnitTest_SOURCES = bondgraphunittest.cpp bondgraphunittest.hpp
    53 BondGraphUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
     57BondGraphUnitTest_LDADD = ${ALLLIBS}
    5458
    5559GSLMatrixSymmetricUnitTest_SOURCES = gslmatrixsymmetricunittest.cpp gslmatrixsymmetricunittest.hpp
    56 GSLMatrixSymmetricUnitTest_LDADD = ../libgslwrapper.a
     60GSLMatrixSymmetricUnitTest_LDADD = ${GSLLIBS}
    5761
    5862GSLMatrixUnitTest_SOURCES = gslmatrixunittest.cpp gslmatrixunittest.hpp
    59 GSLMatrixUnitTest_LDADD = ../libgslwrapper.a
     63GSLMatrixUnitTest_LDADD = ${GSLLIBS}
    6064
    6165GSLVectorUnitTest_SOURCES = gslvectorunittest.cpp gslvectorunittest.hpp
    62 GSLVectorUnitTest_LDADD = ../libgslwrapper.a
     66GSLVectorUnitTest_LDADD = ${GSLLIBS}
    6367
    6468InfoUnitTest_SOURCES = infounittest.cpp infounittest.hpp
    65 InfoUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
     69InfoUnitTest_LDADD = ${ALLLIBS}
    6670
    6771LinearSystemOfEquationsUnitTest_SOURCES = linearsystemofequationsunittest.cpp linearsystemofequationsunittest.hpp
    68 LinearSystemOfEquationsUnitTest_LDADD = ../libgslwrapper.a ../libmolecuilder.a
     72LinearSystemOfEquationsUnitTest_LDADD = ${ALLLIBS}
    6973
    7074ListOfBondsUnitTest_SOURCES = listofbondsunittest.cpp listofbondsunittest.hpp
    71 ListOfBondsUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
     75ListOfBondsUnitTest_LDADD = ${ALLLIBS}
    7276
    7377LogUnitTest_SOURCES = logunittest.cpp logunittest.hpp
    74 LogUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
     78LogUnitTest_LDADD = ${ALLLIBS}
    7579
    7680MemoryAllocatorUnitTest_SOURCES = memoryallocatorunittest.cpp memoryallocatorunittest.hpp
    77 MemoryAllocatorUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
     81MemoryAllocatorUnitTest_LDADD = ${ALLLIBS}
    7882
    7983MemoryUsageObserverUnitTest_SOURCES = memoryusageobserverunittest.cpp memoryusageobserverunittest.hpp
    80 MemoryUsageObserverUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
     84MemoryUsageObserverUnitTest_LDADD = ${ALLLIBS}
    8185
    8286StackClassUnitTest_SOURCES = stackclassunittest.cpp stackclassunittest.hpp
    83 StackClassUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
     87StackClassUnitTest_LDADD = ${ALLLIBS}
    8488
    8589TesselationUnitTest_SOURCES = tesselationunittest.cpp tesselationunittest.hpp
    86 TesselationUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
     90TesselationUnitTest_LDADD = ${ALLLIBS}
    8791
    8892Tesselation_BoundaryTriangleUnitTest_SOURCES = tesselation_boundarytriangleunittest.cpp tesselation_boundarytriangleunittest.hpp
    89 Tesselation_BoundaryTriangleUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
     93Tesselation_BoundaryTriangleUnitTest_LDADD = ${ALLLIBS}
    9094
    9195Tesselation_InOutsideUnitTest_SOURCES = tesselation_insideoutsideunittest.cpp tesselation_insideoutsideunittest.hpp
    92 Tesselation_InOutsideUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
     96Tesselation_InOutsideUnitTest_LDADD = ${ALLLIBS}
    9397
    9498VectorUnitTest_SOURCES = vectorunittest.cpp vectorunittest.hpp
    95 VectorUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
     99VectorUnitTest_LDADD = ${ALLLIBS}
    96100
    97101ActionSequenceTest_SOURCES = ActionSequenceTest.cpp ActionSequenceTest.hpp
    98 ActionSequenceTest_LDADD = ../libmolecuilder.a ../libmenu.a
     102ActionSequenceTest_LDADD = ${ALLLIBS} ../libmenu.a
    99103
    100104ObserverTest_SOURCES = ObserverTest.cpp ObserverTest.hpp
    101 ObserverTest_LDADD = ../libmolecuilder.a
     105ObserverTest_LDADD = ${ALLLIBS}
     106
     107CacheableTest_SOURCES = CacheableTest.cpp CacheableTest.hpp
     108CacheableTest_LDADD = ${ALLLIBS}
     109
     110DescriptorUnittest_SOURCES = DescriptorUnittest.cpp DescriptorUnittest.hpp
     111DescriptorUnittest_LDADD = ${ALLLIBS}
    102112
    103113#AUTOMAKE_OPTIONS = parallel-tests
  • src/unittests/ObserverTest.cpp

    r7ba324 rb1d8092  
    3939public:
    4040  void changeMethod() {
    41     START_OBSERVER;
    42     int i;
    43     i++;
    44     FINISH_OBSERVER;
     41    OBSERVE;
     42    int i;
     43    i++;
    4544  }
    4645};
     
    4948public:
    5049  void changeMethod1() {
    51     START_OBSERVER;
    52     int i;
    53     i++;
    54     FINISH_OBSERVER;
     50    OBSERVE;
     51    int i;
     52    i++;
    5553  }
    5654
    5755  void changeMethod2() {
    58     START_OBSERVER;
     56    OBSERVE;
    5957    int i;
    6058    i++;
    6159    changeMethod1();
    62     FINISH_OBSERVER;
    6360  }
    6461};
     
    7471  }
    7572  void changeMethod() {
    76     START_OBSERVER;
     73    OBSERVE;
    7774    int i;
    7875    i++;
    7976    subObservable->changeMethod();
    80     FINISH_OBSERVER;
    8177  }
    8278  SimpleObservable *subObservable;
Note: See TracChangeset for help on using the changeset viewer.