Changeset d2d8f5


Ignore:
Timestamp:
Feb 5, 2010, 3:19:27 PM (16 years ago)
Author:
Tillmann Crueger <crueger@…>
Children:
86b917
Parents:
42918b
Message:

Made all atoms register themselves with the world upon creation

Location:
molecuilder/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/Makefile.am

    r42918b rd2d8f5  
    2727# deleted once everything is fully refactored
    2828LEGACYSOURCE = Legacy/oldmenu.cpp
    29 LEGACYHEADER = Legacy/oldmenu.hpp Legacy/WorldContent.hpp Legacy/WorldContent_impl.hpp
     29LEGACYHEADER = Legacy/oldmenu.hpp
    3030
    3131SOURCE = ${ANALYSISSOURCE} ${ATOMSOURCE} ${PATTERNSOURCE} ${UISOURCE} ${LEGACYSOURCE} bond.cpp bondgraph.cpp boundary.cpp config.cpp element.cpp ellipsoid.cpp errorlogger.cpp graph.cpp helpers.cpp info.cpp leastsquaremin.cpp linkedcell.cpp log.cpp logger.cpp memoryusageobserver.cpp moleculelist.cpp molecule.cpp molecule_dynamics.cpp molecule_fragmentation.cpp molecule_geometry.cpp molecule_graph.cpp molecule_pointcloud.cpp parser.cpp periodentafel.cpp tesselation.cpp tesselationhelpers.cpp vector.cpp verbose.cpp World.cpp
  • molecuilder/src/World.cpp

    r42918b rd2d8f5  
    88#include "World.hpp"
    99
    10 #include <iostream>
     10#include "atom.hpp"
     11
     12using namespace std;
    1113
    1214/******************************* getter and setter ************************/
     
    7375}
    7476
     77// some legacy stuff to let the World know about items created outside
     78void World::registerAtom(atom *theAtom){
     79  OBSERVE;
     80  atoms[theAtom->getId()] = theAtom;
     81}
    7582
    76 // methods for WorldContent CRTP mechanism
    77 void World::registerContent(atom *atom){
    78   std::cout << "############### some kind of Atom created ##################" << std::endl;
     83void World::unregisterAtom(atom *theAtom){
     84  OBSERVE;
     85  atoms.erase(theAtom->getId());
    7986}
  • molecuilder/src/World.hpp

    r42918b rd2d8f5  
    1010
    1111#include <boost/thread.hpp>
     12#include <map>
    1213
    1314#include "Patterns/Observer.hpp"
     
    2728private:
    2829  periodentafel *periode;
     30  std::map<int,atom*> atoms;
    2931
    3032
     
    5254
    5355  // functions used for the WorldContent template mechanism
    54   void registerContent(atom *theAtom);
     56  void registerAtom(atom *theAtom);
     57  void unregisterAtom(atom *theAtom);
    5558private:
    5659  MoleculeListClass *molecules;
  • molecuilder/src/atom.cpp

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

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

    r42918b rd2d8f5  
    3535  ostream & operator << (ostream &ost) const;
    3636
     37  int getId();
     38
    3739private:
    3840};
Note: See TracChangeset for help on using the changeset viewer.