Changes in / [cbf01e:2561df]


Ignore:
Files:
2 added
75 edited

Legend:

Unmodified
Added
Removed
  • configure.ac

    rcbf01e r2561df  
    7272fi
    7373
     74# add replacement/saturation hydrogen or not
     75AC_ARG_ENABLE([ecut],AS_HELP_STRING([--enable-ecut],[Use ECut TestRunnerClient (default is yes)]),
     76              [enable_ecut=$enableval], [enable_ecut=yes])
     77if test x"$enable_ecut" = xyes; then
     78  AC_DEFINE(HAVE_ECUT,1, ["Use ECut TestRunnerClient instead of our own."])
     79  AC_SUBST(HAVE_ECUT)
     80fi
     81
    7482# Check for "extern inline", using a modified version
    7583# of the test for AC_C_INLINE from acspecific.mt
  • src/Actions/ActionRegistry.cpp

    rcbf01e r2561df  
    2424{
    2525  map<const string,Action*>::iterator iter;
    26   for(iter=actionMap.begin();iter!=actionMap.end();iter++) {
     26  for(iter=actionMap.begin();iter!=actionMap.end();++iter) {
    2727    delete iter->second;
    28     actionMap.erase(iter);
    2928  }
     29  actionMap.clear();
    3030}
    3131
  • src/Actions/MakroAction.cpp

    rcbf01e r2561df  
    2323{
    2424  Action* action;
    25   while(action=actions->removeLastAction()){
     25  while((action=actions->removeLastAction())){
    2626    delete action;
    2727  }
  • src/Actions/ManipulateAtomsProcess.cpp

    rcbf01e r2561df  
    1414ManipulateAtomsProcess::ManipulateAtomsProcess(boost::function<void(atom*)> _operation, AtomDescriptor _descr,
    1515                                               std::string _name,bool _doRegister) :
    16   operation(_operation),
     16  Process(0,_name,_doRegister),
    1717  descr(_descr),
    18   Process(0,_name,_doRegister)
     18  operation(_operation)
    1919{}
    2020
  • src/Actions/Process.cpp

    rcbf01e r2561df  
    1313  Action(_name,_doRegister),
    1414  maxSteps(_maxSteps),
     15  active(false),
    1516  starts(false),
    16   stops(false),
    17   active(false)
     17  stops(false)
    1818{}
    1919
  • src/Descriptors/AtomDescriptor.cpp

    rcbf01e r2561df  
    1919using namespace std;
    2020
    21 typedef map<int,atom*> atoms_t;
    22 typedef atoms_t::iterator atoms_iter_t;
     21typedef World::AtomSet::iterator atoms_iter_t;
    2322
    2423/************************ Forwarding object **************************************/
     
    6867}
    6968
    70 atoms_t& AtomDescriptor_impl::getAtoms(){
     69World::AtomSet& AtomDescriptor_impl::getAtoms(){
    7170  return World::get()->atoms;
    7271}
    7372
    7473atom* AtomDescriptor_impl::find() {
    75   atoms_t atoms = getAtoms();
     74  World::AtomSet atoms = getAtoms();
    7675  atoms_iter_t res = find_if(atoms.begin(),atoms.end(),boost::bind(&AtomDescriptor_impl::predicate,this,_1));
    7776  return (res!=atoms.end())?((*res).second):0;
     
    8079vector<atom*> AtomDescriptor_impl::findAll() {
    8180  vector<atom*> res;
    82   atoms_t atoms = getAtoms();
     81  World::AtomSet atoms = getAtoms();
    8382  atoms_iter_t iter;
    8483  for(iter=atoms.begin();iter!=atoms.end();++iter) {
     
    9897{}
    9998
    100 bool AtomAllDescriptor_impl::predicate(std::pair<int,atom*>){
     99bool AtomAllDescriptor_impl::predicate(std::pair<atomId_t,atom*>){
    101100  return true;
    102101}
     
    112111{}
    113112
    114 bool AtomNoneDescriptor_impl::predicate(std::pair<int,atom*>){
     113bool AtomNoneDescriptor_impl::predicate(std::pair<atomId_t,atom*>){
    115114  return false;
    116115}
     
    130129{}
    131130
    132 bool AtomAndDescriptor_impl::predicate(std::pair<int,atom*> atom){
     131bool AtomAndDescriptor_impl::predicate(std::pair<atomId_t,atom*> atom){
    133132  return lhs->predicate(atom) && rhs->predicate(atom);
    134133}
     
    146145}
    147146
    148 bool AtomOrDescriptor_impl::predicate(std::pair<int,atom*> atom){
     147bool AtomOrDescriptor_impl::predicate(std::pair<atomId_t,atom*> atom){
    149148  return lhs->predicate(atom) || rhs->predicate(atom);
    150149}
     
    166165}
    167166
    168 bool AtomNotDescriptor_impl::predicate(std::pair<int,atom*> atom){
     167bool AtomNotDescriptor_impl::predicate(std::pair<atomId_t,atom*> atom){
    169168 return !(arg->predicate(atom));
    170169}
  • src/Descriptors/AtomDescriptor_impl.hpp

    rcbf01e r2561df  
    11#ifndef ATOMDESCRIPTOR_IMPL_HPP
    22#define ATOMDESCRIPTOR_IMPL_HPP
     3
     4#include "Descriptors/AtomDescriptor.hpp"
    35
    46/************************ Declarations of implementation Objects ************************/
     
    1214  virtual ~AtomDescriptor_impl();
    1315
    14   virtual bool predicate(std::pair<int,atom*>)=0;
     16  virtual bool predicate(std::pair<atomId_t,atom*>)=0;
    1517
    1618protected:
    1719  virtual atom* find();
    1820  virtual std::vector<atom*> findAll();
    19   std::map<int,atom*>& getAtoms();
     21  World::AtomSet& getAtoms();
    2022};
    2123
     
    2628  AtomAllDescriptor_impl();
    2729  virtual ~AtomAllDescriptor_impl();
    28   virtual bool predicate(std::pair<int,atom*>);
     30  virtual bool predicate(std::pair<atomId_t,atom*>);
    2931};
    3032
     
    3335  AtomNoneDescriptor_impl();
    3436  virtual ~AtomNoneDescriptor_impl();
    35   virtual bool predicate(std::pair<int,atom*>);
     37  virtual bool predicate(std::pair<atomId_t,atom*>);
    3638};
    3739
     
    4345  AtomAndDescriptor_impl(AtomDescriptor::impl_ptr _lhs, AtomDescriptor::impl_ptr _rhs);
    4446  ~AtomAndDescriptor_impl();
    45   virtual bool predicate(std::pair<int,atom*>);
     47  virtual bool predicate(std::pair<atomId_t,atom*>);
    4648
    4749private:
     
    5557  AtomOrDescriptor_impl(AtomDescriptor::impl_ptr _lhs, AtomDescriptor::impl_ptr _rhs);
    5658  virtual ~AtomOrDescriptor_impl();
    57   virtual bool predicate(std::pair<int,atom*>);
     59  virtual bool predicate(std::pair<atomId_t,atom*>);
    5860
    5961private:
     
    6870  virtual ~AtomNotDescriptor_impl();
    6971
    70   virtual bool predicate(std::pair<int,atom*>);
     72  virtual bool predicate(std::pair<atomId_t,atom*>);
    7173
    7274private:
  • src/Descriptors/AtomIdDescriptor.cpp

    rcbf01e r2561df  
    1414
    1515
    16 AtomIdDescriptor_impl::AtomIdDescriptor_impl(int _id) :
     16AtomIdDescriptor_impl::AtomIdDescriptor_impl(atomId_t _id) :
    1717  id(_id)
    1818{}
     
    2121{}
    2222
    23 bool AtomIdDescriptor_impl::predicate(std::pair<int,atom*> atom) {
     23bool AtomIdDescriptor_impl::predicate(std::pair<atomId_t,atom*> atom) {
    2424  return atom.first==id;
    2525}
    2626
    27 AtomDescriptor AtomById(int id){
     27AtomDescriptor AtomById(atomId_t id){
    2828  return AtomDescriptor(AtomDescriptor::impl_ptr(new AtomIdDescriptor_impl(id)));
    2929}
    3030
    3131atom *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);
    3434  return (res!=atoms.end())?((*res).second):0;
    3535}
  • src/Descriptors/AtomIdDescriptor.hpp

    rcbf01e r2561df  
    99#define ATOMIDDESCRIPTOR_HPP_
    1010
     11#include "defs.hpp"
    1112#include "Descriptors/AtomDescriptor.hpp"
    1213
    13 AtomDescriptor AtomById(int id);
     14AtomDescriptor AtomById(atomId_t id);
    1415
    1516#endif /* ATOMIDDESCRIPTOR_HPP_ */
  • src/Descriptors/AtomIdDescriptor_impl.hpp

    rcbf01e r2561df  
    77{
    88public:
    9   AtomIdDescriptor_impl(int _id);
     9  AtomIdDescriptor_impl(atomId_t _id);
    1010  virtual ~AtomIdDescriptor_impl();
    1111
    12   bool predicate(std::pair<int,atom*> atom);
     12  bool predicate(std::pair<atomId_t,atom*> atom);
    1313
    1414protected:
     
    1616  virtual std::vector<atom*> findAll();
    1717private:
    18   int id;
     18  atomId_t id;
    1919};
    2020
  • src/Descriptors/AtomTypeDescriptor.cpp

    rcbf01e r2561df  
    2020{}
    2121
    22 bool AtomTypeDescriptor_impl::predicate(std::pair<int,atom*> atom) {
     22bool AtomTypeDescriptor_impl::predicate(std::pair<atomId_t,atom*> atom) {
    2323  return (atom.second->getType()==type);
    2424}
  • src/Descriptors/AtomTypeDescriptor_impl.hpp

    rcbf01e r2561df  
    1717  virtual ~AtomTypeDescriptor_impl();
    1818
    19   bool predicate(std::pair<int,atom*> atom);
     19  bool predicate(std::pair<atomId_t,atom*> atom);
    2020private:
    2121  element *type;
  • src/Legacy/oldmenu.cpp

    rcbf01e r2561df  
    812812void oldmenu::ManipulateMolecules(periodentafel *periode, MoleculeListClass *molecules, config *configuration)
    813813{
    814   atom *first = NULL;
    815814  Vector x,y,z,n; // coordinates for absolute point in cell volume
    816   int j, axis, count, faktor;
    817815  char choice;  // menu choice char
    818816  molecule *mol = NULL;
    819   element **Elements;
    820   Vector **vectors;
    821817  MoleculeLeafClass *Subgraphs = NULL;
    822818
     
    10931089    A++;
    10941090  }
    1095   delete(mol);
     1091  World::get()->destroyMolecule(mol);
    10961092};
    10971093
  • src/Makefile.am

    rcbf01e r2561df  
    6060molecuilderdir = ${bindir}
    6161
    62 #libmolecuilder_a_CXXFLAGS = -DNO_CACHING
    6362libmolecuilder_a_SOURCES = ${SOURCE} ${HEADER}
    6463
  • src/Menu/DisplayMenuItem.cpp

    rcbf01e r2561df  
    2121
    2222DisplayMenuItem::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)
    2828{
    2929}
    3030
    3131DisplayMenuItem::~DisplayMenuItem()
    32 {
    33   // TODO Auto-generated destructor stub
    34 }
     32{}
    3533
    3634
  • src/Menu/TextMenu.cpp

    rcbf01e r2561df  
    1818 */
    1919TextMenu::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)
    2626{
    2727}
  • src/Patterns/Cacheable.hpp

    rcbf01e r2561df  
    4343  Cacheable<T>::Cacheable(Observable *_owner, boost::function<T()> _recalcMethod) :
    4444    owner(_owner),
    45     recalcMethod(_recalcMethod),
    4645    valid(false),
    47     canBeUsed(true)
     46    canBeUsed(true),
     47    recalcMethod(_recalcMethod)
    4848  {
    4949    // we sign on with the best(=lowest) priority, so cached values are recalculated before
  • src/Patterns/Observer.cpp

    rcbf01e r2561df  
    2424// See [Gamma et al, 1995] p. 297
    2525
    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 
     26map<Observable*, int> Observable::depth;  //!< Map of Observables to the depth of the DAG of Observers
     27map<Observable*,multimap<int,Observer*>*> Observable::callTable; //!< Table for each Observable of all its Observers
     28set<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 */
    3539void Observable::start_observer_internal(Observable *publisher){
    3640  // increase the count for this observable by one
     
    4044}
    4145
     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 */
    4256void Observable::finish_observer_internal(Observable *publisher){
    4357  // decrease the count for this observable
     
    5367}
    5468
     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 */
    5575Observable::_Observable_protector::_Observable_protector(Observable *_protege) :
    5676  protege(_protege)
     
    5979}
    6080
     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 */
    6187Observable::_Observable_protector::~_Observable_protector()
    6288{
     
    6692/************* Notification mechanism for observables **************/
    6793
    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 */
    6998void Observable::notifyAll() {
    7099  // we are busy notifying others right now
     
    79108    callees_t *callees = callTable[this];
    80109    callees_t::iterator iter;
    81     for(iter=callees->begin();iter!=callees->end();iter++){
     110    for(iter=callees->begin();iter!=callees->end();++iter){
    82111      (*iter).second->update(this);
    83112    }
     
    87116}
    88117
    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 */
    90123void Observable::update(Observable *publisher) {
    91124  // circle detection
     
    109142}
    110143
    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 */
    112149void Observable::signOn(Observer *target,int priority) {
    113150  assert(priority>=-20 && priority<=+20 && "Priority out of range [-20:+20]");
     
    123160
    124161  callees_t::iterator iter;
    125   for(iter=callees->begin();iter!=callees->end();iter++){
     162  for(iter=callees->begin();iter!=callees->end();++iter){
    126163    res |= ((*iter).second == target);
    127164  }
     
    130167}
    131168
     169/** Sign off an Observer from this Observable.
     170 * Removes \a *target from Observable::callTable list.
     171 * \param *target Observer
     172 */
    132173void Observable::signOff(Observer *target) {
    133174  assert(callTable.count(this) && "SignOff called for an Observable without Observers.");
    134175  callees_t *callees = callTable[this];
    135176  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    }
    139185  }
    140186  if(callees->empty()){
     
    144190}
    145191
    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 */
    147196void Observable::subjectKilled(Observable *publisher){
    148197}
    149198
     199/** Constructor for class Observable.
     200 */
    150201Observable::Observable()
    151202{}
    152203
    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 */
    154207Observable::~Observable()
    155208{
     
    158211    callees_t *callees = callTable[this];
    159212    callees_t::iterator iter;
    160     for(iter=callees->begin();iter!=callees->end();iter++){
     213    for(iter=callees->begin();iter!=callees->end();++iter){
    161214      (*iter).second->subjectKilled(this);
    162215    }
     
    166219}
    167220
     221/** Constructor for class Observer.
     222 */
    168223Observer::Observer()
    169224{}
    170225
     226/** Destructor for class Observer.
     227 */
    171228Observer::~Observer()
    172229{}
  • src/Patterns/Observer.hpp

    rcbf01e r2561df  
    1616 *
    1717 * 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 macro
     18 * In the Observable code that changes, attributes should be started with OBSERVE;. This macro
    1919 * locks the observer mechanism while changes are done. At the end of the scope in which the
    2020 * macro was placed the lock is released. When the last lock is released all changes are
  • src/UIElements/Dialog.cpp

    rcbf01e r2561df  
    115115Dialog::MoleculeQuery::MoleculeQuery(string title, molecule **_target, MoleculeListClass *_molecules) :
    116116    Query(title),
    117     target(_target),
     117    tmp(0),
    118118    molecules(_molecules),
    119     tmp(0)
     119    target(_target)
     120
    120121{}
    121122
     
    129130
    130131Dialog::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)
    132136{
    133137tmp = new Vector();
  • src/UIElements/TextStatusIndicator.cpp

    rcbf01e r2561df  
    2727  Process *proc;
    2828  // we are only observing Processes
    29   if(proc=dynamic_cast<Process*>(subject)){
     29  if((proc=dynamic_cast<Process*>(subject))){
    3030    // see what kind of progress we have to display
    3131    if(proc->getMaxSteps()>0){
  • src/Views/MethodStringView.cpp

    rcbf01e r2561df  
    77
    88#include "MethodStringView.hpp"
     9
     10using namespace std;
    911
    1012MethodStringView::MethodStringView(boost::function<string()> _displayMethod) :
  • src/Views/MethodStringView.hpp

    rcbf01e r2561df  
    1919{
    2020public:
    21   MethodStringView(boost::function<string()>);
     21  MethodStringView(boost::function<std::string()>);
    2222  virtual ~MethodStringView();
    2323
    24   virtual const string toString();
     24  virtual const std::string toString();
    2525
    2626private:
    27   boost::function<string()> displayMethod;
     27  boost::function<std::string()> displayMethod;
    2828};
    2929
  • src/Views/StreamStringView.cpp

    rcbf01e r2561df  
    77
    88#include <sstream>
     9#include <iostream>
    910
    1011#include "StreamStringView.hpp"
    1112
    12 StreamStringView::StreamStringView(boost::function<void(ofstream *)> _displayMethod) :
     13using namespace std;
     14
     15StreamStringView::StreamStringView(boost::function<void(ostream *)> _displayMethod) :
    1316StringView(),
    1417displayMethod(_displayMethod)
    15 {
    16   // TODO Auto-generated constructor stub
    17 
    18 }
     18{}
    1919
    2020StreamStringView::~StreamStringView()
    21 {
    22   // TODO Auto-generated destructor stub
    23 }
     21{}
    2422
    2523const string StreamStringView::toString() {
    2624  stringstream s;
    27   displayMethod((ofstream *)&s);
     25  displayMethod(dynamic_cast<ostream *>(&s));
    2826  return s.str();
    2927}
  • src/Views/StreamStringView.hpp

    rcbf01e r2561df  
    1010
    1111#include <boost/function.hpp>
     12#include <iostream>
    1213
    1314#include "Views/StringView.hpp"
     
    2425{
    2526public:
    26   StreamStringView(boost::function<void(ofstream *)>);
     27  StreamStringView(boost::function<void(std::ostream *)>);
    2728  virtual ~StreamStringView();
    2829
    29   virtual const string toString();
     30  virtual const std::string toString();
    3031
    3132private:
    32   boost::function<void(ofstream *)> displayMethod;
     33  boost::function<void(std::ostream *)> displayMethod;
    3334};
    3435
  • src/Views/StringView.hpp

    rcbf01e r2561df  
    1212#include "Views/View.hpp"
    1313
    14 using namespace std;
    15 
    1614/**
    1715 * View to show something as a string
     
    2624  virtual ~StringView();
    2725
    28   virtual const string toString()=0;
     26  virtual const std::string toString()=0;
    2927};
    3028
  • src/World.cpp

    rcbf01e r2561df  
    4747  OBSERVE;
    4848  molecule *mol = NULL;
    49   mol = new molecule(periode);
    50   molecules_deprecated->insert(mol);
     49  mol = NewMolecule();
    5150  assert(!molecules.count(currMoleculeId));
     51  mol->setId(currMoleculeId++);
    5252  // store the molecule by ID
    53   molecules[currMoleculeId++] = mol;
     53  molecules[mol->getId()] = mol;
    5454  mol->signOn(this);
    5555  return mol;
     56}
     57
     58void World::destroyMolecule(molecule* mol){
     59  OBSERVE;
     60  destroyMolecule(mol->getId());
     61}
     62
     63void World::destroyMolecule(moleculeId_t id){
     64  OBSERVE;
     65  molecule *mol = molecules[id];
     66  assert(mol);
     67  DeleteMolecule(mol);
     68  molecules.erase(id);
    5669}
    5770
     
    8396}
    8497
    85 void World::destroyAtom(int id) {
     98void World::destroyAtom(atomId_t id) {
    8699  OBSERVE;
    87100  atom *atom = atoms[id];
     
    131144
    132145World::World() :
     146    periode(new periodentafel),
     147    atoms(),
    133148    currAtomId(0),
     149    molecules(),
    134150    currMoleculeId(0),
    135     periode(new periodentafel),
    136     molecules_deprecated(new MoleculeListClass),
    137     atoms(),
    138     molecules()
     151    molecules_deprecated(new MoleculeListClass(this))
    139152{
    140153  molecules_deprecated->signOn(this);
     
    143156World::~World()
    144157{
     158  molecules_deprecated->signOff(this);
    145159  delete molecules_deprecated;
    146160  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);
    150169  }
    151170  atoms.clear();
     
    188207  // should see that it gets the updated new world
    189208  delete oldWorld;
     209  return theWorld;
    190210}
    191211
  • src/World.hpp

    rcbf01e r2561df  
    1616#include <boost/shared_ptr.hpp>
    1717
    18 
     18#include "defs.hpp"
    1919#include "Patterns/Observer.hpp"
    2020#include "Patterns/Cacheable.hpp"
     
    4040friend class ManipulateAtomsProcess;
    4141template<typename> friend class AtomsCalculation;
    42 
    43 typedef std::map<int,atom*> AtomSet;
    44 typedef std::map<int,molecule*> MoleculeSet;
    4542public:
     43  typedef std::map<atomId_t,atom*> AtomSet;
     44  typedef std::map<moleculeId_t,molecule*> MoleculeSet;
    4645
    4746  /***** getter and setter *****/
     
    9089  molecule *createMolecule();
    9190
     91  void destroyMolecule(molecule*);
     92  void destroyMolecule(moleculeId_t);
     93
    9294  /**
    9395   * Create a new atom. This method should be used whenever any atom is needed. Assigns a unique ID and stores
     
    112114   * atom directly since this will leave the pointer inside the world.
    113115   */
    114   void destroyAtom(int);
     116  void destroyAtom(atomId_t);
    115117
    116118  /**
     
    140142  protected:
    141143    void advanceState();
    142     World* world;
    143144    AtomSet::iterator state;
    144145    boost::shared_ptr<AtomDescriptor_impl>  descr;
    145146    int index;
     147
     148    World* world;
    146149  };
    147150
     
    166169  periodentafel *periode;
    167170  AtomSet atoms;
    168   int currAtomId; //!< stores the next available Id for atoms
     171  atomId_t currAtomId; //!< stores the next available Id for atoms
    169172  MoleculeSet molecules;
    170   int currMoleculeId;
     173  moleculeId_t currMoleculeId;
    171174
    172175
  • src/WorldIterators.cpp

    rcbf01e r2561df  
    1717World::AtomIterator::AtomIterator(AtomDescriptor _descr, World* _world) :
    1818    descr(_descr.get_impl()),
    19     world(_world),
    20     index(0)
     19    index(0),
     20    world(_world)
    2121{
    2222  state = world->atoms.begin();
  • src/atom_particleinfo.cpp

    rcbf01e r2561df  
    1414
    1515ParticleInfo::ParticleInfo(ParticleInfo *pointer) :
    16     Name(pointer->Name),
    17     nr(pointer->nr)
     16    nr(pointer->nr),
     17    Name(pointer->Name)
    1818    {}
    1919
  • src/boundary.cpp

    rcbf01e r2561df  
    44 */
    55
     6#include "World.hpp"
    67#include "atom.hpp"
    78#include "bond.hpp"
     
    800801{
    801802        Info FunctionInfo(__func__);
    802   molecule *Filling = new molecule(filler->elemente);
     803  molecule *Filling = World::get()->createMolecule();
    803804  Vector CurrentPosition;
    804805  int N[NDIM];
     
    964965  bool freeLC = false;
    965966  bool status = false;
    966   CandidateForTesselation *baseline;
     967  CandidateForTesselation *baseline=0;
    967968  LineMap::iterator testline;
    968969  bool OneLoopWithoutSuccessFlag = true;  // marks whether we went once through all baselines without finding any without two triangles
  • src/builder.cpp

    rcbf01e r2561df  
    6666#include "linkedcell.hpp"
    6767#include "log.hpp"
    68 #include "memoryusageobserverunittest.hpp"
     68#include "memoryusageobserver.hpp"
    6969#include "molecule.hpp"
    7070#include "periodentafel.hpp"
     
    14331433     }
    14341434     if (mol == NULL) {
    1435        mol = new molecule(periode);
     1435       mol = World::get()->createMolecule();
    14361436       mol->ActiveFlag = true;
    14371437       if (ConfigFileName != NULL)
     
    16351635                Log() << Verbose(1) << "Filling Box with water molecules." << endl;
    16361636                // construct water molecule
    1637                 molecule *filler = new molecule(periode);
     1637                molecule *filler = World::get()->createMolecule();
    16381638                molecule *Filling = NULL;
    16391639                atom *second = NULL, *third = NULL;
     
    16651665                  molecules->insert(Filling);
    16661666                }
    1667                 delete(filler);
     1667                World::get()->destroyMolecule(filler);
    16681668                argptr+=6;
    16691669              }
     
    22052205    if(World::get()->numMolecules() == 0){
    22062206        mol = World::get()->createMolecule();
     2207        World::get()->getMolecules()->insert(mol);
     2208        cout << "Molecule created" << endl;
    22072209        if(mol->cell_size[0] == 0.){
    22082210            Log() << Verbose(0) << "enter lower tridiagonal form of basis matrix" << endl << endl;
  • src/config.cpp

    rcbf01e r2561df  
    851851void config::Load(const char * const filename, const string &BondGraphFileName, const periodentafel * const periode, MoleculeListClass * const &MolList)
    852852{
    853   molecule *mol = new molecule(periode);
     853  molecule *mol = World::get()->createMolecule();
    854854  ifstream *file = new ifstream(filename);
    855855  if (file == NULL) {
     
    10891089void config::LoadOld(const char * const filename, const string &BondGraphFileName, const periodentafel * const periode, MoleculeListClass * const &MolList)
    10901090{
    1091   molecule *mol = new molecule(periode);
     1091  molecule *mol = World::get()->createMolecule();
    10921092  ifstream *file = new ifstream(filename);
    10931093  if (file == NULL) {
     
    17881788  char filename[MAXSTRINGSIZE];
    17891789  ofstream output;
    1790   molecule *mol = new molecule(periode);
     1790  molecule *mol = World::get()->createMolecule();
    17911791  mol->SetNameFromFilename(ConfigFileName);
    17921792
     
    18991899  }
    19001900
    1901   delete(mol);
     1901  World::get()->destroyMolecule(mol);
    19021902};
    19031903
  • src/datacreator.cpp

    rcbf01e r2561df  
    771771{
    772772  stringstream line(Force.Header[Force.MatrixCounter]);
    773   char *fillcolor[5] = {"black", "red", "blue", "green", "cyan"};
     773  const char *fillcolor[5] = {"black", "red", "blue", "green", "cyan"};
    774774  string token;
    775775
     
    803803{
    804804  stringstream line(Force.Header[Force.MatrixCounter]);
    805   char *fillcolor[5] = {"black", "red", "blue", "green", "cyan"};
     805  const char *fillcolor[5] = {"black", "red", "blue", "green", "cyan"};
    806806  string token;
    807807
  • src/defs.hpp

    rcbf01e r2561df  
    3232
    3333enum Shading { white, lightgray, darkgray, black };  //!< color in Breadth-First-Search analysis
     34
     35// some types that can stay abstract
     36typedef unsigned int moleculeId_t;
     37typedef unsigned int atomId_t;
    3438
    3539//enum CutCyclicBond { KeepBond,  SaturateBond }; //!< Saturation scheme either atom- or bondwise
  • src/element.cpp

    rcbf01e r2561df  
    1414/** Constructor of class element.
    1515 */
    16 element::element() {
    17   Z = -1;
    18   No = -1;
    19   previous = NULL;
    20   next = NULL;
    21   sort = NULL;
     16element::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{
    2228};
    2329
  • src/gslmatrix.cpp

    rcbf01e r2561df  
    178178        gsl_matrix_set(dest, j,i, gsl_matrix_get(matrix, i,j) );
    179179      }
    180     delete(matrix);
     180    gsl_matrix_free(matrix);
    181181    matrix = dest;
    182182    flip(rows, columns);
  • src/molecule.cpp

    rcbf01e r2561df  
    3434  first(new bond(start, end, 1, -1)), last(new bond(start, end, 1, -1)), MDSteps(0), AtomCount(0),
    3535  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)
    3840{
    3941  // init atom chain list
     
    5355};
    5456
     57molecule *NewMolecule(){
     58  return new molecule(World::get()->getPeriode());
     59}
     60
    5561/** Destructor of class molecule.
    5662 * Initialises molecule list with correctly referenced start and end, and sets molecule::last_atom to zero.
     
    6672
    6773
     74void DeleteMolecule(molecule *mol){
     75  delete mol;
     76}
     77
    6878// getter and setter
    6979const std::string molecule::getName(){
     
    7484  OBSERVE;
    7585  strncpy(name,_name.c_str(),MAXSTRINGSIZE);
     86}
     87
     88moleculeId_t molecule::getId(){
     89  return id;
     90}
     91
     92void molecule::setId(moleculeId_t _id){
     93  id =_id;
    7694}
    7795
  • src/molecule.hpp

    rcbf01e r2561df  
    2929#include <string>
    3030
     31#include "defs.hpp"
    3132#include "graph.hpp"
    3233#include "stackclass.hpp"
     
    8586 */
    8687class molecule : public PointCloud , public Observable {
     88  friend molecule *NewMolecule();
     89  friend void DeleteMolecule(molecule *);
    8790  public:
    8891    double cell_size[6];//!< cell size
     
    108111  private:
    109112    Cacheable<string> formula;
     113    moleculeId_t id;
     114  protected:
     115    molecule(const periodentafel * const teil);
     116    virtual ~molecule();
     117
    110118
    111119public:
    112   molecule(const periodentafel * const teil);
    113   virtual ~molecule();
    114 
    115120  //getter and setter
    116121  const std::string getName();
     122  moleculeId_t getId();
     123  void setId(moleculeId_t);
    117124  void setName(const std::string);
    118125  const std::string getFormula();
    119126  std::string calcFormula();
     127
    120128
    121129  // re-definition of virtual functions from PointCloud
     
    321329};
    322330
     331molecule *NewMolecule();
     332void DeleteMolecule(molecule* mol);
     333
    323334#include "molecule_template.hpp"
    324335
     
    330341    int MaxIndex;
    331342
    332   MoleculeListClass();
     343  MoleculeListClass(World *world);
    333344  ~MoleculeListClass();
    334345
     
    339350  bool OutputConfigForListOfFragments(config *configuration, int *SortIndex);
    340351  int NumberOfActiveMolecules();
    341   void Enumerate(ofstream *out);
     352  void Enumerate(ostream *out);
    342353  void Output(ofstream *out);
    343354  void DissectMoleculeIntoConnectedSubgraphs(const periodentafel * const periode, config * const configuration);
     
    363374
    364375  private:
     376  World *world; //!< The world this List belongs to. Needed to avoid deadlocks in the destructor
    365377};
    366378
  • src/molecule_dynamics.cpp

    rcbf01e r2561df  
    66 */
    77
     8#include "World.hpp"
    89#include "atom.hpp"
    910#include "config.hpp"
     
    162163double molecule::ConstrainedPotential(struct EvaluatePotential &Params)
    163164{
    164   double tmp, result;
    165 
     165  double tmp = 0.;
     166  double result = 0.;
    166167  // go through every atom
    167168  atom *Runner = NULL;
     
    485486  bool status = true;
    486487  int MaxSteps = configuration.MaxOuterStep;
    487   MoleculeListClass *MoleculePerStep = new MoleculeListClass();
     488  MoleculeListClass *MoleculePerStep = new MoleculeListClass(World::get());
    488489  // Get the Permutation Map by MinimiseConstrainedPotential
    489490  atom **PermutationMap = NULL;
     
    505506  Log() << Verbose(1) << "Filling intermediate " << MaxSteps << " steps with MDSteps of " << MDSteps << "." << endl;
    506507  for (int step = 0; step <= MaxSteps; step++) {
    507     mol = new molecule(elemente);
     508    mol = World::get()->createMolecule();
    508509    MoleculePerStep->insert(mol);
    509510    Walker = start;
  • src/molecule_fragmentation.cpp

    rcbf01e r2561df  
    88#include <cstring>
    99
     10#include "World.hpp"
    1011#include "atom.hpp"
    1112#include "bond.hpp"
     
    675676  //if (FragmentationToDo) {    // we should always store the fragments again as coordination might have changed slightly without changing bond structure
    676677  // allocate memory for the pointer array and transmorph graphs into full molecular fragments
    677   BondFragments = new MoleculeListClass();
     678  BondFragments = new MoleculeListClass(World::get());
    678679  int k=0;
    679680  for(Graph::iterator runner = TotalGraph.begin(); runner != TotalGraph.end(); runner++) {
     
    926927{
    927928  atom **SonList = Calloc<atom*>(AtomCount, "molecule::StoreFragmentFromStack: **SonList");
    928   molecule *Leaf = new molecule(elemente);
     929  molecule *Leaf = World::get()->createMolecule();
    929930
    930931//  Log() << Verbose(1) << "Begin of StoreFragmentFromKeyset." << endl;
  • src/moleculelist.cpp

    rcbf01e r2561df  
    77#include <cstring>
    88
     9#include "World.hpp"
    910#include "atom.hpp"
    1011#include "bond.hpp"
     
    2425/** Constructor for MoleculeListClass.
    2526 */
    26 MoleculeListClass::MoleculeListClass()
     27MoleculeListClass::MoleculeListClass(World *_world) :
     28  world(_world)
    2729{
    2830  // empty lists
     
    3840  for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) {
    3941    Log() << Verbose(4) << "ListOfMolecules: Freeing " << *ListRunner << "." << endl;
    40     delete (*ListRunner);
     42    world->destroyMolecule(*ListRunner);
    4143  }
    4244  Log() << Verbose(4) << "Freeing ListOfMolecules." << endl;
     
    137139 * \param *out output stream
    138140 */
    139 void MoleculeListClass::Enumerate(ofstream *out)
     141void MoleculeListClass::Enumerate(ostream *out)
    140142{
    141143  element* Elemental = NULL;
     
    213215  // remove src
    214216  ListOfMolecules.remove(srcmol);
    215   delete(srcmol);
     217  World::get()->destroyMolecule(srcmol);
    216218  return true;
    217219};
     
    748750void MoleculeListClass::DissectMoleculeIntoConnectedSubgraphs(const periodentafel * const periode, config * const configuration)
    749751{
    750   molecule *mol = new molecule(periode);
     752  molecule *mol = World::get()->createMolecule();
    751753  atom *Walker = NULL;
    752754  atom *Advancer = NULL;
     
    773775    }
    774776    // remove the molecule
    775     delete(*MolRunner);
     777    World::get()->destroyMolecule(*MolRunner);
    776778    ListOfMolecules.erase(MolRunner);
    777779  }
     
    795797  molecule **molecules = Malloc<molecule *>(MolCount, "config::Load() - **molecules");
    796798  for (int i=0;i<MolCount;i++) {
    797     molecules[i] = (molecule*) new molecule(mol->elemente);
     799    molecules[i] = World::get()->createMolecule();
    798800    molecules[i]->ActiveFlag = true;
    799801    strncpy(molecules[i]->name, mol->name, MAXSTRINGSIZE);
     
    893895  OBSERVE;
    894896  molecule *mol = NULL;
    895   mol = new molecule(periode);
     897  mol = World::get()->createMolecule();
    896898  insert(mol);
    897899};
     
    902904  char filename[MAXSTRINGSIZE];
    903905  Log() << Verbose(0) << "Format should be XYZ with: ShorthandOfElement\tX\tY\tZ" << endl;
    904   mol = new molecule(periode);
     906  mol = World::get()->createMolecule();
    905907  do {
    906908    Log() << Verbose(0) << "Enter file name: ";
     
    960962      mol = *ListRunner;
    961963      ListOfMolecules.erase(ListRunner);
    962       delete(mol);
     964      World::get()->destroyMolecule(mol);
    963965      break;
    964966    }
     
    10071009  // remove the leaf itself
    10081010  if (Leaf != NULL) {
    1009     delete (Leaf);
     1011    World::get()->destroyMolecule(Leaf);
    10101012    Leaf = NULL;
    10111013  }
  • src/tesselation.cpp

    rcbf01e r2561df  
    46534653        }
    46544654  }
     4655  delete DegeneratedTriangles;
    46554656
    46564657  /// 3. Find connected endpoint candidates and put them into a polygon
  • src/tesselationhelpers.cpp

    rcbf01e r2561df  
    2727  int signum;
    2828  gsl_permutation *p = gsl_permutation_alloc(A->size1);
    29   gsl_matrix *tmpA;
     29  gsl_matrix *tmpA=0;
    3030
    3131  if (inPlace)
  • src/unittests/ActOnAllUnitTest.cpp

    rcbf01e r2561df  
    1616#include "memoryallocator.hpp"
    1717#include "vector.hpp"
     18
     19#ifdef HAVE_TESTRUNNER
     20#include "UnitTestMain.hpp"
     21#endif /*HAVE_TESTRUNNER*/
    1822
    1923/********************************************** Test classes **************************************/
     
    4044{
    4145  VL.EmptyList();
     46  // Ref was copy constructed, hence has to be cleaned, too!
     47  Ref.EmptyList();
     48  MemoryUsageObserver::purgeInstance();
    4249};
    4350
     
    8895  VL.ActOnAll( (void (Vector::*)(const double ** const)) &Vector::Scale, (const double ** const)&inverses );
    8996  CPPUNIT_ASSERT_EQUAL( VL == Ref , true );
     97  Free(factors);
     98  Free(inverses);
    9099};
    91100
     
    108117  }
    109118};
    110 
    111 
    112 /********************************************** Main routine **************************************/
    113 
    114 int main(int argc, char **argv)
    115 {
    116   // Get the top level suite from the registry
    117   CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
    118 
    119   // Adds the test to the list of test to run
    120   CppUnit::TextUi::TestRunner runner;
    121   runner.addTest( suite );
    122 
    123   // Change the default outputter to a compiler error format outputter
    124   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  
    1313#include "Actions/Action.hpp"
    1414#include "Actions/ActionSequence.hpp"
     15
     16#ifdef HAVE_TESTRUNNER
     17#include "UnitTestMain.hpp"
     18#endif /*HAVE_TESTRUNNER*/
     19
     20/********************************************** Test classes **************************************/
    1521
    1622// Registers the fixture into the 'registry'
     
    169175  CPPUNIT_ASSERT_EQUAL(false,shouldNotCall2->wasCalled());
    170176
     177  delete sequence;
    171178}
    172179
     
    190197  CPPUNIT_ASSERT_EQUAL(false,shouldNotCall2->wasCalled());
    191198
    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  
    2525#include "periodentafel.hpp"
    2626#include "tesselation.hpp"
     27#include "World.hpp"
     28
     29#ifdef HAVE_TESTRUNNER
     30#include "UnitTestMain.hpp"
     31#endif /*HAVE_TESTRUNNER*/
    2732
    2833/********************************************** Test classes **************************************/
     
    5257
    5358  // construct periodentafel
    54   tafel = new periodentafel;
     59  tafel = World::get()->getPeriode();
    5560  tafel->AddElement(hydrogen);
    5661
    5762  // construct molecule (tetraeder of hydrogens)
    58   TestMolecule = new molecule(tafel);
     63  TestMolecule = World::get()->createMolecule();
    5964  Walker = World::get()->createAtom();
    6065  Walker->type = hydrogen;
     
    7782  CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 );
    7883
    79   TestList = new MoleculeListClass;
     84  TestList = World::get()->getMolecules();
    8085  TestMolecule->ActiveFlag = true;
    8186  TestList->insert(TestMolecule);
     
    98103    delete(binmap);
    99104
    100   // remove
    101   delete(TestList);
    102   // note that all the atoms are cleaned by TestMolecule
    103105  delete(point);
    104   delete(tafel);
    105   // note that element is cleaned by periodentafel
     106  World::destroy();
     107  MemoryUsageObserver::purgeInstance();
     108  logger::purgeInstance();
    106109};
    107110
     
    141144
    142145};
    143 
    144 /********************************************** Main routine **************************************/
    145 
    146 int main(int argc, char **argv)
    147 {
    148   // Get the top level suite from the registry
    149   CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
    150 
    151   // Adds the test to the list of test to run
    152   CppUnit::TextUi::TestRunner runner;
    153   runner.addTest( suite );
    154 
    155   // Change the default outputter to a compiler error format outputter
    156   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  
    2525#include "periodentafel.hpp"
    2626#include "tesselation.hpp"
     27#include "World.hpp"
     28
     29#ifdef HAVE_TESTRUNNER
     30#include "UnitTestMain.hpp"
     31#endif /*HAVE_TESTRUNNER*/
    2732
    2833/********************************************** Test classes **************************************/
     
    5661
    5762  // construct periodentafel
    58   tafel = new periodentafel;
     63  tafel = World::get()->getPeriode();
    5964  tafel->AddElement(hydrogen);
    6065  tafel->AddElement(carbon);
    6166
    6267  // construct molecule (tetraeder of hydrogens) base
    63   TestMolecule = new molecule(tafel);
     68  TestMolecule = World::get()->createMolecule();
    6469  Walker = World::get()->createAtom();
    6570  Walker->type = hydrogen;
     
    8287  CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 );
    8388
    84   TestList = new MoleculeListClass;
     89  TestList = World::get()->getMolecules();
    8590  TestMolecule->ActiveFlag = true;
    8691  TestList->insert(TestMolecule);
     
    127132    delete(binmap);
    128133
    129   // remove
    130   delete(TestList);
    131134  delete(Surface);
    132135  // note that all the atoms are cleaned by TestMolecule
    133136  delete(LC);
    134   delete(tafel);
    135   // note that element is cleaned by periodentafel
     137  World::destroy();
     138  MemoryUsageObserver::purgeInstance();
     139  logger::purgeInstance();
    136140};
    137141
     
    212216
    213217};
    214 
    215 /********************************************** Main routine **************************************/
    216 
    217 int main(int argc, char **argv)
    218 {
    219   // Get the top level suite from the registry
    220   CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
    221 
    222   // Adds the test to the list of test to run
    223   CppUnit::TextUi::TestRunner runner;
    224   runner.addTest( suite );
    225 
    226   // Change the default outputter to a compiler error format outputter
    227   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  
    2525#include "periodentafel.hpp"
    2626#include "tesselation.hpp"
     27#include "World.hpp"
     28
     29#ifdef HAVE_TESTRUNNER
     30#include "UnitTestMain.hpp"
     31#endif /*HAVE_TESTRUNNER*/
    2732
    2833/********************************************** Test classes **************************************/
     
    5156
    5257  // construct periodentafel
    53   tafel = new periodentafel;
     58  tafel = World::get()->getPeriode();
    5459  tafel->AddElement(hydrogen);
    5560
    5661  // construct molecule (tetraeder of hydrogens)
    57   TestMolecule = new molecule(tafel);
     62  TestMolecule = World::get()->createMolecule();
    5863  Walker = World::get()->createAtom();
    5964  Walker->type = hydrogen;
     
    7681  CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 );
    7782
    78   TestList = new MoleculeListClass;
     83  TestList = World::get()->getMolecules();
    7984  TestMolecule->ActiveFlag = true;
    8085  TestList->insert(TestMolecule);
     
    9499    delete(binmap);
    95100
    96   // remove
    97   delete(TestList);
    98101  // 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();
    101106};
    102107
     
    133138  CPPUNIT_ASSERT_EQUAL( 6, tester->second );
    134139};
    135 
    136 /********************************************** Main routine **************************************/
    137 
    138 int main(int argc, char **argv)
    139 {
    140   // Get the top level suite from the registry
    141   CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
    142 
    143   // Adds the test to the list of test to run
    144   CppUnit::TextUi::TestRunner runner;
    145   runner.addTest( suite );
    146 
    147   // Change the default outputter to a compiler error format outputter
    148   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  
    1515
    1616#include "Patterns/Cacheable.hpp"
     17
     18#ifdef HAVE_TESTRUNNER
     19#include "UnitTestMain.hpp"
     20#endif /*HAVE_TESTRUNNER*/
     21
     22/********************************************** Test classes **************************************/
    1723
    1824// Registers the fixture into the 'registry'
     
    7783  CPPUNIT_ASSERT_EQUAL( true, numbers->hasRecalced);
    7884}
    79 
    80 
    81 
    82 /********************************************** Main routine **************************************/
    83 
    84 int main(int argc, char **argv)
    85 {
    86   // Get the top level suite from the registry
    87   CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
    88 
    89   // Adds the test to the list of test to run
    90   CppUnit::TextUi::TestRunner runner;
    91   runner.addTest( suite );
    92 
    93   // Change the default outputter to a compiler error format outputter
    94   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  
    1919#include "atom.hpp"
    2020
     21#ifdef HAVE_TESTRUNNER
     22#include "UnitTestMain.hpp"
     23#endif /*HAVE_TESTRUNNER*/
     24
     25/********************************************** Test classes **************************************/
    2126// Registers the fixture into the 'registry'
    2227CPPUNIT_TEST_SUITE_REGISTRATION( DescriptorUnittest );
     
    152157  }
    153158}
    154 
    155 /********************************************** Main routine **************************************/
    156 
    157 int main(int argc, char **argv)
    158 {
    159   // Get the top level suite from the registry
    160   CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
    161 
    162   // Adds the test to the list of test to run
    163   CppUnit::TextUi::TestRunner runner;
    164   runner.addTest( suite );
    165 
    166   // Change the default outputter to a compiler error format outputter
    167   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  
    3737 
    3838check_PROGRAMS = $(TESTS)
    39 noinst_PROGRAMS = $(TESTS)
     39noinst_PROGRAMS = $(TESTS) TestRunner
    4040
    4141GSLLIBS = ../libgslwrapper.a
    4242ALLLIBS = ../libmolecuilder.a ${GSLLIBS} $(BOOST_LIB) ${BOOST_THREAD_LIB}
    4343
    44 ActOnAllUnitTest_SOURCES = ../test/ActOnAllTest.hpp ActOnAllUnitTest.cpp ActOnAllUnitTest.hpp
     44TESTSOURCES = \
     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
     72TESTHEADERS = \
     73  analysis_correlation.hpp
     74
     75ActOnAllUnitTest_SOURCES = UnitTestMain.cpp ../test/ActOnAllTest.hpp ActOnAllUnitTest.cpp ActOnAllUnitTest.hpp
    4576ActOnAllUnitTest_LDADD = ${ALLLIBS}
    4677
    47 AnalysisBondsUnitTests_SOURCES = analysisbondsunittest.cpp analysisbondsunittest.hpp
     78AnalysisBondsUnitTests_SOURCES = UnitTestMain.cpp analysisbondsunittest.cpp analysisbondsunittest.hpp
    4879AnalysisBondsUnitTests_LDADD = ${ALLLIBS}
    4980
    50 AnalysisCorrelationToPointUnitTest_SOURCES = analysis_correlation.hpp AnalysisCorrelationToPointUnitTest.cpp AnalysisCorrelationToPointUnitTest.hpp
     81AnalysisCorrelationToPointUnitTest_SOURCES = UnitTestMain.cpp analysis_correlation.hpp AnalysisCorrelationToPointUnitTest.cpp AnalysisCorrelationToPointUnitTest.hpp
    5182AnalysisCorrelationToPointUnitTest_LDADD = ${ALLLIBS}
    5283
    53 AnalysisCorrelationToSurfaceUnitTest_SOURCES = analysis_correlation.hpp AnalysisCorrelationToSurfaceUnitTest.cpp AnalysisCorrelationToSurfaceUnitTest.hpp
     84AnalysisCorrelationToSurfaceUnitTest_SOURCES = UnitTestMain.cpp analysis_correlation.hpp AnalysisCorrelationToSurfaceUnitTest.cpp AnalysisCorrelationToSurfaceUnitTest.hpp
    5485AnalysisCorrelationToSurfaceUnitTest_LDADD = ${ALLLIBS}
    5586
    56 AnalysisPairCorrelationUnitTest_SOURCES = analysis_correlation.hpp AnalysisPairCorrelationUnitTest.cpp AnalysisPairCorrelationUnitTest.hpp
     87AnalysisPairCorrelationUnitTest_SOURCES = UnitTestMain.cpp analysis_correlation.hpp AnalysisPairCorrelationUnitTest.cpp AnalysisPairCorrelationUnitTest.hpp
    5788AnalysisPairCorrelationUnitTest_LDADD = ${ALLLIBS}
    5889
    59 BondGraphUnitTest_SOURCES = bondgraphunittest.cpp bondgraphunittest.hpp
     90BondGraphUnitTest_SOURCES = UnitTestMain.cpp bondgraphunittest.cpp bondgraphunittest.hpp
    6091BondGraphUnitTest_LDADD = ${ALLLIBS}
    6192
    62 GSLMatrixSymmetricUnitTest_SOURCES = gslmatrixsymmetricunittest.cpp gslmatrixsymmetricunittest.hpp
     93GSLMatrixSymmetricUnitTest_SOURCES = UnitTestMain.cpp gslmatrixsymmetricunittest.cpp gslmatrixsymmetricunittest.hpp
    6394GSLMatrixSymmetricUnitTest_LDADD = ${GSLLIBS}
    6495
    65 GSLMatrixUnitTest_SOURCES = gslmatrixunittest.cpp gslmatrixunittest.hpp
     96GSLMatrixUnitTest_SOURCES = UnitTestMain.cpp gslmatrixunittest.cpp gslmatrixunittest.hpp
    6697GSLMatrixUnitTest_LDADD = ${GSLLIBS}
    6798
    68 GSLVectorUnitTest_SOURCES = gslvectorunittest.cpp gslvectorunittest.hpp
     99GSLVectorUnitTest_SOURCES = UnitTestMain.cpp gslvectorunittest.cpp gslvectorunittest.hpp
    69100GSLVectorUnitTest_LDADD = ${GSLLIBS}
    70101
    71 InfoUnitTest_SOURCES = infounittest.cpp infounittest.hpp
     102InfoUnitTest_SOURCES = UnitTestMain.cpp infounittest.cpp infounittest.hpp
    72103InfoUnitTest_LDADD = ${ALLLIBS}
    73104
    74 LinearSystemOfEquationsUnitTest_SOURCES = linearsystemofequationsunittest.cpp linearsystemofequationsunittest.hpp
     105LinearSystemOfEquationsUnitTest_SOURCES = UnitTestMain.cpp linearsystemofequationsunittest.cpp linearsystemofequationsunittest.hpp
    75106LinearSystemOfEquationsUnitTest_LDADD = ${ALLLIBS}
    76107
    77 ListOfBondsUnitTest_SOURCES = listofbondsunittest.cpp listofbondsunittest.hpp
     108ListOfBondsUnitTest_SOURCES = UnitTestMain.cpp listofbondsunittest.cpp listofbondsunittest.hpp
    78109ListOfBondsUnitTest_LDADD = ${ALLLIBS}
    79110
    80 LogUnitTest_SOURCES = logunittest.cpp logunittest.hpp
     111LogUnitTest_SOURCES = UnitTestMain.cpp logunittest.cpp logunittest.hpp
    81112LogUnitTest_LDADD = ${ALLLIBS}
    82113
    83 MemoryAllocatorUnitTest_SOURCES = memoryallocatorunittest.cpp memoryallocatorunittest.hpp
     114MemoryAllocatorUnitTest_SOURCES = UnitTestMain.cpp memoryallocatorunittest.cpp memoryallocatorunittest.hpp
    84115MemoryAllocatorUnitTest_LDADD = ${ALLLIBS}
    85116
    86 MemoryUsageObserverUnitTest_SOURCES = memoryusageobserverunittest.cpp memoryusageobserverunittest.hpp
     117MemoryUsageObserverUnitTest_SOURCES = UnitTestMain.cpp memoryusageobserverunittest.cpp memoryusageobserverunittest.hpp
    87118MemoryUsageObserverUnitTest_LDADD = ${ALLLIBS}
    88119
    89 StackClassUnitTest_SOURCES = stackclassunittest.cpp stackclassunittest.hpp
     120StackClassUnitTest_SOURCES = UnitTestMain.cpp stackclassunittest.cpp stackclassunittest.hpp
    90121StackClassUnitTest_LDADD = ${ALLLIBS}
    91122
    92 TesselationUnitTest_SOURCES = tesselationunittest.cpp tesselationunittest.hpp
     123TesselationUnitTest_SOURCES = UnitTestMain.cpp tesselationunittest.cpp tesselationunittest.hpp
    93124TesselationUnitTest_LDADD = ${ALLLIBS}
    94125
    95 Tesselation_BoundaryTriangleUnitTest_SOURCES = tesselation_boundarytriangleunittest.cpp tesselation_boundarytriangleunittest.hpp
     126Tesselation_BoundaryTriangleUnitTest_SOURCES = UnitTestMain.cpp tesselation_boundarytriangleunittest.cpp tesselation_boundarytriangleunittest.hpp
    96127Tesselation_BoundaryTriangleUnitTest_LDADD = ${ALLLIBS}
    97128
    98 Tesselation_InOutsideUnitTest_SOURCES = tesselation_insideoutsideunittest.cpp tesselation_insideoutsideunittest.hpp
     129Tesselation_InOutsideUnitTest_SOURCES = UnitTestMain.cpp tesselation_insideoutsideunittest.cpp tesselation_insideoutsideunittest.hpp
    99130Tesselation_InOutsideUnitTest_LDADD = ${ALLLIBS}
    100131
    101 VectorUnitTest_SOURCES = vectorunittest.cpp vectorunittest.hpp
     132VectorUnitTest_SOURCES = UnitTestMain.cpp vectorunittest.cpp vectorunittest.hpp
    102133VectorUnitTest_LDADD = ${ALLLIBS}
    103134
    104 ActionSequenceTest_SOURCES = ActionSequenceTest.cpp ActionSequenceTest.hpp
    105 ActionSequenceTest_LDADD = ${ALLLIBS} ../libmenu.a
     135ActionSequenceTest_SOURCES = UnitTestMain.cpp ../../../TestRunnerClient.hpp ActionSequenceTest.cpp ActionSequenceTest.hpp
     136ActionSequenceTest_LDADD = ${ALLLIBS}
    106137
    107 ObserverTest_SOURCES = ObserverTest.cpp ObserverTest.hpp
     138ObserverTest_SOURCES = UnitTestMain.cpp ObserverTest.cpp ObserverTest.hpp
    108139ObserverTest_LDADD = ${ALLLIBS}
    109140
    110 CacheableTest_SOURCES = CacheableTest.cpp CacheableTest.hpp
     141CacheableTest_SOURCES = UnitTestMain.cpp CacheableTest.cpp CacheableTest.hpp
    111142CacheableTest_LDADD = ${ALLLIBS}
    112143
    113 DescriptorUnittest_SOURCES = DescriptorUnittest.cpp DescriptorUnittest.hpp
     144DescriptorUnittest_SOURCES = UnitTestMain.cpp DescriptorUnittest.cpp DescriptorUnittest.hpp
    114145DescriptorUnittest_LDADD = ${ALLLIBS}
    115146
    116 manipulateAtomsTest_SOURCES = manipulateAtomsTest.cpp manipulateAtomsTest.hpp
     147manipulateAtomsTest_SOURCES = UnitTestMain.cpp manipulateAtomsTest.cpp manipulateAtomsTest.hpp
    117148manipulateAtomsTest_LDADD = ${ALLLIBS}
    118149
    119 atomsCalculationTest_SOURCES = atomsCalculationTest.cpp atomsCalculationTest.hpp
     150atomsCalculationTest_SOURCES = UnitTestMain.cpp atomsCalculationTest.cpp atomsCalculationTest.hpp
    120151atomsCalculationTest_LDADD = ${ALLLIBS}
     152
     153TestRunner_SOURCES = TestRunnerMain.cpp $(TESTSOURCES) $(TESTHEADERS)
     154TestRunner_LDADD = ${ALLLIBS}
    121155
    122156#AUTOMAKE_OPTIONS = parallel-tests
  • src/unittests/ObserverTest.cpp

    rcbf01e r2561df  
    1717
    1818using namespace std;
     19
     20#ifdef HAVE_TESTRUNNER
     21#include "UnitTestMain.hpp"
     22#endif /*HAVE_TESTRUNNER*/
    1923
    2024// Registers the fixture into the 'registry'
     
    4044  void changeMethod() {
    4145    OBSERVE;
    42     int i;
     46    int i = 0;
    4347    i++;
    4448  }
     
    4953  void changeMethod1() {
    5054    OBSERVE;
    51     int i;
     55    int i = 0;
    5256    i++;
    5357  }
     
    5559  void changeMethod2() {
    5660    OBSERVE;
    57     int i;
     61    int i = 0;
    5862    i++;
    5963    changeMethod1();
     
    7276  void changeMethod() {
    7377    OBSERVE;
    74     int i;
     78    int i = 0;
    7579    i++;
    7680    subObservable->changeMethod();
     
    110114  simpleObservable1->signOn(observer2);
    111115  simpleObservable1->signOn(observer3);
     116
    112117  simpleObservable2->signOn(observer2);
    113118  simpleObservable2->signOn(observer4);
     
    181186  CPPUNIT_ASSERT(true);
    182187}
    183 
    184 /********************************************** Main routine **************************************/
    185 
    186 int main(int argc, char **argv)
    187 {
    188   // Get the top level suite from the registry
    189   CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
    190 
    191   // Adds the test to the list of test to run
    192   CppUnit::TextUi::TestRunner runner;
    193   runner.addTest( suite );
    194 
    195   // Change the default outputter to a compiler error format outputter
    196   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  
    2525#include "molecule.hpp"
    2626#include "periodentafel.hpp"
     27
     28#ifdef HAVE_TESTRUNNER
     29#include "UnitTestMain.hpp"
     30#endif /*HAVE_TESTRUNNER*/
    2731
    2832/********************************************** Test classes **************************************/
     
    5761
    5862  // construct periodentafel
    59   tafel = new periodentafel;
     63  tafel = World::get()->getPeriode();
    6064  tafel->AddElement(hydrogen);
    6165  tafel->AddElement(carbon);
    6266
    6367  // construct molecule (tetraeder of hydrogens)
    64   TestMolecule = new molecule(tafel);
     68  TestMolecule = World::get()->createMolecule();
    6569  Walker = World::get()->createAtom();
    6670  Walker->type = hydrogen;
     
    113117
    114118  // remove molecule
    115   delete(TestMolecule);
     119  World::get()->destroyMolecule(TestMolecule);
    116120  // note that all the atoms are cleaned by TestMolecule
    117   delete(tafel);
    118   // note that element is cleaned by periodentafel
     121  World::destroy();
    119122};
    120123
     
    164167  CPPUNIT_ASSERT_EQUAL( 0. , Max );
    165168};
    166 
    167 
    168 /********************************************** Main routine **************************************/
    169 
    170 int main(int argc, char **argv)
    171 {
    172   // Get the top level suite from the registry
    173   CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
    174 
    175   // Adds the test to the list of test to run
    176   CppUnit::TextUi::TestRunner runner;
    177   runner.addTest( suite );
    178 
    179   // Change the default outputter to a compiler error format outputter
    180   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  
    6363
    6464// some helper functions
    65 bool hasAll(std::vector<int> ids,int min, int max, std::set<int> excluded = std::set<int>()){
     65static bool hasAll(std::vector<int> ids,int min, int max, std::set<int> excluded = std::set<int>()){
    6666  for(int i=min;i<max;++i){
    6767    if(!excluded.count(i)){
     
    8080}
    8181
    82 bool hasNoDuplicates(std::vector<int> ids){
     82static bool hasNoDuplicates(std::vector<int> ids){
    8383  std::set<int> found;
    8484  std::vector<int>::iterator iter;
     
    9292}
    9393
    94 void operation(atom* _atom){
     94static void operation(atom* _atom){
    9595  AtomStub *atom = dynamic_cast<AtomStub*>(_atom);
    9696  assert(atom);
     
    116116  CPPUNIT_ASSERT_EQUAL((size_t)(ATOM_COUNT-1),allIds.size());
    117117}
    118 
    119 /********************************************** Main routine **************************************/
    120 
    121 int main(int argc, char **argv)
    122 {
    123   // Get the top level suite from the registry
    124   CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
    125 
    126   // Adds the test to the list of test to run
    127   CppUnit::TextUi::TestRunner runner;
    128   runner.addTest( suite );
    129 
    130   // Change the default outputter to a compiler error format outputter
    131   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  
    2424#include "periodentafel.hpp"
    2525#include "bondgraphunittest.hpp"
     26#include "World.hpp"
     27
     28#ifdef HAVE_TESTRUNNER
     29#include "UnitTestMain.hpp"
     30#endif /*HAVE_TESTRUNNER*/
    2631
    2732/********************************************** Test classes **************************************/
     
    5257
    5358  // construct periodentafel
    54   tafel = new periodentafel;
     59  tafel = World::get()->getPeriode();
    5560  tafel->AddElement(hydrogen);
    5661  tafel->AddElement(carbon);
    5762
    5863  // construct molecule (tetraeder of hydrogens)
    59   TestMolecule = new molecule(tafel);
     64  TestMolecule = World::get()->createMolecule();
    6065  Walker = World::get()->createAtom();
    6166  Walker->type = hydrogen;
     
    97102
    98103  // 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();
    103110};
    104111
     
    124131  CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) );
    125132};
    126 
    127 
    128 /********************************************** Main routine **************************************/
    129 
    130 int main(int argc, char **argv)
    131 {
    132   // Get the top level suite from the registry
    133   CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
    134 
    135   // Adds the test to the list of test to run
    136   CppUnit::TextUi::TestRunner runner;
    137   runner.addTest( suite );
    138 
    139   // Change the default outputter to a compiler error format outputter
    140   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  
    1313
    1414#include "gslmatrixsymmetricunittest.hpp"
     15
     16#ifdef HAVE_TESTRUNNER
     17#include "UnitTestMain.hpp"
     18#endif /*HAVE_TESTRUNNER*/
    1519
    1620/********************************************** Test classes **************************************/
     
    266270  CPPUNIT_ASSERT_EQUAL( -26.5, m->Determinant() );
    267271};
    268 
    269 /********************************************** Main routine **************************************/
    270 
    271 int main(int argc, char **argv)
    272 {
    273   // Get the top level suite from the registry
    274   CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
    275 
    276   // Adds the test to the list of test to run
    277   CppUnit::TextUi::TestRunner runner;
    278   runner.addTest( suite );
    279 
    280   // Change the default outputter to a compiler error format outputter
    281   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  
    1313
    1414#include "gslmatrixunittest.hpp"
     15
     16#ifdef HAVE_TESTRUNNER
     17#include "UnitTestMain.hpp"
     18#endif /*HAVE_TESTRUNNER*/
    1519
    1620/********************************************** Test classes **************************************/
     
    248252  CPPUNIT_ASSERT_EQUAL( false, m->IsPositiveDefinite() );
    249253};
    250 
    251 /********************************************** Main routine **************************************/
    252 
    253 int main(int argc, char **argv)
    254 {
    255   // Get the top level suite from the registry
    256   CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
    257 
    258   // Adds the test to the list of test to run
    259   CppUnit::TextUi::TestRunner runner;
    260   runner.addTest( suite );
    261 
    262   // Change the default outputter to a compiler error format outputter
    263   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  
    1313
    1414#include "gslvectorunittest.hpp"
     15
     16#ifdef HAVE_TESTRUNNER
     17#include "UnitTestMain.hpp"
     18#endif /*HAVE_TESTRUNNER*/
    1519
    1620/********************************************** Test classes **************************************/
     
    113117    CPPUNIT_ASSERT_EQUAL( (double)(3-j), v->Get(j) );
    114118};
    115 
    116 
    117 /********************************************** Main routine **************************************/
    118 
    119 int main(int argc, char **argv)
    120 {
    121   // Get the top level suite from the registry
    122   CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
    123 
    124   // Adds the test to the list of test to run
    125   CppUnit::TextUi::TestRunner runner;
    126   runner.addTest( suite );
    127 
    128   // Change the default outputter to a compiler error format outputter
    129   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  
    1717#include "info.hpp"
    1818#include "infounittest.hpp"
     19#include "log.hpp"
     20
     21#ifdef HAVE_TESTRUNNER
     22#include "UnitTestMain.hpp"
     23#endif /*HAVE_TESTRUNNER*/
    1924
    2025/********************************************** Test classes **************************************/
     
    3136void InfoTest::tearDown()
    3237{
     38  logger::purgeInstance();
    3339};
    3440
     
    4349  CPPUNIT_ASSERT_EQUAL( 1, test.verbosity );
    4450};
    45 
    46 
    47 /********************************************** Main routine **************************************/
    48 
    49 int main(int argc, char **argv)
    50 {
    51   // Get the top level suite from the registry
    52   CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
    53 
    54   // Adds the test to the list of test to run
    55   CppUnit::TextUi::TestRunner runner;
    56   runner.addTest( suite );
    57 
    58   // Change the default outputter to a compiler error format outputter
    59   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  
    1515#include "linearsystemofequationsunittest.hpp"
    1616#include "vector.hpp"
     17
     18#ifdef HAVE_TESTRUNNER
     19#include "UnitTestMain.hpp"
     20#endif /*HAVE_TESTRUNNER*/
    1721
    1822/********************************************** Test classes **************************************/
     
    103107  delete[](array);
    104108};
    105 
    106 /********************************************** Main routine **************************************/
    107 
    108 int main(int argc, char **argv)
    109 {
    110   // Get the top level suite from the registry
    111   CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
    112 
    113   // Adds the test to the list of test to run
    114   CppUnit::TextUi::TestRunner runner;
    115   runner.addTest( suite );
    116 
    117   // Change the default outputter to a compiler error format outputter
    118   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  
    2222#include "molecule.hpp"
    2323#include "periodentafel.hpp"
     24#include "World.hpp"
     25
     26#ifdef HAVE_TESTRUNNER
     27#include "UnitTestMain.hpp"
     28#endif /*HAVE_TESTRUNNER*/
    2429
    2530/********************************************** Test classes **************************************/
     
    4651
    4752  // construct periodentafel
    48   tafel = new periodentafel;
     53  tafel = World::get()->getPeriode();
    4954  tafel->AddElement(hydrogen);
    5055
    5156  // construct molecule (tetraeder of hydrogens)
    52   TestMolecule = new molecule(tafel);
     57  TestMolecule = World::get()->createMolecule();
    5358  Walker = World::get()->createAtom();
    5459  Walker->type = hydrogen;
     
    7782{
    7883  // 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();
    8390};
    8491
     
    251258  CPPUNIT_ASSERT_EQUAL( TestMolecule->first->next, TestMolecule->last );
    252259};
    253 
    254 /********************************************** Main routine **************************************/
    255 
    256 int main(int argc, char **argv)
    257 {
    258   // Get the top level suite from the registry
    259   CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
    260 
    261   // Adds the test to the list of test to run
    262   CppUnit::TextUi::TestRunner runner;
    263   runner.addTest( suite );
    264 
    265   // Change the default outputter to a compiler error format outputter
    266   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  
    1515#include "verbose.hpp"
    1616
     17#ifdef HAVE_TESTRUNNER
     18#include "UnitTestMain.hpp"
     19#endif /*HAVE_TESTRUNNER*/
     20
    1721/********************************************** Test classes **************************************/
    1822
     
    2731void LogTest::tearDown()
    2832{
     33  logger::purgeInstance();
     34  errorLogger::purgeInstance();
    2935};
    3036
     
    4854  eLog() << Verbose(4) << "This should not be printed." << endl;
    4955};
    50 
    51 
    52 /********************************************** Main routine **************************************/
    53 
    54 int main(int argc, char **argv)
    55 {
    56   // Get the top level suite from the registry
    57   CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
    58 
    59   // Adds the test to the list of test to run
    60   CppUnit::TextUi::TestRunner runner;
    61   runner.addTest( suite );
    62 
    63   // Change the default outputter to a compiler error format outputter
    64   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  
    7878
    7979// some helper functions
    80 bool hasAll(std::vector<atom*> atoms,int min, int max, std::set<int> excluded = std::set<int>()){
     80static bool hasAll(std::vector<atom*> atoms,int min, int max, std::set<int> excluded = std::set<int>()){
    8181  for(int i=min;i<max;++i){
    8282    if(!excluded.count(i)){
     
    9595}
    9696
    97 bool hasNoDuplicates(std::vector<atom*> atoms){
     97static bool hasNoDuplicates(std::vector<atom*> atoms){
    9898  std::set<int> found;
    9999  std::vector<atom*>::iterator iter;
     
    107107}
    108108
    109 void operation(atom* _atom){
     109static void operation(atom* _atom){
    110110  AtomStub *atom = dynamic_cast<AtomStub*>(_atom);
    111111  assert(atom);
     
    153153  delete obs;
    154154}
    155 
    156 /********************************************** Main routine **************************************/
    157 
    158 int main(int argc, char **argv)
    159 {
    160   // Get the top level suite from the registry
    161   CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
    162 
    163   // Adds the test to the list of test to run
    164   CppUnit::TextUi::TestRunner runner;
    165   runner.addTest( suite );
    166 
    167   // Change the default outputter to a compiler error format outputter
    168   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  
    1313#include "memoryallocatorunittest.hpp"
    1414#include "helpers.hpp"
     15#include "log.hpp"
    1516#include "defs.hpp"
     17
     18#ifdef HAVE_TESTRUNNER
     19#include "UnitTestMain.hpp"
     20#endif /*HAVE_TESTRUNNER*/
    1621
    1722/********************************************** Test classes **************************************/
     
    2934{
    3035  MemoryUsageObserver::getInstance()->purgeInstance();
     36  logger::purgeInstance();
    3137};
    3238
     
    102108  Free(buffer2);
    103109};
    104 
    105 
    106 /********************************************** Main routine **************************************/
    107 
    108 int main(int argc, char **argv)
    109 {
    110   // Get the top level suite from the registry
    111   CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
    112 
    113   // Adds the test to the list of test to run
    114   CppUnit::TextUi::TestRunner runner;
    115   runner.addTest( suite );
    116 
    117   // Change the default outputter to a compiler error format outputter
    118   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  
    1414#include "memoryusageobserverunittest.hpp"
    1515
     16#ifdef HAVE_TESTRUNNER
     17#include "UnitTestMain.hpp"
     18#endif /*HAVE_TESTRUNNER*/
     19
    1620/********************************************** Test classes **************************************/
    1721// Registers the fixture into the 'registry'
     
    2731{
    2832  MemoryUsageObserver::purgeInstance();
     33  logger::purgeInstance();
     34  errorLogger::purgeInstance();
    2935};
    3036
     
    7076  MemoryUsageObserver::getInstance()->removeMemory(i);
    7177  CPPUNIT_ASSERT_EQUAL((size_t) 0, MemoryUsageObserver::getInstance()->getUsedMemorySize());
     78  Free(i);
    7279};
    7380
     
    8087  MemoryUsageObserver::getInstance()->removeMemory(i);
    8188  CPPUNIT_ASSERT_EQUAL((size_t) 0, MemoryUsageObserver::getInstance()->getUsedMemorySize());
     89  Free(i);
    8290};
    8391
     
    92100  MemoryUsageObserver::getInstance()->addMemory(j, sizeof(int));
    93101  CPPUNIT_ASSERT_EQUAL(2 * sizeof(int), MemoryUsageObserver::getInstance()->getUsedMemorySize());
     102  Free(i);
     103  Free(j);
    94104};
    95105
     
    103113  MemoryUsageObserver::getInstance()->addMemory(i, sizeof(int));
    104114  CPPUNIT_ASSERT_EQUAL(sizeof(int), MemoryUsageObserver::getInstance()->getUsedMemorySize());
     115  Free(i);
    105116};
    106117
     
    114125  MemoryUsageObserver::getInstance()->addMemory(i, sizeof(int));
    115126  CPPUNIT_ASSERT_EQUAL(2 * sizeof(int), MemoryUsageObserver::getInstance()->getMaximumUsedMemory());
     127  Free(i);
    116128};
    117129
     
    125137  MemoryUsageObserver::getInstance()->removeMemory(i);
    126138  CPPUNIT_ASSERT_EQUAL(sizeof(int), MemoryUsageObserver::getInstance()->getMaximumUsedMemory());
     139  Free(i);
    127140};
    128141
     
    135148  MemoryUsageObserver::getInstance()->addMemory(i, sizeof(int));
    136149  CPPUNIT_ASSERT_EQUAL(i, (int*) MemoryUsageObserver::getInstance()->getPointersToAllocatedMemory().begin()->first);
     150  Free(i);
    137151};
    138 
    139 
    140 /********************************************** Main routine **************************************/
    141 
    142 int main(int argc, char **argv)
    143 {
    144   // Get the top level suite from the registry
    145   CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
    146 
    147   // Adds the test to the list of test to run
    148   CppUnit::TextUi::TestRunner runner;
    149   runner.addTest( suite );
    150 
    151   // Change the default outputter to a compiler error format outputter
    152   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  
    1414#include "stackclassunittest.hpp"
    1515#include "log.hpp"
     16
     17#ifdef HAVE_TESTRUNNER
     18#include "UnitTestMain.hpp"
     19#endif /*HAVE_TESTRUNNER*/
    1620
    1721enum { testdimension=3 };
     
    3337  Stack->ClearStack();
    3438  delete(Stack);
     39  MemoryUsageObserver::purgeInstance();
     40  logger::purgeInstance();
    3541};
    3642
     
    6773  CPPUNIT_ASSERT_EQUAL(0, Stack->ItemCount());
    6874};
    69 
    70 
    71 /********************************************** Main routine **************************************/
    72 
    73 int main(int argc, char **argv)
    74 {
    75   // Get the top level suite from the registry
    76   CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
    77 
    78   // Adds the test to the list of test to run
    79   CppUnit::TextUi::TestRunner runner;
    80   runner.addTest( suite );
    81 
    82   // Change the default outputter to a compiler error format outputter
    83   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  
    1818#include "tesselation_boundarytriangleunittest.hpp"
    1919
     20#ifdef HAVE_TESTRUNNER
     21#include "UnitTestMain.hpp"
     22#endif /*HAVE_TESTRUNNER*/
     23
    2024#define SPHERERADIUS 2.
    2125
     
    3135
    3236  // 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] );
    5255
    5356  // create line
     
    6568{
    6669  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  }
    6775  MemoryUsageObserver::purgeInstance();
    6876  logger::purgeInstance();
     
    191199  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
    192200};
    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 };
  • src/unittests/tesselation_boundarytriangleunittest.hpp

    rcbf01e r2561df  
    3535      class BoundaryLineSet *lines[3];
    3636      class BoundaryPointSet *points[3];
     37      class TesselPoint *tesselpoints[3];
    3738      LinkedNodes Corners;
    3839};
  • src/unittests/tesselation_insideoutsideunittest.cpp

    rcbf01e r2561df  
    1717#include "tesselation.hpp"
    1818#include "tesselation_insideoutsideunittest.hpp"
     19
     20#ifdef HAVE_TESTRUNNER
     21#include "UnitTestMain.hpp"
     22#endif /*HAVE_TESTRUNNER*/
    1923
    2024#define SPHERERADIUS 2.
     
    161165      }
    162166};
    163 
    164 /********************************************** Main routine **************************************/
    165 
    166 int main(int argc, char **argv)
    167 {
    168   // Get the top level suite from the registry
    169   CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
    170 
    171   // Adds the test to the list of test to run
    172   CppUnit::TextUi::TestRunner runner;
    173   runner.addTest( suite );
    174 
    175   // Change the default outputter to a compiler error format outputter
    176   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  
    1818#include "tesselation.hpp"
    1919#include "tesselationunittest.hpp"
     20
     21#ifdef HAVE_TESTRUNNER
     22#include "UnitTestMain.hpp"
     23#endif /*HAVE_TESTRUNNER*/
    2024
    2125#define SPHERERADIUS 2.
     
    177181  }
    178182}
    179 
    180 /********************************************** Main routine **************************************/
    181 
    182 int main(int argc, char **argv)
    183 {
    184   // Get the top level suite from the registry
    185   CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
    186 
    187   // Adds the test to the list of test to run
    188   CppUnit::TextUi::TestRunner runner;
    189   runner.addTest( suite );
    190 
    191   // Change the default outputter to a compiler error format outputter
    192   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  
    1414
    1515#include "defs.hpp"
     16#include "log.hpp"
     17#include "memoryusageobserver.hpp"
    1618#include "vector.hpp"
    1719#include "vectorunittest.hpp"
     20
     21#ifdef HAVE_TESTRUNNER
     22#include "UnitTestMain.hpp"
     23#endif /*HAVE_TESTRUNNER*/
    1824
    1925/********************************************** Test classes **************************************/
     
    3541void VectorTest::tearDown()
    3642{
     43  MemoryUsageObserver::purgeInstance();
     44  logger::purgeInstance();
     45  errorLogger::purgeInstance();
    3746};
    3847
     
    290299}
    291300
    292 
    293 /********************************************** Main routine **************************************/
    294 
    295 int main(int argc, char **argv)
    296 {
    297   // Get the top level suite from the registry
    298   CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
    299 
    300   // Adds the test to the list of test to run
    301   CppUnit::TextUi::TestRunner runner;
    302   runner.addTest( suite );
    303 
    304   // Change the default outputter to a compiler error format outputter
    305   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  
    330330    return false;
    331331  }
     332  delete(M);
    332333  Log() << Verbose(1) << "INFO: Line1a = " << *Line1a << ", Line1b = " << *Line1b << ", Line2a = " << *Line2a << ", Line2b = " << *Line2b << "." << endl;
    333334
     
    585586 * \return lhs + a
    586587 */
    587 Vector& operator+=(Vector& a, const Vector& b)
     588const Vector& operator+=(Vector& a, const Vector& b)
    588589{
    589590  a.AddVector(&b);
     
    596597 * \return lhs - a
    597598 */
    598 Vector& operator-=(Vector& a, const Vector& b)
     599const Vector& operator-=(Vector& a, const Vector& b)
    599600{
    600601  a.SubtractVector(&b);
     
    607608 * \return lhs.x[i] * m
    608609 */
    609 Vector& operator*=(Vector& a, const double m)
     610const Vector& operator*=(Vector& a, const double m)
    610611{
    611612  a.Scale(m);
     
    618619 * \return a + b
    619620 */
    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;
     621Vector const operator+(const Vector& a, const Vector& b)
     622{
     623  Vector x(a);
     624  x.AddVector(&b);
     625  return x;
    626626};
    627627
     
    631631 * \return a - b
    632632 */
    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;
     633Vector const operator-(const Vector& a, const Vector& b)
     634{
     635  Vector x(a);
     636  x.SubtractVector(&b);
     637  return x;
    639638};
    640639
     
    644643 * \return m * a
    645644 */
    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;
     645Vector const operator*(const Vector& a, const double m)
     646{
     647  Vector x(a);
     648  x.Scale(m);
     649  return x;
    652650};
    653651
     
    657655 * \return m * a
    658656 */
    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;
     657Vector const operator*(const double m, const Vector& a )
     658{
     659  Vector x(a);
     660  x.Scale(m);
     661  return x;
    665662};
    666663
  • src/vector.hpp

    rcbf01e r2561df  
    8787ostream & operator << (ostream& ost, const Vector &m);
    8888bool 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);
     89const Vector& operator+=(Vector& a, const Vector& b);
     90const Vector& operator-=(Vector& a, const Vector& b);
     91const Vector& operator*=(Vector& a, const double m);
     92Vector const operator*(const Vector& a, const double m);
     93Vector const operator*(const double m, const Vector& a);
     94Vector const operator+(const Vector& a, const Vector& b);
     95Vector const operator-(const Vector& a, const Vector& b);
    9696
    9797
  • tests/Tesselations/defs.in

    rcbf01e r2561df  
    2626        if $testdir_exists; then :; else
    2727                mkdir $testdir
    28                 CLEANUP="rmdir $testdir; $CLEANUP"
     28                CLEANUP="rm -rf $testdir; $CLEANUP"
    2929        fi
    3030        cp  @srcdir@/$testdir/* $testdir/
Note: See TracChangeset for help on using the changeset viewer.