Changes in / [cbf01e:2561df]
- Files:
-
- 2 added
- 75 edited
Legend:
- Unmodified
- Added
- Removed
-
configure.ac
rcbf01e r2561df 72 72 fi 73 73 74 # add replacement/saturation hydrogen or not 75 AC_ARG_ENABLE([ecut],AS_HELP_STRING([--enable-ecut],[Use ECut TestRunnerClient (default is yes)]), 76 [enable_ecut=$enableval], [enable_ecut=yes]) 77 if test x"$enable_ecut" = xyes; then 78 AC_DEFINE(HAVE_ECUT,1, ["Use ECut TestRunnerClient instead of our own."]) 79 AC_SUBST(HAVE_ECUT) 80 fi 81 74 82 # Check for "extern inline", using a modified version 75 83 # of the test for AC_C_INLINE from acspecific.mt -
src/Actions/ActionRegistry.cpp
rcbf01e r2561df 24 24 { 25 25 map<const string,Action*>::iterator iter; 26 for(iter=actionMap.begin();iter!=actionMap.end(); iter++) {26 for(iter=actionMap.begin();iter!=actionMap.end();++iter) { 27 27 delete iter->second; 28 actionMap.erase(iter);29 28 } 29 actionMap.clear(); 30 30 } 31 31 -
src/Actions/MakroAction.cpp
rcbf01e r2561df 23 23 { 24 24 Action* action; 25 while( action=actions->removeLastAction()){25 while((action=actions->removeLastAction())){ 26 26 delete action; 27 27 } -
src/Actions/ManipulateAtomsProcess.cpp
rcbf01e r2561df 14 14 ManipulateAtomsProcess::ManipulateAtomsProcess(boost::function<void(atom*)> _operation, AtomDescriptor _descr, 15 15 std::string _name,bool _doRegister) : 16 operation(_operation),16 Process(0,_name,_doRegister), 17 17 descr(_descr), 18 Process(0,_name,_doRegister)18 operation(_operation) 19 19 {} 20 20 -
src/Actions/Process.cpp
rcbf01e r2561df 13 13 Action(_name,_doRegister), 14 14 maxSteps(_maxSteps), 15 active(false), 15 16 starts(false), 16 stops(false), 17 active(false) 17 stops(false) 18 18 {} 19 19 -
src/Descriptors/AtomDescriptor.cpp
rcbf01e r2561df 19 19 using namespace std; 20 20 21 typedef map<int,atom*> atoms_t; 22 typedef atoms_t::iterator atoms_iter_t; 21 typedef World::AtomSet::iterator atoms_iter_t; 23 22 24 23 /************************ Forwarding object **************************************/ … … 68 67 } 69 68 70 atoms_t& AtomDescriptor_impl::getAtoms(){69 World::AtomSet& AtomDescriptor_impl::getAtoms(){ 71 70 return World::get()->atoms; 72 71 } 73 72 74 73 atom* AtomDescriptor_impl::find() { 75 atoms_t atoms = getAtoms();74 World::AtomSet atoms = getAtoms(); 76 75 atoms_iter_t res = find_if(atoms.begin(),atoms.end(),boost::bind(&AtomDescriptor_impl::predicate,this,_1)); 77 76 return (res!=atoms.end())?((*res).second):0; … … 80 79 vector<atom*> AtomDescriptor_impl::findAll() { 81 80 vector<atom*> res; 82 atoms_t atoms = getAtoms();81 World::AtomSet atoms = getAtoms(); 83 82 atoms_iter_t iter; 84 83 for(iter=atoms.begin();iter!=atoms.end();++iter) { … … 98 97 {} 99 98 100 bool AtomAllDescriptor_impl::predicate(std::pair< int,atom*>){99 bool AtomAllDescriptor_impl::predicate(std::pair<atomId_t,atom*>){ 101 100 return true; 102 101 } … … 112 111 {} 113 112 114 bool AtomNoneDescriptor_impl::predicate(std::pair< int,atom*>){113 bool AtomNoneDescriptor_impl::predicate(std::pair<atomId_t,atom*>){ 115 114 return false; 116 115 } … … 130 129 {} 131 130 132 bool AtomAndDescriptor_impl::predicate(std::pair< int,atom*> atom){131 bool AtomAndDescriptor_impl::predicate(std::pair<atomId_t,atom*> atom){ 133 132 return lhs->predicate(atom) && rhs->predicate(atom); 134 133 } … … 146 145 } 147 146 148 bool AtomOrDescriptor_impl::predicate(std::pair< int,atom*> atom){147 bool AtomOrDescriptor_impl::predicate(std::pair<atomId_t,atom*> atom){ 149 148 return lhs->predicate(atom) || rhs->predicate(atom); 150 149 } … … 166 165 } 167 166 168 bool AtomNotDescriptor_impl::predicate(std::pair< int,atom*> atom){167 bool AtomNotDescriptor_impl::predicate(std::pair<atomId_t,atom*> atom){ 169 168 return !(arg->predicate(atom)); 170 169 } -
src/Descriptors/AtomDescriptor_impl.hpp
rcbf01e r2561df 1 1 #ifndef ATOMDESCRIPTOR_IMPL_HPP 2 2 #define ATOMDESCRIPTOR_IMPL_HPP 3 4 #include "Descriptors/AtomDescriptor.hpp" 3 5 4 6 /************************ Declarations of implementation Objects ************************/ … … 12 14 virtual ~AtomDescriptor_impl(); 13 15 14 virtual bool predicate(std::pair< int,atom*>)=0;16 virtual bool predicate(std::pair<atomId_t,atom*>)=0; 15 17 16 18 protected: 17 19 virtual atom* find(); 18 20 virtual std::vector<atom*> findAll(); 19 std::map<int,atom*>& getAtoms();21 World::AtomSet& getAtoms(); 20 22 }; 21 23 … … 26 28 AtomAllDescriptor_impl(); 27 29 virtual ~AtomAllDescriptor_impl(); 28 virtual bool predicate(std::pair< int,atom*>);30 virtual bool predicate(std::pair<atomId_t,atom*>); 29 31 }; 30 32 … … 33 35 AtomNoneDescriptor_impl(); 34 36 virtual ~AtomNoneDescriptor_impl(); 35 virtual bool predicate(std::pair< int,atom*>);37 virtual bool predicate(std::pair<atomId_t,atom*>); 36 38 }; 37 39 … … 43 45 AtomAndDescriptor_impl(AtomDescriptor::impl_ptr _lhs, AtomDescriptor::impl_ptr _rhs); 44 46 ~AtomAndDescriptor_impl(); 45 virtual bool predicate(std::pair< int,atom*>);47 virtual bool predicate(std::pair<atomId_t,atom*>); 46 48 47 49 private: … … 55 57 AtomOrDescriptor_impl(AtomDescriptor::impl_ptr _lhs, AtomDescriptor::impl_ptr _rhs); 56 58 virtual ~AtomOrDescriptor_impl(); 57 virtual bool predicate(std::pair< int,atom*>);59 virtual bool predicate(std::pair<atomId_t,atom*>); 58 60 59 61 private: … … 68 70 virtual ~AtomNotDescriptor_impl(); 69 71 70 virtual bool predicate(std::pair< int,atom*>);72 virtual bool predicate(std::pair<atomId_t,atom*>); 71 73 72 74 private: -
src/Descriptors/AtomIdDescriptor.cpp
rcbf01e r2561df 14 14 15 15 16 AtomIdDescriptor_impl::AtomIdDescriptor_impl( int _id) :16 AtomIdDescriptor_impl::AtomIdDescriptor_impl(atomId_t _id) : 17 17 id(_id) 18 18 {} … … 21 21 {} 22 22 23 bool AtomIdDescriptor_impl::predicate(std::pair< int,atom*> atom) {23 bool AtomIdDescriptor_impl::predicate(std::pair<atomId_t,atom*> atom) { 24 24 return atom.first==id; 25 25 } 26 26 27 AtomDescriptor AtomById( int id){27 AtomDescriptor AtomById(atomId_t id){ 28 28 return AtomDescriptor(AtomDescriptor::impl_ptr(new AtomIdDescriptor_impl(id))); 29 29 } 30 30 31 31 atom *AtomIdDescriptor_impl::find(){ 32 map<int,atom*>atoms = getAtoms();33 map<int,atom*>::iterator res = atoms.find(id);32 World::AtomSet atoms = getAtoms(); 33 World::AtomSet::iterator res = atoms.find(id); 34 34 return (res!=atoms.end())?((*res).second):0; 35 35 } -
src/Descriptors/AtomIdDescriptor.hpp
rcbf01e r2561df 9 9 #define ATOMIDDESCRIPTOR_HPP_ 10 10 11 #include "defs.hpp" 11 12 #include "Descriptors/AtomDescriptor.hpp" 12 13 13 AtomDescriptor AtomById( int id);14 AtomDescriptor AtomById(atomId_t id); 14 15 15 16 #endif /* ATOMIDDESCRIPTOR_HPP_ */ -
src/Descriptors/AtomIdDescriptor_impl.hpp
rcbf01e r2561df 7 7 { 8 8 public: 9 AtomIdDescriptor_impl( int _id);9 AtomIdDescriptor_impl(atomId_t _id); 10 10 virtual ~AtomIdDescriptor_impl(); 11 11 12 bool predicate(std::pair< int,atom*> atom);12 bool predicate(std::pair<atomId_t,atom*> atom); 13 13 14 14 protected: … … 16 16 virtual std::vector<atom*> findAll(); 17 17 private: 18 int id;18 atomId_t id; 19 19 }; 20 20 -
src/Descriptors/AtomTypeDescriptor.cpp
rcbf01e r2561df 20 20 {} 21 21 22 bool AtomTypeDescriptor_impl::predicate(std::pair< int,atom*> atom) {22 bool AtomTypeDescriptor_impl::predicate(std::pair<atomId_t,atom*> atom) { 23 23 return (atom.second->getType()==type); 24 24 } -
src/Descriptors/AtomTypeDescriptor_impl.hpp
rcbf01e r2561df 17 17 virtual ~AtomTypeDescriptor_impl(); 18 18 19 bool predicate(std::pair< int,atom*> atom);19 bool predicate(std::pair<atomId_t,atom*> atom); 20 20 private: 21 21 element *type; -
src/Legacy/oldmenu.cpp
rcbf01e r2561df 812 812 void oldmenu::ManipulateMolecules(periodentafel *periode, MoleculeListClass *molecules, config *configuration) 813 813 { 814 atom *first = NULL;815 814 Vector x,y,z,n; // coordinates for absolute point in cell volume 816 int j, axis, count, faktor;817 815 char choice; // menu choice char 818 816 molecule *mol = NULL; 819 element **Elements;820 Vector **vectors;821 817 MoleculeLeafClass *Subgraphs = NULL; 822 818 … … 1093 1089 A++; 1094 1090 } 1095 delete(mol);1091 World::get()->destroyMolecule(mol); 1096 1092 }; 1097 1093 -
src/Makefile.am
rcbf01e r2561df 60 60 molecuilderdir = ${bindir} 61 61 62 #libmolecuilder_a_CXXFLAGS = -DNO_CACHING63 62 libmolecuilder_a_SOURCES = ${SOURCE} ${HEADER} 64 63 -
src/Menu/DisplayMenuItem.cpp
rcbf01e r2561df 21 21 22 22 DisplayMenuItem::DisplayMenuItem(Menu* _menu, StringView *_view, string _title, char _spacer, int _length ): 23 MenuItem('\0',"",_menu),24 view(_view),25 title(_title),26 spacer(_spacer),27 length(_length)23 MenuItem('\0',"",_menu), 24 view(_view), 25 title(_title), 26 length(_length), 27 spacer(_spacer) 28 28 { 29 29 } 30 30 31 31 DisplayMenuItem::~DisplayMenuItem() 32 { 33 // TODO Auto-generated destructor stub 34 } 32 {} 35 33 36 34 -
src/Menu/TextMenu.cpp
rcbf01e r2561df 18 18 */ 19 19 TextMenu::TextMenu(ostream& _outputter, string _title, char _spacer,int _length) : 20 outputter(_outputter),21 title(_title),22 spacer(_spacer),23 length(_length),24 quit(false),25 defaultItem(0)20 defaultItem(0), 21 outputter(_outputter), 22 title(_title), 23 spacer(_spacer), 24 length(_length), 25 quit(false) 26 26 { 27 27 } -
src/Patterns/Cacheable.hpp
rcbf01e r2561df 43 43 Cacheable<T>::Cacheable(Observable *_owner, boost::function<T()> _recalcMethod) : 44 44 owner(_owner), 45 recalcMethod(_recalcMethod),46 45 valid(false), 47 canBeUsed(true) 46 canBeUsed(true), 47 recalcMethod(_recalcMethod) 48 48 { 49 49 // we sign on with the best(=lowest) priority, so cached values are recalculated before -
src/Patterns/Observer.cpp
rcbf01e r2561df 24 24 // See [Gamma et al, 1995] p. 297 25 25 26 map<Observable*, int> Observable::depth; 27 map<Observable*,multimap<int,Observer*>*> Observable::callTable; 28 set<Observable*> Observable::busyObservables; 29 30 // The two functions start_observer_internal and finish_observer_internal 31 // have to be used together at all time. Never use these functions directly 32 // START_OBSERVER and FINISH_OBSERVER also construct a bogus while(0) loop 33 // thus producing compiler-errors whenever only one is used 34 26 map<Observable*, int> Observable::depth; //!< Map of Observables to the depth of the DAG of Observers 27 map<Observable*,multimap<int,Observer*>*> Observable::callTable; //!< Table for each Observable of all its Observers 28 set<Observable*> Observable::busyObservables; //!< Set of Observables that are currently busy notifying their sign-on'ed Observers 29 30 /** Attaching Sub-observables to Observables. 31 * Increases entry in Observable::depth for this \a *publisher by one. 32 * 33 * The two functions \sa start_observer_internal() and \sa finish_observer_internal() 34 * have to be used together at all time. Never use these functions directly 35 * START_OBSERVER and FINISH_OBSERVER also construct a bogus while(0) loop 36 * thus producing compiler-errors whenever only one is used. 37 * \param *publisher reference of sub-observable 38 */ 35 39 void Observable::start_observer_internal(Observable *publisher){ 36 40 // increase the count for this observable by one … … 40 44 } 41 45 46 /** Detaching Sub-observables from Observables. 47 * Decreases entry in Observable::depth for this \a *publisher by one. If zero, we 48 * start notifying all our Observers. 49 * 50 * The two functions start_observer_internal() and finish_observer_internal() 51 * have to be used together at all time. Never use these functions directly 52 * START_OBSERVER and FINISH_OBSERVER also construct a bogus while(0) loop 53 * thus producing compiler-errors whenever only one is used. 54 * \param *publisher reference of sub-observable 55 */ 42 56 void Observable::finish_observer_internal(Observable *publisher){ 43 57 // decrease the count for this observable … … 53 67 } 54 68 69 /** Constructor for Observable Protector. 70 * Basically, calls start_observer_internal(). Hence use this class instead of 71 * calling the function directly. 72 * 73 * \param *protege Observable to be protected. 74 */ 55 75 Observable::_Observable_protector::_Observable_protector(Observable *_protege) : 56 76 protege(_protege) … … 59 79 } 60 80 81 /** Destructor for Observable Protector. 82 * Basically, calls finish_observer_internal(). Hence use this class instead of 83 * calling the function directly. 84 * 85 * \param *protege Observable to be protected. 86 */ 61 87 Observable::_Observable_protector::~_Observable_protector() 62 88 { … … 66 92 /************* Notification mechanism for observables **************/ 67 93 68 94 /** Notify all Observers of changes. 95 * Puts \a *this into Observable::busyObservables, calls Observer::update() for all in callee_t 96 * and removes from busy list. 97 */ 69 98 void Observable::notifyAll() { 70 99 // we are busy notifying others right now … … 79 108 callees_t *callees = callTable[this]; 80 109 callees_t::iterator iter; 81 for(iter=callees->begin();iter!=callees->end(); iter++){110 for(iter=callees->begin();iter!=callees->end();++iter){ 82 111 (*iter).second->update(this); 83 112 } … … 87 116 } 88 117 89 // this handles passing on updates from sub-Observables 118 /** Handles passing on updates from sub-Observables. 119 * Mimicks basically the Observer::update() function. 120 * 121 * \param *publisher The \a *this we observe. 122 */ 90 123 void Observable::update(Observable *publisher) { 91 124 // circle detection … … 109 142 } 110 143 111 // methods to sign-on and off 144 /** Sign on an Observer to this Observable. 145 * Puts \a *target into Observable::callTable list. 146 * \param *target Observer 147 * \param priority number in [-20,20] 148 */ 112 149 void Observable::signOn(Observer *target,int priority) { 113 150 assert(priority>=-20 && priority<=+20 && "Priority out of range [-20:+20]"); … … 123 160 124 161 callees_t::iterator iter; 125 for(iter=callees->begin();iter!=callees->end(); iter++){162 for(iter=callees->begin();iter!=callees->end();++iter){ 126 163 res |= ((*iter).second == target); 127 164 } … … 130 167 } 131 168 169 /** Sign off an Observer from this Observable. 170 * Removes \a *target from Observable::callTable list. 171 * \param *target Observer 172 */ 132 173 void Observable::signOff(Observer *target) { 133 174 assert(callTable.count(this) && "SignOff called for an Observable without Observers."); 134 175 callees_t *callees = callTable[this]; 135 176 callees_t::iterator iter; 136 for(iter=callees->begin();iter!=callees->end();iter++) { 137 if((*iter).second == target) 138 callees->erase(iter); 177 callees_t::iterator deliter; 178 for(iter=callees->begin();iter!=callees->end();) { 179 if((*iter).second == target) { 180 callees->erase(iter++); 181 } 182 else { 183 ++iter; 184 } 139 185 } 140 186 if(callees->empty()){ … … 144 190 } 145 191 146 // when an sub-observerable dies we usually don't need to do anything 192 /** Handles sub-observables that just got killed 193 * when an sub-observerable dies we usually don't need to do anything 194 * \param *publisher Sub-Observable. 195 */ 147 196 void Observable::subjectKilled(Observable *publisher){ 148 197 } 149 198 199 /** Constructor for class Observable. 200 */ 150 201 Observable::Observable() 151 202 {} 152 203 153 // when an observable is deleted, we let all our observers know 204 /** Destructor for class Observable. 205 * When an observable is deleted, we let all our observers know. \sa Observable::subjectKilled(). 206 */ 154 207 Observable::~Observable() 155 208 { … … 158 211 callees_t *callees = callTable[this]; 159 212 callees_t::iterator iter; 160 for(iter=callees->begin();iter!=callees->end(); iter++){213 for(iter=callees->begin();iter!=callees->end();++iter){ 161 214 (*iter).second->subjectKilled(this); 162 215 } … … 166 219 } 167 220 221 /** Constructor for class Observer. 222 */ 168 223 Observer::Observer() 169 224 {} 170 225 226 /** Destructor for class Observer. 227 */ 171 228 Observer::~Observer() 172 229 {} -
src/Patterns/Observer.hpp
rcbf01e r2561df 16 16 * 17 17 * Observers register themselves with the observables to be notified when something changes. 18 * In the Observable code that changes attributes should be started with OBSERVE;. This macro18 * In the Observable code that changes, attributes should be started with OBSERVE;. This macro 19 19 * locks the observer mechanism while changes are done. At the end of the scope in which the 20 20 * macro was placed the lock is released. When the last lock is released all changes are -
src/UIElements/Dialog.cpp
rcbf01e r2561df 115 115 Dialog::MoleculeQuery::MoleculeQuery(string title, molecule **_target, MoleculeListClass *_molecules) : 116 116 Query(title), 117 t arget(_target),117 tmp(0), 118 118 molecules(_molecules), 119 tmp(0) 119 target(_target) 120 120 121 {} 121 122 … … 129 130 130 131 Dialog::VectorQuery::VectorQuery(std::string title,Vector *_target,const double *const _cellSize,bool _check) : 131 Query(title), target(_target), cellSize(_cellSize), check(_check) 132 Query(title), 133 cellSize(_cellSize), 134 check(_check), 135 target(_target) 132 136 { 133 137 tmp = new Vector(); -
src/UIElements/TextStatusIndicator.cpp
rcbf01e r2561df 27 27 Process *proc; 28 28 // we are only observing Processes 29 if( proc=dynamic_cast<Process*>(subject)){29 if((proc=dynamic_cast<Process*>(subject))){ 30 30 // see what kind of progress we have to display 31 31 if(proc->getMaxSteps()>0){ -
src/Views/MethodStringView.cpp
rcbf01e r2561df 7 7 8 8 #include "MethodStringView.hpp" 9 10 using namespace std; 9 11 10 12 MethodStringView::MethodStringView(boost::function<string()> _displayMethod) : -
src/Views/MethodStringView.hpp
rcbf01e r2561df 19 19 { 20 20 public: 21 MethodStringView(boost::function<st ring()>);21 MethodStringView(boost::function<std::string()>); 22 22 virtual ~MethodStringView(); 23 23 24 virtual const st ring toString();24 virtual const std::string toString(); 25 25 26 26 private: 27 boost::function<st ring()> displayMethod;27 boost::function<std::string()> displayMethod; 28 28 }; 29 29 -
src/Views/StreamStringView.cpp
rcbf01e r2561df 7 7 8 8 #include <sstream> 9 #include <iostream> 9 10 10 11 #include "StreamStringView.hpp" 11 12 12 StreamStringView::StreamStringView(boost::function<void(ofstream *)> _displayMethod) : 13 using namespace std; 14 15 StreamStringView::StreamStringView(boost::function<void(ostream *)> _displayMethod) : 13 16 StringView(), 14 17 displayMethod(_displayMethod) 15 { 16 // TODO Auto-generated constructor stub 17 18 } 18 {} 19 19 20 20 StreamStringView::~StreamStringView() 21 { 22 // TODO Auto-generated destructor stub 23 } 21 {} 24 22 25 23 const string StreamStringView::toString() { 26 24 stringstream s; 27 displayMethod( (ofstream *)&s);25 displayMethod(dynamic_cast<ostream *>(&s)); 28 26 return s.str(); 29 27 } -
src/Views/StreamStringView.hpp
rcbf01e r2561df 10 10 11 11 #include <boost/function.hpp> 12 #include <iostream> 12 13 13 14 #include "Views/StringView.hpp" … … 24 25 { 25 26 public: 26 StreamStringView(boost::function<void( ofstream *)>);27 StreamStringView(boost::function<void(std::ostream *)>); 27 28 virtual ~StreamStringView(); 28 29 29 virtual const st ring toString();30 virtual const std::string toString(); 30 31 31 32 private: 32 boost::function<void( ofstream *)> displayMethod;33 boost::function<void(std::ostream *)> displayMethod; 33 34 }; 34 35 -
src/Views/StringView.hpp
rcbf01e r2561df 12 12 #include "Views/View.hpp" 13 13 14 using namespace std;15 16 14 /** 17 15 * View to show something as a string … … 26 24 virtual ~StringView(); 27 25 28 virtual const st ring toString()=0;26 virtual const std::string toString()=0; 29 27 }; 30 28 -
src/World.cpp
rcbf01e r2561df 47 47 OBSERVE; 48 48 molecule *mol = NULL; 49 mol = new molecule(periode); 50 molecules_deprecated->insert(mol); 49 mol = NewMolecule(); 51 50 assert(!molecules.count(currMoleculeId)); 51 mol->setId(currMoleculeId++); 52 52 // store the molecule by ID 53 molecules[ currMoleculeId++] = mol;53 molecules[mol->getId()] = mol; 54 54 mol->signOn(this); 55 55 return mol; 56 } 57 58 void World::destroyMolecule(molecule* mol){ 59 OBSERVE; 60 destroyMolecule(mol->getId()); 61 } 62 63 void World::destroyMolecule(moleculeId_t id){ 64 OBSERVE; 65 molecule *mol = molecules[id]; 66 assert(mol); 67 DeleteMolecule(mol); 68 molecules.erase(id); 56 69 } 57 70 … … 83 96 } 84 97 85 void World::destroyAtom( int id) {98 void World::destroyAtom(atomId_t id) { 86 99 OBSERVE; 87 100 atom *atom = atoms[id]; … … 131 144 132 145 World::World() : 146 periode(new periodentafel), 147 atoms(), 133 148 currAtomId(0), 149 molecules(), 134 150 currMoleculeId(0), 135 periode(new periodentafel), 136 molecules_deprecated(new MoleculeListClass), 137 atoms(), 138 molecules() 151 molecules_deprecated(new MoleculeListClass(this)) 139 152 { 140 153 molecules_deprecated->signOn(this); … … 143 156 World::~World() 144 157 { 158 molecules_deprecated->signOff(this); 145 159 delete molecules_deprecated; 146 160 delete periode; 147 AtomSet::iterator iter; 148 for(iter=atoms.begin();iter!=atoms.end();++iter){ 149 DeleteAtom((*iter).second); 161 MoleculeSet::iterator molIter; 162 for(molIter=molecules.begin();molIter!=molecules.end();++molIter){ 163 DeleteMolecule((*molIter).second); 164 } 165 molecules.clear(); 166 AtomSet::iterator atIter; 167 for(atIter=atoms.begin();atIter!=atoms.end();++atIter){ 168 DeleteAtom((*atIter).second); 150 169 } 151 170 atoms.clear(); … … 188 207 // should see that it gets the updated new world 189 208 delete oldWorld; 209 return theWorld; 190 210 } 191 211 -
src/World.hpp
rcbf01e r2561df 16 16 #include <boost/shared_ptr.hpp> 17 17 18 18 #include "defs.hpp" 19 19 #include "Patterns/Observer.hpp" 20 20 #include "Patterns/Cacheable.hpp" … … 40 40 friend class ManipulateAtomsProcess; 41 41 template<typename> friend class AtomsCalculation; 42 43 typedef std::map<int,atom*> AtomSet;44 typedef std::map<int,molecule*> MoleculeSet;45 42 public: 43 typedef std::map<atomId_t,atom*> AtomSet; 44 typedef std::map<moleculeId_t,molecule*> MoleculeSet; 46 45 47 46 /***** getter and setter *****/ … … 90 89 molecule *createMolecule(); 91 90 91 void destroyMolecule(molecule*); 92 void destroyMolecule(moleculeId_t); 93 92 94 /** 93 95 * Create a new atom. This method should be used whenever any atom is needed. Assigns a unique ID and stores … … 112 114 * atom directly since this will leave the pointer inside the world. 113 115 */ 114 void destroyAtom( int);116 void destroyAtom(atomId_t); 115 117 116 118 /** … … 140 142 protected: 141 143 void advanceState(); 142 World* world;143 144 AtomSet::iterator state; 144 145 boost::shared_ptr<AtomDescriptor_impl> descr; 145 146 int index; 147 148 World* world; 146 149 }; 147 150 … … 166 169 periodentafel *periode; 167 170 AtomSet atoms; 168 int currAtomId; //!< stores the next available Id for atoms171 atomId_t currAtomId; //!< stores the next available Id for atoms 169 172 MoleculeSet molecules; 170 int currMoleculeId;173 moleculeId_t currMoleculeId; 171 174 172 175 -
src/WorldIterators.cpp
rcbf01e r2561df 17 17 World::AtomIterator::AtomIterator(AtomDescriptor _descr, World* _world) : 18 18 descr(_descr.get_impl()), 19 world(_world),20 index(0)19 index(0), 20 world(_world) 21 21 { 22 22 state = world->atoms.begin(); -
src/atom_particleinfo.cpp
rcbf01e r2561df 14 14 15 15 ParticleInfo::ParticleInfo(ParticleInfo *pointer) : 16 Name(pointer->Name),17 nr(pointer->nr)16 nr(pointer->nr), 17 Name(pointer->Name) 18 18 {} 19 19 -
src/boundary.cpp
rcbf01e r2561df 4 4 */ 5 5 6 #include "World.hpp" 6 7 #include "atom.hpp" 7 8 #include "bond.hpp" … … 800 801 { 801 802 Info FunctionInfo(__func__); 802 molecule *Filling = new molecule(filler->elemente);803 molecule *Filling = World::get()->createMolecule(); 803 804 Vector CurrentPosition; 804 805 int N[NDIM]; … … 964 965 bool freeLC = false; 965 966 bool status = false; 966 CandidateForTesselation *baseline ;967 CandidateForTesselation *baseline=0; 967 968 LineMap::iterator testline; 968 969 bool OneLoopWithoutSuccessFlag = true; // marks whether we went once through all baselines without finding any without two triangles -
src/builder.cpp
rcbf01e r2561df 66 66 #include "linkedcell.hpp" 67 67 #include "log.hpp" 68 #include "memoryusageobserver unittest.hpp"68 #include "memoryusageobserver.hpp" 69 69 #include "molecule.hpp" 70 70 #include "periodentafel.hpp" … … 1433 1433 } 1434 1434 if (mol == NULL) { 1435 mol = new molecule(periode);1435 mol = World::get()->createMolecule(); 1436 1436 mol->ActiveFlag = true; 1437 1437 if (ConfigFileName != NULL) … … 1635 1635 Log() << Verbose(1) << "Filling Box with water molecules." << endl; 1636 1636 // construct water molecule 1637 molecule *filler = new molecule(periode);1637 molecule *filler = World::get()->createMolecule(); 1638 1638 molecule *Filling = NULL; 1639 1639 atom *second = NULL, *third = NULL; … … 1665 1665 molecules->insert(Filling); 1666 1666 } 1667 delete(filler);1667 World::get()->destroyMolecule(filler); 1668 1668 argptr+=6; 1669 1669 } … … 2205 2205 if(World::get()->numMolecules() == 0){ 2206 2206 mol = World::get()->createMolecule(); 2207 World::get()->getMolecules()->insert(mol); 2208 cout << "Molecule created" << endl; 2207 2209 if(mol->cell_size[0] == 0.){ 2208 2210 Log() << Verbose(0) << "enter lower tridiagonal form of basis matrix" << endl << endl; -
src/config.cpp
rcbf01e r2561df 851 851 void config::Load(const char * const filename, const string &BondGraphFileName, const periodentafel * const periode, MoleculeListClass * const &MolList) 852 852 { 853 molecule *mol = new molecule(periode);853 molecule *mol = World::get()->createMolecule(); 854 854 ifstream *file = new ifstream(filename); 855 855 if (file == NULL) { … … 1089 1089 void config::LoadOld(const char * const filename, const string &BondGraphFileName, const periodentafel * const periode, MoleculeListClass * const &MolList) 1090 1090 { 1091 molecule *mol = new molecule(periode);1091 molecule *mol = World::get()->createMolecule(); 1092 1092 ifstream *file = new ifstream(filename); 1093 1093 if (file == NULL) { … … 1788 1788 char filename[MAXSTRINGSIZE]; 1789 1789 ofstream output; 1790 molecule *mol = new molecule(periode);1790 molecule *mol = World::get()->createMolecule(); 1791 1791 mol->SetNameFromFilename(ConfigFileName); 1792 1792 … … 1899 1899 } 1900 1900 1901 delete(mol);1901 World::get()->destroyMolecule(mol); 1902 1902 }; 1903 1903 -
src/datacreator.cpp
rcbf01e r2561df 771 771 { 772 772 stringstream line(Force.Header[Force.MatrixCounter]); 773 c har *fillcolor[5] = {"black", "red", "blue", "green", "cyan"};773 const char *fillcolor[5] = {"black", "red", "blue", "green", "cyan"}; 774 774 string token; 775 775 … … 803 803 { 804 804 stringstream line(Force.Header[Force.MatrixCounter]); 805 c har *fillcolor[5] = {"black", "red", "blue", "green", "cyan"};805 const char *fillcolor[5] = {"black", "red", "blue", "green", "cyan"}; 806 806 string token; 807 807 -
src/defs.hpp
rcbf01e r2561df 32 32 33 33 enum Shading { white, lightgray, darkgray, black }; //!< color in Breadth-First-Search analysis 34 35 // some types that can stay abstract 36 typedef unsigned int moleculeId_t; 37 typedef unsigned int atomId_t; 34 38 35 39 //enum CutCyclicBond { KeepBond, SaturateBond }; //!< Saturation scheme either atom- or bondwise -
src/element.cpp
rcbf01e r2561df 14 14 /** Constructor of class element. 15 15 */ 16 element::element() { 17 Z = -1; 18 No = -1; 19 previous = NULL; 20 next = NULL; 21 sort = NULL; 16 element::element() : 17 mass(0), 18 CovalentRadius(0), 19 VanDerWaalsRadius(0), 20 Z(-1), 21 previous(NULL), 22 next(NULL), 23 sort(NULL), 24 No(-1), 25 Valence(0), 26 NoValenceOrbitals(0) 27 { 22 28 }; 23 29 -
src/gslmatrix.cpp
rcbf01e r2561df 178 178 gsl_matrix_set(dest, j,i, gsl_matrix_get(matrix, i,j) ); 179 179 } 180 delete(matrix);180 gsl_matrix_free(matrix); 181 181 matrix = dest; 182 182 flip(rows, columns); -
src/molecule.cpp
rcbf01e r2561df 34 34 first(new bond(start, end, 1, -1)), last(new bond(start, end, 1, -1)), MDSteps(0), AtomCount(0), 35 35 BondCount(0), ElementCount(0), NoNonHydrogen(0), NoNonBonds(0), NoCyclicBonds(0), BondDistance(0.), 36 ActiveFlag(false), IndexNr(-1), last_atom(0), InternalPointer(start), 37 formula(this,boost::bind(&molecule::calcFormula,this)) 36 ActiveFlag(false), IndexNr(-1), 37 formula(this,boost::bind(&molecule::calcFormula,this)), 38 last_atom(0), 39 InternalPointer(start) 38 40 { 39 41 // init atom chain list … … 53 55 }; 54 56 57 molecule *NewMolecule(){ 58 return new molecule(World::get()->getPeriode()); 59 } 60 55 61 /** Destructor of class molecule. 56 62 * Initialises molecule list with correctly referenced start and end, and sets molecule::last_atom to zero. … … 66 72 67 73 74 void DeleteMolecule(molecule *mol){ 75 delete mol; 76 } 77 68 78 // getter and setter 69 79 const std::string molecule::getName(){ … … 74 84 OBSERVE; 75 85 strncpy(name,_name.c_str(),MAXSTRINGSIZE); 86 } 87 88 moleculeId_t molecule::getId(){ 89 return id; 90 } 91 92 void molecule::setId(moleculeId_t _id){ 93 id =_id; 76 94 } 77 95 -
src/molecule.hpp
rcbf01e r2561df 29 29 #include <string> 30 30 31 #include "defs.hpp" 31 32 #include "graph.hpp" 32 33 #include "stackclass.hpp" … … 85 86 */ 86 87 class molecule : public PointCloud , public Observable { 88 friend molecule *NewMolecule(); 89 friend void DeleteMolecule(molecule *); 87 90 public: 88 91 double cell_size[6];//!< cell size … … 108 111 private: 109 112 Cacheable<string> formula; 113 moleculeId_t id; 114 protected: 115 molecule(const periodentafel * const teil); 116 virtual ~molecule(); 117 110 118 111 119 public: 112 molecule(const periodentafel * const teil);113 virtual ~molecule();114 115 120 //getter and setter 116 121 const std::string getName(); 122 moleculeId_t getId(); 123 void setId(moleculeId_t); 117 124 void setName(const std::string); 118 125 const std::string getFormula(); 119 126 std::string calcFormula(); 127 120 128 121 129 // re-definition of virtual functions from PointCloud … … 321 329 }; 322 330 331 molecule *NewMolecule(); 332 void DeleteMolecule(molecule* mol); 333 323 334 #include "molecule_template.hpp" 324 335 … … 330 341 int MaxIndex; 331 342 332 MoleculeListClass( );343 MoleculeListClass(World *world); 333 344 ~MoleculeListClass(); 334 345 … … 339 350 bool OutputConfigForListOfFragments(config *configuration, int *SortIndex); 340 351 int NumberOfActiveMolecules(); 341 void Enumerate(o fstream *out);352 void Enumerate(ostream *out); 342 353 void Output(ofstream *out); 343 354 void DissectMoleculeIntoConnectedSubgraphs(const periodentafel * const periode, config * const configuration); … … 363 374 364 375 private: 376 World *world; //!< The world this List belongs to. Needed to avoid deadlocks in the destructor 365 377 }; 366 378 -
src/molecule_dynamics.cpp
rcbf01e r2561df 6 6 */ 7 7 8 #include "World.hpp" 8 9 #include "atom.hpp" 9 10 #include "config.hpp" … … 162 163 double molecule::ConstrainedPotential(struct EvaluatePotential &Params) 163 164 { 164 double tmp , result;165 165 double tmp = 0.; 166 double result = 0.; 166 167 // go through every atom 167 168 atom *Runner = NULL; … … 485 486 bool status = true; 486 487 int MaxSteps = configuration.MaxOuterStep; 487 MoleculeListClass *MoleculePerStep = new MoleculeListClass( );488 MoleculeListClass *MoleculePerStep = new MoleculeListClass(World::get()); 488 489 // Get the Permutation Map by MinimiseConstrainedPotential 489 490 atom **PermutationMap = NULL; … … 505 506 Log() << Verbose(1) << "Filling intermediate " << MaxSteps << " steps with MDSteps of " << MDSteps << "." << endl; 506 507 for (int step = 0; step <= MaxSteps; step++) { 507 mol = new molecule(elemente);508 mol = World::get()->createMolecule(); 508 509 MoleculePerStep->insert(mol); 509 510 Walker = start; -
src/molecule_fragmentation.cpp
rcbf01e r2561df 8 8 #include <cstring> 9 9 10 #include "World.hpp" 10 11 #include "atom.hpp" 11 12 #include "bond.hpp" … … 675 676 //if (FragmentationToDo) { // we should always store the fragments again as coordination might have changed slightly without changing bond structure 676 677 // allocate memory for the pointer array and transmorph graphs into full molecular fragments 677 BondFragments = new MoleculeListClass( );678 BondFragments = new MoleculeListClass(World::get()); 678 679 int k=0; 679 680 for(Graph::iterator runner = TotalGraph.begin(); runner != TotalGraph.end(); runner++) { … … 926 927 { 927 928 atom **SonList = Calloc<atom*>(AtomCount, "molecule::StoreFragmentFromStack: **SonList"); 928 molecule *Leaf = new molecule(elemente);929 molecule *Leaf = World::get()->createMolecule(); 929 930 930 931 // Log() << Verbose(1) << "Begin of StoreFragmentFromKeyset." << endl; -
src/moleculelist.cpp
rcbf01e r2561df 7 7 #include <cstring> 8 8 9 #include "World.hpp" 9 10 #include "atom.hpp" 10 11 #include "bond.hpp" … … 24 25 /** Constructor for MoleculeListClass. 25 26 */ 26 MoleculeListClass::MoleculeListClass() 27 MoleculeListClass::MoleculeListClass(World *_world) : 28 world(_world) 27 29 { 28 30 // empty lists … … 38 40 for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) { 39 41 Log() << Verbose(4) << "ListOfMolecules: Freeing " << *ListRunner << "." << endl; 40 delete(*ListRunner);42 world->destroyMolecule(*ListRunner); 41 43 } 42 44 Log() << Verbose(4) << "Freeing ListOfMolecules." << endl; … … 137 139 * \param *out output stream 138 140 */ 139 void MoleculeListClass::Enumerate(o fstream *out)141 void MoleculeListClass::Enumerate(ostream *out) 140 142 { 141 143 element* Elemental = NULL; … … 213 215 // remove src 214 216 ListOfMolecules.remove(srcmol); 215 delete(srcmol);217 World::get()->destroyMolecule(srcmol); 216 218 return true; 217 219 }; … … 748 750 void MoleculeListClass::DissectMoleculeIntoConnectedSubgraphs(const periodentafel * const periode, config * const configuration) 749 751 { 750 molecule *mol = new molecule(periode);752 molecule *mol = World::get()->createMolecule(); 751 753 atom *Walker = NULL; 752 754 atom *Advancer = NULL; … … 773 775 } 774 776 // remove the molecule 775 delete(*MolRunner);777 World::get()->destroyMolecule(*MolRunner); 776 778 ListOfMolecules.erase(MolRunner); 777 779 } … … 795 797 molecule **molecules = Malloc<molecule *>(MolCount, "config::Load() - **molecules"); 796 798 for (int i=0;i<MolCount;i++) { 797 molecules[i] = (molecule*) new molecule(mol->elemente);799 molecules[i] = World::get()->createMolecule(); 798 800 molecules[i]->ActiveFlag = true; 799 801 strncpy(molecules[i]->name, mol->name, MAXSTRINGSIZE); … … 893 895 OBSERVE; 894 896 molecule *mol = NULL; 895 mol = new molecule(periode);897 mol = World::get()->createMolecule(); 896 898 insert(mol); 897 899 }; … … 902 904 char filename[MAXSTRINGSIZE]; 903 905 Log() << Verbose(0) << "Format should be XYZ with: ShorthandOfElement\tX\tY\tZ" << endl; 904 mol = new molecule(periode);906 mol = World::get()->createMolecule(); 905 907 do { 906 908 Log() << Verbose(0) << "Enter file name: "; … … 960 962 mol = *ListRunner; 961 963 ListOfMolecules.erase(ListRunner); 962 delete(mol);964 World::get()->destroyMolecule(mol); 963 965 break; 964 966 } … … 1007 1009 // remove the leaf itself 1008 1010 if (Leaf != NULL) { 1009 delete(Leaf);1011 World::get()->destroyMolecule(Leaf); 1010 1012 Leaf = NULL; 1011 1013 } -
src/tesselation.cpp
rcbf01e r2561df 4653 4653 } 4654 4654 } 4655 delete DegeneratedTriangles; 4655 4656 4656 4657 /// 3. Find connected endpoint candidates and put them into a polygon -
src/tesselationhelpers.cpp
rcbf01e r2561df 27 27 int signum; 28 28 gsl_permutation *p = gsl_permutation_alloc(A->size1); 29 gsl_matrix *tmpA ;29 gsl_matrix *tmpA=0; 30 30 31 31 if (inPlace) -
src/unittests/ActOnAllUnitTest.cpp
rcbf01e r2561df 16 16 #include "memoryallocator.hpp" 17 17 #include "vector.hpp" 18 19 #ifdef HAVE_TESTRUNNER 20 #include "UnitTestMain.hpp" 21 #endif /*HAVE_TESTRUNNER*/ 18 22 19 23 /********************************************** Test classes **************************************/ … … 40 44 { 41 45 VL.EmptyList(); 46 // Ref was copy constructed, hence has to be cleaned, too! 47 Ref.EmptyList(); 48 MemoryUsageObserver::purgeInstance(); 42 49 }; 43 50 … … 88 95 VL.ActOnAll( (void (Vector::*)(const double ** const)) &Vector::Scale, (const double ** const)&inverses ); 89 96 CPPUNIT_ASSERT_EQUAL( VL == Ref , true ); 97 Free(factors); 98 Free(inverses); 90 99 }; 91 100 … … 108 117 } 109 118 }; 110 111 112 /********************************************** Main routine **************************************/113 114 int main(int argc, char **argv)115 {116 // Get the top level suite from the registry117 CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();118 119 // Adds the test to the list of test to run120 CppUnit::TextUi::TestRunner runner;121 runner.addTest( suite );122 123 // Change the default outputter to a compiler error format outputter124 runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),125 std::cerr ) );126 // Run the tests.127 bool wasSucessful = runner.run();128 129 // Return error code 1 if the one of test failed.130 return wasSucessful ? 0 : 1;131 }; -
src/unittests/ActionSequenceTest.cpp
rcbf01e r2561df 13 13 #include "Actions/Action.hpp" 14 14 #include "Actions/ActionSequence.hpp" 15 16 #ifdef HAVE_TESTRUNNER 17 #include "UnitTestMain.hpp" 18 #endif /*HAVE_TESTRUNNER*/ 19 20 /********************************************** Test classes **************************************/ 15 21 16 22 // Registers the fixture into the 'registry' … … 169 175 CPPUNIT_ASSERT_EQUAL(false,shouldNotCall2->wasCalled()); 170 176 177 delete sequence; 171 178 } 172 179 … … 190 197 CPPUNIT_ASSERT_EQUAL(false,shouldNotCall2->wasCalled()); 191 198 192 } 193 194 195 /********************************************** Main routine **************************************/ 196 197 int main(int argc, char **argv) 198 { 199 // Get the top level suite from the registry 200 CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest(); 201 202 // Adds the test to the list of test to run 203 CppUnit::TextUi::TestRunner runner; 204 runner.addTest( suite ); 205 206 // Change the default outputter to a compiler error format outputter 207 runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(), 208 std::cerr ) ); 209 // Run the tests. 210 bool wasSucessful = runner.run(); 211 212 // Return error code 1 if the one of test failed. 213 return wasSucessful ? 0 : 1; 214 }; 199 delete sequence; 200 } 201 202 -
src/unittests/AnalysisCorrelationToPointUnitTest.cpp
rcbf01e r2561df 25 25 #include "periodentafel.hpp" 26 26 #include "tesselation.hpp" 27 #include "World.hpp" 28 29 #ifdef HAVE_TESTRUNNER 30 #include "UnitTestMain.hpp" 31 #endif /*HAVE_TESTRUNNER*/ 27 32 28 33 /********************************************** Test classes **************************************/ … … 52 57 53 58 // construct periodentafel 54 tafel = new periodentafel;59 tafel = World::get()->getPeriode(); 55 60 tafel->AddElement(hydrogen); 56 61 57 62 // construct molecule (tetraeder of hydrogens) 58 TestMolecule = new molecule(tafel);63 TestMolecule = World::get()->createMolecule(); 59 64 Walker = World::get()->createAtom(); 60 65 Walker->type = hydrogen; … … 77 82 CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 ); 78 83 79 TestList = new MoleculeListClass;84 TestList = World::get()->getMolecules(); 80 85 TestMolecule->ActiveFlag = true; 81 86 TestList->insert(TestMolecule); … … 98 103 delete(binmap); 99 104 100 // remove101 delete(TestList);102 // note that all the atoms are cleaned by TestMolecule103 105 delete(point); 104 delete(tafel); 105 // note that element is cleaned by periodentafel 106 World::destroy(); 107 MemoryUsageObserver::purgeInstance(); 108 logger::purgeInstance(); 106 109 }; 107 110 … … 141 144 142 145 }; 143 144 /********************************************** Main routine **************************************/145 146 int main(int argc, char **argv)147 {148 // Get the top level suite from the registry149 CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();150 151 // Adds the test to the list of test to run152 CppUnit::TextUi::TestRunner runner;153 runner.addTest( suite );154 155 // Change the default outputter to a compiler error format outputter156 runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),157 std::cerr ) );158 // Run the tests.159 bool wasSucessful = runner.run();160 161 // Return error code 1 if the one of test failed.162 return wasSucessful ? 0 : 1;163 }; -
src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp
rcbf01e r2561df 25 25 #include "periodentafel.hpp" 26 26 #include "tesselation.hpp" 27 #include "World.hpp" 28 29 #ifdef HAVE_TESTRUNNER 30 #include "UnitTestMain.hpp" 31 #endif /*HAVE_TESTRUNNER*/ 27 32 28 33 /********************************************** Test classes **************************************/ … … 56 61 57 62 // construct periodentafel 58 tafel = new periodentafel;63 tafel = World::get()->getPeriode(); 59 64 tafel->AddElement(hydrogen); 60 65 tafel->AddElement(carbon); 61 66 62 67 // construct molecule (tetraeder of hydrogens) base 63 TestMolecule = new molecule(tafel);68 TestMolecule = World::get()->createMolecule(); 64 69 Walker = World::get()->createAtom(); 65 70 Walker->type = hydrogen; … … 82 87 CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 ); 83 88 84 TestList = new MoleculeListClass;89 TestList = World::get()->getMolecules(); 85 90 TestMolecule->ActiveFlag = true; 86 91 TestList->insert(TestMolecule); … … 127 132 delete(binmap); 128 133 129 // remove130 delete(TestList);131 134 delete(Surface); 132 135 // note that all the atoms are cleaned by TestMolecule 133 136 delete(LC); 134 delete(tafel); 135 // note that element is cleaned by periodentafel 137 World::destroy(); 138 MemoryUsageObserver::purgeInstance(); 139 logger::purgeInstance(); 136 140 }; 137 141 … … 212 216 213 217 }; 214 215 /********************************************** Main routine **************************************/216 217 int main(int argc, char **argv)218 {219 // Get the top level suite from the registry220 CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();221 222 // Adds the test to the list of test to run223 CppUnit::TextUi::TestRunner runner;224 runner.addTest( suite );225 226 // Change the default outputter to a compiler error format outputter227 runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),228 std::cerr ) );229 // Run the tests.230 bool wasSucessful = runner.run();231 232 // Return error code 1 if the one of test failed.233 return wasSucessful ? 0 : 1;234 }; -
src/unittests/AnalysisPairCorrelationUnitTest.cpp
rcbf01e r2561df 25 25 #include "periodentafel.hpp" 26 26 #include "tesselation.hpp" 27 #include "World.hpp" 28 29 #ifdef HAVE_TESTRUNNER 30 #include "UnitTestMain.hpp" 31 #endif /*HAVE_TESTRUNNER*/ 27 32 28 33 /********************************************** Test classes **************************************/ … … 51 56 52 57 // construct periodentafel 53 tafel = new periodentafel;58 tafel = World::get()->getPeriode(); 54 59 tafel->AddElement(hydrogen); 55 60 56 61 // construct molecule (tetraeder of hydrogens) 57 TestMolecule = new molecule(tafel);62 TestMolecule = World::get()->createMolecule(); 58 63 Walker = World::get()->createAtom(); 59 64 Walker->type = hydrogen; … … 76 81 CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 ); 77 82 78 TestList = new MoleculeListClass;83 TestList = World::get()->getMolecules(); 79 84 TestMolecule->ActiveFlag = true; 80 85 TestList->insert(TestMolecule); … … 94 99 delete(binmap); 95 100 96 // remove97 delete(TestList);98 101 // note that all the atoms are cleaned by TestMolecule 99 delete(tafel); 100 // note that element is cleaned by periodentafel 102 World::destroy(); 103 MemoryUsageObserver::purgeInstance(); 104 logger::purgeInstance(); 105 errorLogger::purgeInstance(); 101 106 }; 102 107 … … 133 138 CPPUNIT_ASSERT_EQUAL( 6, tester->second ); 134 139 }; 135 136 /********************************************** Main routine **************************************/137 138 int main(int argc, char **argv)139 {140 // Get the top level suite from the registry141 CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();142 143 // Adds the test to the list of test to run144 CppUnit::TextUi::TestRunner runner;145 runner.addTest( suite );146 147 // Change the default outputter to a compiler error format outputter148 runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),149 std::cerr ) );150 // Run the tests.151 bool wasSucessful = runner.run();152 153 // Return error code 1 if the one of test failed.154 return wasSucessful ? 0 : 1;155 }; -
src/unittests/CacheableTest.cpp
rcbf01e r2561df 15 15 16 16 #include "Patterns/Cacheable.hpp" 17 18 #ifdef HAVE_TESTRUNNER 19 #include "UnitTestMain.hpp" 20 #endif /*HAVE_TESTRUNNER*/ 21 22 /********************************************** Test classes **************************************/ 17 23 18 24 // Registers the fixture into the 'registry' … … 77 83 CPPUNIT_ASSERT_EQUAL( true, numbers->hasRecalced); 78 84 } 79 80 81 82 /********************************************** Main routine **************************************/83 84 int main(int argc, char **argv)85 {86 // Get the top level suite from the registry87 CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();88 89 // Adds the test to the list of test to run90 CppUnit::TextUi::TestRunner runner;91 runner.addTest( suite );92 93 // Change the default outputter to a compiler error format outputter94 runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),95 std::cerr ) );96 // Run the tests.97 bool wasSucessful = runner.run();98 99 // Return error code 1 if the one of test failed.100 return wasSucessful ? 0 : 1;101 };102 -
src/unittests/DescriptorUnittest.cpp
rcbf01e r2561df 19 19 #include "atom.hpp" 20 20 21 #ifdef HAVE_TESTRUNNER 22 #include "UnitTestMain.hpp" 23 #endif /*HAVE_TESTRUNNER*/ 24 25 /********************************************** Test classes **************************************/ 21 26 // Registers the fixture into the 'registry' 22 27 CPPUNIT_TEST_SUITE_REGISTRATION( DescriptorUnittest ); … … 152 157 } 153 158 } 154 155 /********************************************** Main routine **************************************/156 157 int main(int argc, char **argv)158 {159 // Get the top level suite from the registry160 CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();161 162 // Adds the test to the list of test to run163 CppUnit::TextUi::TestRunner runner;164 runner.addTest( suite );165 166 // Change the default outputter to a compiler error format outputter167 runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),168 std::cerr ) );169 // Run the tests.170 bool wasSucessful = runner.run();171 172 // Return error code 1 if the one of test failed.173 return wasSucessful ? 0 : 1;174 }; -
src/unittests/Makefile.am
rcbf01e r2561df 37 37 38 38 check_PROGRAMS = $(TESTS) 39 noinst_PROGRAMS = $(TESTS) 39 noinst_PROGRAMS = $(TESTS) TestRunner 40 40 41 41 GSLLIBS = ../libgslwrapper.a 42 42 ALLLIBS = ../libmolecuilder.a ${GSLLIBS} $(BOOST_LIB) ${BOOST_THREAD_LIB} 43 43 44 ActOnAllUnitTest_SOURCES = ../test/ActOnAllTest.hpp ActOnAllUnitTest.cpp ActOnAllUnitTest.hpp 44 TESTSOURCES = \ 45 ActOnAllUnitTest.cpp \ 46 analysisbondsunittest.cpp \ 47 AnalysisCorrelationToPointUnitTest.cpp \ 48 AnalysisCorrelationToSurfaceUnitTest.cpp \ 49 AnalysisPairCorrelationUnitTest.cpp \ 50 bondgraphunittest.cpp \ 51 gslmatrixsymmetricunittest.cpp \ 52 gslmatrixunittest.cpp \ 53 gslvectorunittest.cpp \ 54 infounittest.cpp \ 55 linearsystemofequationsunittest.cpp \ 56 listofbondsunittest.cpp \ 57 logunittest.cpp \ 58 memoryallocatorunittest.cpp \ 59 memoryusageobserverunittest.cpp \ 60 stackclassunittest.cpp \ 61 tesselationunittest.cpp \ 62 tesselation_boundarytriangleunittest.cpp \ 63 tesselation_insideoutsideunittest.cpp \ 64 vectorunittest.cpp \ 65 ObserverTest.cpp \ 66 CacheableTest.cpp \ 67 DescriptorUnittest.cpp \ 68 manipulateAtomsTest.cpp \ 69 atomsCalculationTest.cpp \ 70 ActionSequenceTest.cpp 71 72 TESTHEADERS = \ 73 analysis_correlation.hpp 74 75 ActOnAllUnitTest_SOURCES = UnitTestMain.cpp ../test/ActOnAllTest.hpp ActOnAllUnitTest.cpp ActOnAllUnitTest.hpp 45 76 ActOnAllUnitTest_LDADD = ${ALLLIBS} 46 77 47 AnalysisBondsUnitTests_SOURCES = analysisbondsunittest.cpp analysisbondsunittest.hpp78 AnalysisBondsUnitTests_SOURCES = UnitTestMain.cpp analysisbondsunittest.cpp analysisbondsunittest.hpp 48 79 AnalysisBondsUnitTests_LDADD = ${ALLLIBS} 49 80 50 AnalysisCorrelationToPointUnitTest_SOURCES = analysis_correlation.hpp AnalysisCorrelationToPointUnitTest.cpp AnalysisCorrelationToPointUnitTest.hpp81 AnalysisCorrelationToPointUnitTest_SOURCES = UnitTestMain.cpp analysis_correlation.hpp AnalysisCorrelationToPointUnitTest.cpp AnalysisCorrelationToPointUnitTest.hpp 51 82 AnalysisCorrelationToPointUnitTest_LDADD = ${ALLLIBS} 52 83 53 AnalysisCorrelationToSurfaceUnitTest_SOURCES = analysis_correlation.hpp AnalysisCorrelationToSurfaceUnitTest.cpp AnalysisCorrelationToSurfaceUnitTest.hpp84 AnalysisCorrelationToSurfaceUnitTest_SOURCES = UnitTestMain.cpp analysis_correlation.hpp AnalysisCorrelationToSurfaceUnitTest.cpp AnalysisCorrelationToSurfaceUnitTest.hpp 54 85 AnalysisCorrelationToSurfaceUnitTest_LDADD = ${ALLLIBS} 55 86 56 AnalysisPairCorrelationUnitTest_SOURCES = analysis_correlation.hpp AnalysisPairCorrelationUnitTest.cpp AnalysisPairCorrelationUnitTest.hpp87 AnalysisPairCorrelationUnitTest_SOURCES = UnitTestMain.cpp analysis_correlation.hpp AnalysisPairCorrelationUnitTest.cpp AnalysisPairCorrelationUnitTest.hpp 57 88 AnalysisPairCorrelationUnitTest_LDADD = ${ALLLIBS} 58 89 59 BondGraphUnitTest_SOURCES = bondgraphunittest.cpp bondgraphunittest.hpp90 BondGraphUnitTest_SOURCES = UnitTestMain.cpp bondgraphunittest.cpp bondgraphunittest.hpp 60 91 BondGraphUnitTest_LDADD = ${ALLLIBS} 61 92 62 GSLMatrixSymmetricUnitTest_SOURCES = gslmatrixsymmetricunittest.cpp gslmatrixsymmetricunittest.hpp93 GSLMatrixSymmetricUnitTest_SOURCES = UnitTestMain.cpp gslmatrixsymmetricunittest.cpp gslmatrixsymmetricunittest.hpp 63 94 GSLMatrixSymmetricUnitTest_LDADD = ${GSLLIBS} 64 95 65 GSLMatrixUnitTest_SOURCES = gslmatrixunittest.cpp gslmatrixunittest.hpp96 GSLMatrixUnitTest_SOURCES = UnitTestMain.cpp gslmatrixunittest.cpp gslmatrixunittest.hpp 66 97 GSLMatrixUnitTest_LDADD = ${GSLLIBS} 67 98 68 GSLVectorUnitTest_SOURCES = gslvectorunittest.cpp gslvectorunittest.hpp99 GSLVectorUnitTest_SOURCES = UnitTestMain.cpp gslvectorunittest.cpp gslvectorunittest.hpp 69 100 GSLVectorUnitTest_LDADD = ${GSLLIBS} 70 101 71 InfoUnitTest_SOURCES = infounittest.cpp infounittest.hpp102 InfoUnitTest_SOURCES = UnitTestMain.cpp infounittest.cpp infounittest.hpp 72 103 InfoUnitTest_LDADD = ${ALLLIBS} 73 104 74 LinearSystemOfEquationsUnitTest_SOURCES = linearsystemofequationsunittest.cpp linearsystemofequationsunittest.hpp105 LinearSystemOfEquationsUnitTest_SOURCES = UnitTestMain.cpp linearsystemofequationsunittest.cpp linearsystemofequationsunittest.hpp 75 106 LinearSystemOfEquationsUnitTest_LDADD = ${ALLLIBS} 76 107 77 ListOfBondsUnitTest_SOURCES = listofbondsunittest.cpp listofbondsunittest.hpp108 ListOfBondsUnitTest_SOURCES = UnitTestMain.cpp listofbondsunittest.cpp listofbondsunittest.hpp 78 109 ListOfBondsUnitTest_LDADD = ${ALLLIBS} 79 110 80 LogUnitTest_SOURCES = logunittest.cpp logunittest.hpp111 LogUnitTest_SOURCES = UnitTestMain.cpp logunittest.cpp logunittest.hpp 81 112 LogUnitTest_LDADD = ${ALLLIBS} 82 113 83 MemoryAllocatorUnitTest_SOURCES = memoryallocatorunittest.cpp memoryallocatorunittest.hpp114 MemoryAllocatorUnitTest_SOURCES = UnitTestMain.cpp memoryallocatorunittest.cpp memoryallocatorunittest.hpp 84 115 MemoryAllocatorUnitTest_LDADD = ${ALLLIBS} 85 116 86 MemoryUsageObserverUnitTest_SOURCES = memoryusageobserverunittest.cpp memoryusageobserverunittest.hpp117 MemoryUsageObserverUnitTest_SOURCES = UnitTestMain.cpp memoryusageobserverunittest.cpp memoryusageobserverunittest.hpp 87 118 MemoryUsageObserverUnitTest_LDADD = ${ALLLIBS} 88 119 89 StackClassUnitTest_SOURCES = stackclassunittest.cpp stackclassunittest.hpp120 StackClassUnitTest_SOURCES = UnitTestMain.cpp stackclassunittest.cpp stackclassunittest.hpp 90 121 StackClassUnitTest_LDADD = ${ALLLIBS} 91 122 92 TesselationUnitTest_SOURCES = tesselationunittest.cpp tesselationunittest.hpp123 TesselationUnitTest_SOURCES = UnitTestMain.cpp tesselationunittest.cpp tesselationunittest.hpp 93 124 TesselationUnitTest_LDADD = ${ALLLIBS} 94 125 95 Tesselation_BoundaryTriangleUnitTest_SOURCES = tesselation_boundarytriangleunittest.cpp tesselation_boundarytriangleunittest.hpp126 Tesselation_BoundaryTriangleUnitTest_SOURCES = UnitTestMain.cpp tesselation_boundarytriangleunittest.cpp tesselation_boundarytriangleunittest.hpp 96 127 Tesselation_BoundaryTriangleUnitTest_LDADD = ${ALLLIBS} 97 128 98 Tesselation_InOutsideUnitTest_SOURCES = tesselation_insideoutsideunittest.cpp tesselation_insideoutsideunittest.hpp129 Tesselation_InOutsideUnitTest_SOURCES = UnitTestMain.cpp tesselation_insideoutsideunittest.cpp tesselation_insideoutsideunittest.hpp 99 130 Tesselation_InOutsideUnitTest_LDADD = ${ALLLIBS} 100 131 101 VectorUnitTest_SOURCES = vectorunittest.cpp vectorunittest.hpp132 VectorUnitTest_SOURCES = UnitTestMain.cpp vectorunittest.cpp vectorunittest.hpp 102 133 VectorUnitTest_LDADD = ${ALLLIBS} 103 134 104 ActionSequenceTest_SOURCES = ActionSequenceTest.cpp ActionSequenceTest.hpp105 ActionSequenceTest_LDADD = ${ALLLIBS} ../libmenu.a135 ActionSequenceTest_SOURCES = UnitTestMain.cpp ../../../TestRunnerClient.hpp ActionSequenceTest.cpp ActionSequenceTest.hpp 136 ActionSequenceTest_LDADD = ${ALLLIBS} 106 137 107 ObserverTest_SOURCES = ObserverTest.cpp ObserverTest.hpp138 ObserverTest_SOURCES = UnitTestMain.cpp ObserverTest.cpp ObserverTest.hpp 108 139 ObserverTest_LDADD = ${ALLLIBS} 109 140 110 CacheableTest_SOURCES = CacheableTest.cpp CacheableTest.hpp141 CacheableTest_SOURCES = UnitTestMain.cpp CacheableTest.cpp CacheableTest.hpp 111 142 CacheableTest_LDADD = ${ALLLIBS} 112 143 113 DescriptorUnittest_SOURCES = DescriptorUnittest.cpp DescriptorUnittest.hpp144 DescriptorUnittest_SOURCES = UnitTestMain.cpp DescriptorUnittest.cpp DescriptorUnittest.hpp 114 145 DescriptorUnittest_LDADD = ${ALLLIBS} 115 146 116 manipulateAtomsTest_SOURCES = manipulateAtomsTest.cpp manipulateAtomsTest.hpp147 manipulateAtomsTest_SOURCES = UnitTestMain.cpp manipulateAtomsTest.cpp manipulateAtomsTest.hpp 117 148 manipulateAtomsTest_LDADD = ${ALLLIBS} 118 149 119 atomsCalculationTest_SOURCES = atomsCalculationTest.cpp atomsCalculationTest.hpp150 atomsCalculationTest_SOURCES = UnitTestMain.cpp atomsCalculationTest.cpp atomsCalculationTest.hpp 120 151 atomsCalculationTest_LDADD = ${ALLLIBS} 152 153 TestRunner_SOURCES = TestRunnerMain.cpp $(TESTSOURCES) $(TESTHEADERS) 154 TestRunner_LDADD = ${ALLLIBS} 121 155 122 156 #AUTOMAKE_OPTIONS = parallel-tests -
src/unittests/ObserverTest.cpp
rcbf01e r2561df 17 17 18 18 using namespace std; 19 20 #ifdef HAVE_TESTRUNNER 21 #include "UnitTestMain.hpp" 22 #endif /*HAVE_TESTRUNNER*/ 19 23 20 24 // Registers the fixture into the 'registry' … … 40 44 void changeMethod() { 41 45 OBSERVE; 42 int i ;46 int i = 0; 43 47 i++; 44 48 } … … 49 53 void changeMethod1() { 50 54 OBSERVE; 51 int i ;55 int i = 0; 52 56 i++; 53 57 } … … 55 59 void changeMethod2() { 56 60 OBSERVE; 57 int i ;61 int i = 0; 58 62 i++; 59 63 changeMethod1(); … … 72 76 void changeMethod() { 73 77 OBSERVE; 74 int i ;78 int i = 0; 75 79 i++; 76 80 subObservable->changeMethod(); … … 110 114 simpleObservable1->signOn(observer2); 111 115 simpleObservable1->signOn(observer3); 116 112 117 simpleObservable2->signOn(observer2); 113 118 simpleObservable2->signOn(observer4); … … 181 186 CPPUNIT_ASSERT(true); 182 187 } 183 184 /********************************************** Main routine **************************************/185 186 int main(int argc, char **argv)187 {188 // Get the top level suite from the registry189 CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();190 191 // Adds the test to the list of test to run192 CppUnit::TextUi::TestRunner runner;193 runner.addTest( suite );194 195 // Change the default outputter to a compiler error format outputter196 runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),197 std::cerr ) );198 // Run the tests.199 bool wasSucessful = runner.run();200 201 // Return error code 1 if the one of test failed.202 return wasSucessful ? 0 : 1;203 }; -
src/unittests/analysisbondsunittest.cpp
rcbf01e r2561df 25 25 #include "molecule.hpp" 26 26 #include "periodentafel.hpp" 27 28 #ifdef HAVE_TESTRUNNER 29 #include "UnitTestMain.hpp" 30 #endif /*HAVE_TESTRUNNER*/ 27 31 28 32 /********************************************** Test classes **************************************/ … … 57 61 58 62 // construct periodentafel 59 tafel = new periodentafel;63 tafel = World::get()->getPeriode(); 60 64 tafel->AddElement(hydrogen); 61 65 tafel->AddElement(carbon); 62 66 63 67 // construct molecule (tetraeder of hydrogens) 64 TestMolecule = new molecule(tafel);68 TestMolecule = World::get()->createMolecule(); 65 69 Walker = World::get()->createAtom(); 66 70 Walker->type = hydrogen; … … 113 117 114 118 // remove molecule 115 delete(TestMolecule);119 World::get()->destroyMolecule(TestMolecule); 116 120 // note that all the atoms are cleaned by TestMolecule 117 delete(tafel); 118 // note that element is cleaned by periodentafel 121 World::destroy(); 119 122 }; 120 123 … … 164 167 CPPUNIT_ASSERT_EQUAL( 0. , Max ); 165 168 }; 166 167 168 /********************************************** Main routine **************************************/169 170 int main(int argc, char **argv)171 {172 // Get the top level suite from the registry173 CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();174 175 // Adds the test to the list of test to run176 CppUnit::TextUi::TestRunner runner;177 runner.addTest( suite );178 179 // Change the default outputter to a compiler error format outputter180 runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),181 std::cerr ) );182 // Run the tests.183 bool wasSucessful = runner.run();184 185 // Return error code 1 if the one of test failed.186 return wasSucessful ? 0 : 1;187 }; -
src/unittests/atomsCalculationTest.cpp
rcbf01e r2561df 63 63 64 64 // some helper functions 65 bool hasAll(std::vector<int> ids,int min, int max, std::set<int> excluded = std::set<int>()){65 static bool hasAll(std::vector<int> ids,int min, int max, std::set<int> excluded = std::set<int>()){ 66 66 for(int i=min;i<max;++i){ 67 67 if(!excluded.count(i)){ … … 80 80 } 81 81 82 bool hasNoDuplicates(std::vector<int> ids){82 static bool hasNoDuplicates(std::vector<int> ids){ 83 83 std::set<int> found; 84 84 std::vector<int>::iterator iter; … … 92 92 } 93 93 94 void operation(atom* _atom){94 static void operation(atom* _atom){ 95 95 AtomStub *atom = dynamic_cast<AtomStub*>(_atom); 96 96 assert(atom); … … 116 116 CPPUNIT_ASSERT_EQUAL((size_t)(ATOM_COUNT-1),allIds.size()); 117 117 } 118 119 /********************************************** Main routine **************************************/120 121 int main(int argc, char **argv)122 {123 // Get the top level suite from the registry124 CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();125 126 // Adds the test to the list of test to run127 CppUnit::TextUi::TestRunner runner;128 runner.addTest( suite );129 130 // Change the default outputter to a compiler error format outputter131 runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),132 std::cerr ) );133 // Run the tests.134 bool wasSucessful = runner.run();135 136 // Return error code 1 if the one of test failed.137 return wasSucessful ? 0 : 1;138 }; -
src/unittests/bondgraphunittest.cpp
rcbf01e r2561df 24 24 #include "periodentafel.hpp" 25 25 #include "bondgraphunittest.hpp" 26 #include "World.hpp" 27 28 #ifdef HAVE_TESTRUNNER 29 #include "UnitTestMain.hpp" 30 #endif /*HAVE_TESTRUNNER*/ 26 31 27 32 /********************************************** Test classes **************************************/ … … 52 57 53 58 // construct periodentafel 54 tafel = new periodentafel;59 tafel = World::get()->getPeriode(); 55 60 tafel->AddElement(hydrogen); 56 61 tafel->AddElement(carbon); 57 62 58 63 // construct molecule (tetraeder of hydrogens) 59 TestMolecule = new molecule(tafel);64 TestMolecule = World::get()->createMolecule(); 60 65 Walker = World::get()->createAtom(); 61 66 Walker->type = hydrogen; … … 97 102 98 103 // remove molecule 99 delete(TestMolecule); 100 // note that all the atoms are cleaned by TestMolecule 101 delete(tafel); 102 // note that element is cleaned by periodentafel 104 World::get()->destroyMolecule(TestMolecule); 105 // note that all the atoms, molecules, the tafel and the elements 106 // are all cleaned when the world is destroyed 107 World::destroy(); 108 MemoryUsageObserver::purgeInstance(); 109 logger::purgeInstance(); 103 110 }; 104 111 … … 124 131 CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) ); 125 132 }; 126 127 128 /********************************************** Main routine **************************************/129 130 int main(int argc, char **argv)131 {132 // Get the top level suite from the registry133 CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();134 135 // Adds the test to the list of test to run136 CppUnit::TextUi::TestRunner runner;137 runner.addTest( suite );138 139 // Change the default outputter to a compiler error format outputter140 runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),141 std::cerr ) );142 // Run the tests.143 bool wasSucessful = runner.run();144 145 // Return error code 1 if the one of test failed.146 return wasSucessful ? 0 : 1;147 }; -
src/unittests/gslmatrixsymmetricunittest.cpp
rcbf01e r2561df 13 13 14 14 #include "gslmatrixsymmetricunittest.hpp" 15 16 #ifdef HAVE_TESTRUNNER 17 #include "UnitTestMain.hpp" 18 #endif /*HAVE_TESTRUNNER*/ 15 19 16 20 /********************************************** Test classes **************************************/ … … 266 270 CPPUNIT_ASSERT_EQUAL( -26.5, m->Determinant() ); 267 271 }; 268 269 /********************************************** Main routine **************************************/270 271 int main(int argc, char **argv)272 {273 // Get the top level suite from the registry274 CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();275 276 // Adds the test to the list of test to run277 CppUnit::TextUi::TestRunner runner;278 runner.addTest( suite );279 280 // Change the default outputter to a compiler error format outputter281 runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),282 std::cerr ) );283 // Run the tests.284 bool wasSucessful = runner.run();285 286 // Return error code 1 if the one of test failed.287 return wasSucessful ? 0 : 1;288 }; -
src/unittests/gslmatrixunittest.cpp
rcbf01e r2561df 13 13 14 14 #include "gslmatrixunittest.hpp" 15 16 #ifdef HAVE_TESTRUNNER 17 #include "UnitTestMain.hpp" 18 #endif /*HAVE_TESTRUNNER*/ 15 19 16 20 /********************************************** Test classes **************************************/ … … 248 252 CPPUNIT_ASSERT_EQUAL( false, m->IsPositiveDefinite() ); 249 253 }; 250 251 /********************************************** Main routine **************************************/252 253 int main(int argc, char **argv)254 {255 // Get the top level suite from the registry256 CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();257 258 // Adds the test to the list of test to run259 CppUnit::TextUi::TestRunner runner;260 runner.addTest( suite );261 262 // Change the default outputter to a compiler error format outputter263 runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),264 std::cerr ) );265 // Run the tests.266 bool wasSucessful = runner.run();267 268 // Return error code 1 if the one of test failed.269 return wasSucessful ? 0 : 1;270 }; -
src/unittests/gslvectorunittest.cpp
rcbf01e r2561df 13 13 14 14 #include "gslvectorunittest.hpp" 15 16 #ifdef HAVE_TESTRUNNER 17 #include "UnitTestMain.hpp" 18 #endif /*HAVE_TESTRUNNER*/ 15 19 16 20 /********************************************** Test classes **************************************/ … … 113 117 CPPUNIT_ASSERT_EQUAL( (double)(3-j), v->Get(j) ); 114 118 }; 115 116 117 /********************************************** Main routine **************************************/118 119 int main(int argc, char **argv)120 {121 // Get the top level suite from the registry122 CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();123 124 // Adds the test to the list of test to run125 CppUnit::TextUi::TestRunner runner;126 runner.addTest( suite );127 128 // Change the default outputter to a compiler error format outputter129 runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),130 std::cerr ) );131 // Run the tests.132 bool wasSucessful = runner.run();133 134 // Return error code 1 if the one of test failed.135 return wasSucessful ? 0 : 1;136 }; -
src/unittests/infounittest.cpp
rcbf01e r2561df 17 17 #include "info.hpp" 18 18 #include "infounittest.hpp" 19 #include "log.hpp" 20 21 #ifdef HAVE_TESTRUNNER 22 #include "UnitTestMain.hpp" 23 #endif /*HAVE_TESTRUNNER*/ 19 24 20 25 /********************************************** Test classes **************************************/ … … 31 36 void InfoTest::tearDown() 32 37 { 38 logger::purgeInstance(); 33 39 }; 34 40 … … 43 49 CPPUNIT_ASSERT_EQUAL( 1, test.verbosity ); 44 50 }; 45 46 47 /********************************************** Main routine **************************************/48 49 int main(int argc, char **argv)50 {51 // Get the top level suite from the registry52 CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();53 54 // Adds the test to the list of test to run55 CppUnit::TextUi::TestRunner runner;56 runner.addTest( suite );57 58 // Change the default outputter to a compiler error format outputter59 runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),60 std::cerr ) );61 // Run the tests.62 bool wasSucessful = runner.run();63 64 // Return error code 1 if the one of test failed.65 return wasSucessful ? 0 : 1;66 }; -
src/unittests/linearsystemofequationsunittest.cpp
rcbf01e r2561df 15 15 #include "linearsystemofequationsunittest.hpp" 16 16 #include "vector.hpp" 17 18 #ifdef HAVE_TESTRUNNER 19 #include "UnitTestMain.hpp" 20 #endif /*HAVE_TESTRUNNER*/ 17 21 18 22 /********************************************** Test classes **************************************/ … … 103 107 delete[](array); 104 108 }; 105 106 /********************************************** Main routine **************************************/107 108 int main(int argc, char **argv)109 {110 // Get the top level suite from the registry111 CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();112 113 // Adds the test to the list of test to run114 CppUnit::TextUi::TestRunner runner;115 runner.addTest( suite );116 117 // Change the default outputter to a compiler error format outputter118 runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),119 std::cerr ) );120 // Run the tests.121 bool wasSucessful = runner.run();122 123 // Return error code 1 if the one of test failed.124 return wasSucessful ? 0 : 1;125 }; -
src/unittests/listofbondsunittest.cpp
rcbf01e r2561df 22 22 #include "molecule.hpp" 23 23 #include "periodentafel.hpp" 24 #include "World.hpp" 25 26 #ifdef HAVE_TESTRUNNER 27 #include "UnitTestMain.hpp" 28 #endif /*HAVE_TESTRUNNER*/ 24 29 25 30 /********************************************** Test classes **************************************/ … … 46 51 47 52 // construct periodentafel 48 tafel = new periodentafel;53 tafel = World::get()->getPeriode(); 49 54 tafel->AddElement(hydrogen); 50 55 51 56 // construct molecule (tetraeder of hydrogens) 52 TestMolecule = new molecule(tafel);57 TestMolecule = World::get()->createMolecule(); 53 58 Walker = World::get()->createAtom(); 54 59 Walker->type = hydrogen; … … 77 82 { 78 83 // remove 79 delete(TestMolecule); 80 // note that all the atoms are cleaned by TestMolecule 81 delete(tafel); 82 // note that element is cleaned by periodentafel 84 World::get()->destroyMolecule(TestMolecule); 85 // note that all the atoms, molecules, the tafel and the elements 86 // are all cleaned when the world is destroyed 87 World::destroy(); 88 MemoryUsageObserver::purgeInstance(); 89 logger::purgeInstance(); 83 90 }; 84 91 … … 251 258 CPPUNIT_ASSERT_EQUAL( TestMolecule->first->next, TestMolecule->last ); 252 259 }; 253 254 /********************************************** Main routine **************************************/255 256 int main(int argc, char **argv)257 {258 // Get the top level suite from the registry259 CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();260 261 // Adds the test to the list of test to run262 CppUnit::TextUi::TestRunner runner;263 runner.addTest( suite );264 265 // Change the default outputter to a compiler error format outputter266 runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),267 std::cerr ) );268 // Run the tests.269 bool wasSucessful = runner.run();270 271 // Return error code 1 if the one of test failed.272 return wasSucessful ? 0 : 1;273 }; -
src/unittests/logunittest.cpp
rcbf01e r2561df 15 15 #include "verbose.hpp" 16 16 17 #ifdef HAVE_TESTRUNNER 18 #include "UnitTestMain.hpp" 19 #endif /*HAVE_TESTRUNNER*/ 20 17 21 /********************************************** Test classes **************************************/ 18 22 … … 27 31 void LogTest::tearDown() 28 32 { 33 logger::purgeInstance(); 34 errorLogger::purgeInstance(); 29 35 }; 30 36 … … 48 54 eLog() << Verbose(4) << "This should not be printed." << endl; 49 55 }; 50 51 52 /********************************************** Main routine **************************************/53 54 int main(int argc, char **argv)55 {56 // Get the top level suite from the registry57 CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();58 59 // Adds the test to the list of test to run60 CppUnit::TextUi::TestRunner runner;61 runner.addTest( suite );62 63 // Change the default outputter to a compiler error format outputter64 runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),65 std::cerr ) );66 // Run the tests.67 bool wasSucessful = runner.run();68 69 // Return error code 1 if the one of test failed.70 return wasSucessful ? 0 : 1;71 }; -
src/unittests/manipulateAtomsTest.cpp
rcbf01e r2561df 78 78 79 79 // some helper functions 80 bool hasAll(std::vector<atom*> atoms,int min, int max, std::set<int> excluded = std::set<int>()){80 static bool hasAll(std::vector<atom*> atoms,int min, int max, std::set<int> excluded = std::set<int>()){ 81 81 for(int i=min;i<max;++i){ 82 82 if(!excluded.count(i)){ … … 95 95 } 96 96 97 bool hasNoDuplicates(std::vector<atom*> atoms){97 static bool hasNoDuplicates(std::vector<atom*> atoms){ 98 98 std::set<int> found; 99 99 std::vector<atom*>::iterator iter; … … 107 107 } 108 108 109 void operation(atom* _atom){109 static void operation(atom* _atom){ 110 110 AtomStub *atom = dynamic_cast<AtomStub*>(_atom); 111 111 assert(atom); … … 153 153 delete obs; 154 154 } 155 156 /********************************************** Main routine **************************************/157 158 int main(int argc, char **argv)159 {160 // Get the top level suite from the registry161 CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();162 163 // Adds the test to the list of test to run164 CppUnit::TextUi::TestRunner runner;165 runner.addTest( suite );166 167 // Change the default outputter to a compiler error format outputter168 runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),169 std::cerr ) );170 // Run the tests.171 bool wasSucessful = runner.run();172 173 // Return error code 1 if the one of test failed.174 return wasSucessful ? 0 : 1;175 }; -
src/unittests/memoryallocatorunittest.cpp
rcbf01e r2561df 13 13 #include "memoryallocatorunittest.hpp" 14 14 #include "helpers.hpp" 15 #include "log.hpp" 15 16 #include "defs.hpp" 17 18 #ifdef HAVE_TESTRUNNER 19 #include "UnitTestMain.hpp" 20 #endif /*HAVE_TESTRUNNER*/ 16 21 17 22 /********************************************** Test classes **************************************/ … … 29 34 { 30 35 MemoryUsageObserver::getInstance()->purgeInstance(); 36 logger::purgeInstance(); 31 37 }; 32 38 … … 102 108 Free(buffer2); 103 109 }; 104 105 106 /********************************************** Main routine **************************************/107 108 int main(int argc, char **argv)109 {110 // Get the top level suite from the registry111 CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();112 113 // Adds the test to the list of test to run114 CppUnit::TextUi::TestRunner runner;115 runner.addTest( suite );116 117 // Change the default outputter to a compiler error format outputter118 runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),119 std::cerr ) );120 // Run the tests.121 bool wasSucessful = runner.run();122 123 // Return error code 1 if the one of test failed.124 return wasSucessful ? 0 : 1;125 }; -
src/unittests/memoryusageobserverunittest.cpp
rcbf01e r2561df 14 14 #include "memoryusageobserverunittest.hpp" 15 15 16 #ifdef HAVE_TESTRUNNER 17 #include "UnitTestMain.hpp" 18 #endif /*HAVE_TESTRUNNER*/ 19 16 20 /********************************************** Test classes **************************************/ 17 21 // Registers the fixture into the 'registry' … … 27 31 { 28 32 MemoryUsageObserver::purgeInstance(); 33 logger::purgeInstance(); 34 errorLogger::purgeInstance(); 29 35 }; 30 36 … … 70 76 MemoryUsageObserver::getInstance()->removeMemory(i); 71 77 CPPUNIT_ASSERT_EQUAL((size_t) 0, MemoryUsageObserver::getInstance()->getUsedMemorySize()); 78 Free(i); 72 79 }; 73 80 … … 80 87 MemoryUsageObserver::getInstance()->removeMemory(i); 81 88 CPPUNIT_ASSERT_EQUAL((size_t) 0, MemoryUsageObserver::getInstance()->getUsedMemorySize()); 89 Free(i); 82 90 }; 83 91 … … 92 100 MemoryUsageObserver::getInstance()->addMemory(j, sizeof(int)); 93 101 CPPUNIT_ASSERT_EQUAL(2 * sizeof(int), MemoryUsageObserver::getInstance()->getUsedMemorySize()); 102 Free(i); 103 Free(j); 94 104 }; 95 105 … … 103 113 MemoryUsageObserver::getInstance()->addMemory(i, sizeof(int)); 104 114 CPPUNIT_ASSERT_EQUAL(sizeof(int), MemoryUsageObserver::getInstance()->getUsedMemorySize()); 115 Free(i); 105 116 }; 106 117 … … 114 125 MemoryUsageObserver::getInstance()->addMemory(i, sizeof(int)); 115 126 CPPUNIT_ASSERT_EQUAL(2 * sizeof(int), MemoryUsageObserver::getInstance()->getMaximumUsedMemory()); 127 Free(i); 116 128 }; 117 129 … … 125 137 MemoryUsageObserver::getInstance()->removeMemory(i); 126 138 CPPUNIT_ASSERT_EQUAL(sizeof(int), MemoryUsageObserver::getInstance()->getMaximumUsedMemory()); 139 Free(i); 127 140 }; 128 141 … … 135 148 MemoryUsageObserver::getInstance()->addMemory(i, sizeof(int)); 136 149 CPPUNIT_ASSERT_EQUAL(i, (int*) MemoryUsageObserver::getInstance()->getPointersToAllocatedMemory().begin()->first); 150 Free(i); 137 151 }; 138 139 140 /********************************************** Main routine **************************************/141 142 int main(int argc, char **argv)143 {144 // Get the top level suite from the registry145 CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();146 147 // Adds the test to the list of test to run148 CppUnit::TextUi::TestRunner runner;149 runner.addTest( suite );150 151 // Change the default outputter to a compiler error format outputter152 runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),153 std::cerr ) );154 // Run the tests.155 bool wasSucessful = runner.run();156 157 // Return error code 1 if the one of test failed.158 return wasSucessful ? 0 : 1;159 }; -
src/unittests/stackclassunittest.cpp
rcbf01e r2561df 14 14 #include "stackclassunittest.hpp" 15 15 #include "log.hpp" 16 17 #ifdef HAVE_TESTRUNNER 18 #include "UnitTestMain.hpp" 19 #endif /*HAVE_TESTRUNNER*/ 16 20 17 21 enum { testdimension=3 }; … … 33 37 Stack->ClearStack(); 34 38 delete(Stack); 39 MemoryUsageObserver::purgeInstance(); 40 logger::purgeInstance(); 35 41 }; 36 42 … … 67 73 CPPUNIT_ASSERT_EQUAL(0, Stack->ItemCount()); 68 74 }; 69 70 71 /********************************************** Main routine **************************************/72 73 int main(int argc, char **argv)74 {75 // Get the top level suite from the registry76 CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();77 78 // Adds the test to the list of test to run79 CppUnit::TextUi::TestRunner runner;80 runner.addTest( suite );81 82 // Change the default outputter to a compiler error format outputter83 runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),84 std::cerr ) );85 // Run the tests.86 bool wasSucessful = runner.run();87 88 // Return error code 1 if the one of test failed.89 return wasSucessful ? 0 : 1;90 }; -
src/unittests/tesselation_boundarytriangleunittest.cpp
rcbf01e r2561df 18 18 #include "tesselation_boundarytriangleunittest.hpp" 19 19 20 #ifdef HAVE_TESTRUNNER 21 #include "UnitTestMain.hpp" 22 #endif /*HAVE_TESTRUNNER*/ 23 20 24 #define SPHERERADIUS 2. 21 25 … … 31 35 32 36 // create nodes 33 TesselPoint *Walker = NULL; 34 Walker = new TesselPoint; 35 Walker->node = new Vector(0., 0., 0.); 36 Walker->Name = Malloc<char>(3, "TesselationBoundaryTriangleTest::setUp - *Name"); 37 strcpy(Walker->Name, "1"); 38 Walker->nr = 1; 39 points[0] = new BoundaryPointSet(Walker); 40 Walker = new TesselPoint; 41 Walker->node = new Vector(0., 1., 0.); 42 Walker->Name = Malloc<char>(3, "TesselationBoundaryTriangleTest::setUp - *Name"); 43 strcpy(Walker->Name, "2"); 44 Walker->nr = 2; 45 points[1] = new BoundaryPointSet(Walker); 46 Walker = new TesselPoint; 47 Walker->node = new Vector(1., 0., 0.); 48 Walker->Name = Malloc<char>(3, "TesselationBoundaryTriangleTest::setUp - *Name"); 49 strcpy(Walker->Name, "3"); 50 Walker->nr = 3; 51 points[2] = new BoundaryPointSet(Walker); 37 tesselpoints[0] = new TesselPoint; 38 tesselpoints[0]->node = new Vector(0., 0., 0.); 39 tesselpoints[0]->Name = Malloc<char>(3, "TesselationBoundaryTriangleTest::setUp - *Name"); 40 strcpy(tesselpoints[0]->Name, "1"); 41 tesselpoints[0]->nr = 1; 42 points[0] = new BoundaryPointSet(tesselpoints[0]); 43 tesselpoints[1] = new TesselPoint; 44 tesselpoints[1]->node = new Vector(0., 1., 0.); 45 tesselpoints[1]->Name = Malloc<char>(3, "TesselationBoundaryTriangleTest::setUp - *Name"); 46 strcpy(tesselpoints[1]->Name, "2"); 47 tesselpoints[1]->nr = 2; 48 points[1] = new BoundaryPointSet(tesselpoints[1]); 49 tesselpoints[2] = new TesselPoint; 50 tesselpoints[2] ->node = new Vector(1., 0., 0.); 51 tesselpoints[2] ->Name = Malloc<char>(3, "TesselationBoundaryTriangleTest::setUp - *Name"); 52 strcpy(tesselpoints[2] ->Name, "3"); 53 tesselpoints[2] ->nr = 3; 54 points[2] = new BoundaryPointSet(tesselpoints[2] ); 52 55 53 56 // create line … … 65 68 { 66 69 delete(triangle); 70 for (int i=0;i<3;++i) { 71 // TesselPoint does not delete its vector as it only got a reference 72 delete tesselpoints[i]->node; 73 delete tesselpoints[i]; 74 } 67 75 MemoryUsageObserver::purgeInstance(); 68 76 logger::purgeInstance(); … … 191 199 CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection ); 192 200 }; 193 194 195 /********************************************** Main routine **************************************/196 197 int main(int argc, char **argv)198 {199 // Get the top level suite from the registry200 CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();201 202 // Adds the test to the list of test to run203 CppUnit::TextUi::TestRunner runner;204 runner.addTest( suite );205 206 // Change the default outputter to a compiler error format outputter207 runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),208 std::cerr ) );209 // Run the tests.210 bool wasSucessful = runner.run();211 212 // Return error code 1 if the one of test failed.213 return wasSucessful ? 0 : 1;214 }; -
src/unittests/tesselation_boundarytriangleunittest.hpp
rcbf01e r2561df 35 35 class BoundaryLineSet *lines[3]; 36 36 class BoundaryPointSet *points[3]; 37 class TesselPoint *tesselpoints[3]; 37 38 LinkedNodes Corners; 38 39 }; -
src/unittests/tesselation_insideoutsideunittest.cpp
rcbf01e r2561df 17 17 #include "tesselation.hpp" 18 18 #include "tesselation_insideoutsideunittest.hpp" 19 20 #ifdef HAVE_TESTRUNNER 21 #include "UnitTestMain.hpp" 22 #endif /*HAVE_TESTRUNNER*/ 19 23 20 24 #define SPHERERADIUS 2. … … 161 165 } 162 166 }; 163 164 /********************************************** Main routine **************************************/165 166 int main(int argc, char **argv)167 {168 // Get the top level suite from the registry169 CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();170 171 // Adds the test to the list of test to run172 CppUnit::TextUi::TestRunner runner;173 runner.addTest( suite );174 175 // Change the default outputter to a compiler error format outputter176 runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),177 std::cerr ) );178 // Run the tests.179 bool wasSucessful = runner.run();180 181 // Return error code 1 if the one of test failed.182 return wasSucessful ? 0 : 1;183 }; -
src/unittests/tesselationunittest.cpp
rcbf01e r2561df 18 18 #include "tesselation.hpp" 19 19 #include "tesselationunittest.hpp" 20 21 #ifdef HAVE_TESTRUNNER 22 #include "UnitTestMain.hpp" 23 #endif /*HAVE_TESTRUNNER*/ 20 24 21 25 #define SPHERERADIUS 2. … … 177 181 } 178 182 } 179 180 /********************************************** Main routine **************************************/181 182 int main(int argc, char **argv)183 {184 // Get the top level suite from the registry185 CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();186 187 // Adds the test to the list of test to run188 CppUnit::TextUi::TestRunner runner;189 runner.addTest( suite );190 191 // Change the default outputter to a compiler error format outputter192 runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),193 std::cerr ) );194 // Run the tests.195 bool wasSucessful = runner.run();196 197 // Return error code 1 if the one of test failed.198 return wasSucessful ? 0 : 1;199 }; -
src/unittests/vectorunittest.cpp
rcbf01e r2561df 14 14 15 15 #include "defs.hpp" 16 #include "log.hpp" 17 #include "memoryusageobserver.hpp" 16 18 #include "vector.hpp" 17 19 #include "vectorunittest.hpp" 20 21 #ifdef HAVE_TESTRUNNER 22 #include "UnitTestMain.hpp" 23 #endif /*HAVE_TESTRUNNER*/ 18 24 19 25 /********************************************** Test classes **************************************/ … … 35 41 void VectorTest::tearDown() 36 42 { 43 MemoryUsageObserver::purgeInstance(); 44 logger::purgeInstance(); 45 errorLogger::purgeInstance(); 37 46 }; 38 47 … … 290 299 } 291 300 292 293 /********************************************** Main routine **************************************/294 295 int main(int argc, char **argv)296 {297 // Get the top level suite from the registry298 CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();299 300 // Adds the test to the list of test to run301 CppUnit::TextUi::TestRunner runner;302 runner.addTest( suite );303 304 // Change the default outputter to a compiler error format outputter305 runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),306 std::cerr ) );307 // Run the tests.308 bool wasSucessful = runner.run();309 310 // Return error code 1 if the one of test failed.311 return wasSucessful ? 0 : 1;312 }; -
src/vector.cpp
rcbf01e r2561df 330 330 return false; 331 331 } 332 delete(M); 332 333 Log() << Verbose(1) << "INFO: Line1a = " << *Line1a << ", Line1b = " << *Line1b << ", Line2a = " << *Line2a << ", Line2b = " << *Line2b << "." << endl; 333 334 … … 585 586 * \return lhs + a 586 587 */ 587 Vector& operator+=(Vector& a, const Vector& b)588 const Vector& operator+=(Vector& a, const Vector& b) 588 589 { 589 590 a.AddVector(&b); … … 596 597 * \return lhs - a 597 598 */ 598 Vector& operator-=(Vector& a, const Vector& b)599 const Vector& operator-=(Vector& a, const Vector& b) 599 600 { 600 601 a.SubtractVector(&b); … … 607 608 * \return lhs.x[i] * m 608 609 */ 609 Vector& operator*=(Vector& a, const double m)610 const Vector& operator*=(Vector& a, const double m) 610 611 { 611 612 a.Scale(m); … … 618 619 * \return a + b 619 620 */ 620 Vector& operator+(const Vector& a, const Vector& b) 621 { 622 Vector *x = new Vector; 623 x->CopyVector(&a); 624 x->AddVector(&b); 625 return *x; 621 Vector const operator+(const Vector& a, const Vector& b) 622 { 623 Vector x(a); 624 x.AddVector(&b); 625 return x; 626 626 }; 627 627 … … 631 631 * \return a - b 632 632 */ 633 Vector& operator-(const Vector& a, const Vector& b) 634 { 635 Vector *x = new Vector; 636 x->CopyVector(&a); 637 x->SubtractVector(&b); 638 return *x; 633 Vector const operator-(const Vector& a, const Vector& b) 634 { 635 Vector x(a); 636 x.SubtractVector(&b); 637 return x; 639 638 }; 640 639 … … 644 643 * \return m * a 645 644 */ 646 Vector& operator*(const Vector& a, const double m) 647 { 648 Vector *x = new Vector; 649 x->CopyVector(&a); 650 x->Scale(m); 651 return *x; 645 Vector const operator*(const Vector& a, const double m) 646 { 647 Vector x(a); 648 x.Scale(m); 649 return x; 652 650 }; 653 651 … … 657 655 * \return m * a 658 656 */ 659 Vector& operator*(const double m, const Vector& a ) 660 { 661 Vector *x = new Vector; 662 x->CopyVector(&a); 663 x->Scale(m); 664 return *x; 657 Vector const operator*(const double m, const Vector& a ) 658 { 659 Vector x(a); 660 x.Scale(m); 661 return x; 665 662 }; 666 663 -
src/vector.hpp
rcbf01e r2561df 87 87 ostream & operator << (ostream& ost, const Vector &m); 88 88 bool operator==(const Vector& a, const Vector& b); 89 Vector& operator+=(Vector& a, const Vector& b);90 Vector& operator-=(Vector& a, const Vector& b);91 Vector& operator*=(Vector& a, const double m);92 Vector &operator*(const Vector& a, const double m);93 Vector &operator*(const double m, const Vector& a);94 Vector &operator+(const Vector& a, const Vector& b);95 Vector &operator-(const Vector& a, const Vector& b);89 const Vector& operator+=(Vector& a, const Vector& b); 90 const Vector& operator-=(Vector& a, const Vector& b); 91 const Vector& operator*=(Vector& a, const double m); 92 Vector const operator*(const Vector& a, const double m); 93 Vector const operator*(const double m, const Vector& a); 94 Vector const operator+(const Vector& a, const Vector& b); 95 Vector const operator-(const Vector& a, const Vector& b); 96 96 97 97 -
tests/Tesselations/defs.in
rcbf01e r2561df 26 26 if $testdir_exists; then :; else 27 27 mkdir $testdir 28 CLEANUP="rm dir$testdir; $CLEANUP"28 CLEANUP="rm -rf $testdir; $CLEANUP" 29 29 fi 30 30 cp @srcdir@/$testdir/* $testdir/
Note:
See TracChangeset
for help on using the changeset viewer.