Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/molecule.cpp

    ra7aebd r833b15  
    4949#include "CodePatterns/enumeration.hpp"
    5050#include "CodePatterns/Log.hpp"
    51 #include "CodePatterns/Observer/Notification.hpp"
    5251#include "config.hpp"
    5352#include "Descriptors/AtomIdDescriptor.hpp"
     
    147146  OBSERVE;
    148147  if(atomIdPool.reserveId(newNr)){
    149     _lastchangedatom = target;
    150148    NOTIFY(AtomNrChanged);
    151149    if (oldNr != -1)  // -1 is reserved and indicates no number
     
    209207{
    210208  OBSERVE;
     209  NOTIFY(AtomRemoved);
    211210  const_iterator iter = loc;
    212211  ++iter;
    213212  atom * const _atom = const_cast<atom *>(*loc);
    214   {
    215     _lastchangedatom = _atom;
    216     NOTIFY(AtomRemoved);
    217   }
    218213  atomIds.erase( _atom->getId() );
    219214  {
     
    231226{
    232227  OBSERVE;
    233   {
    234     _lastchangedatom = key;
    235     NOTIFY(AtomRemoved);
    236   }
     228  NOTIFY(AtomRemoved);
    237229  const_iterator iter = find(key);
    238230  if (iter != end()){
     
    255247  OBSERVE;
    256248  NOTIFY(AtomInserted);
    257   _lastchangedatom = key;
    258249  std::pair<iterator,bool> res = atomIds.insert(key->getId());
    259250  if (res.second) { // push atom if went well
     
    646637/** Destroys all atoms inside this molecule.
    647638 */
    648 void removeAtomsinMolecule(molecule *&_mol)
     639void molecule::removeAtomsinMolecule()
    649640{
    650641  // remove each atom from world
    651   for(molecule::iterator AtomRunner = _mol->begin(); !_mol->empty(); AtomRunner = _mol->begin())
     642  for(iterator AtomRunner = begin(); !empty(); AtomRunner = begin())
    652643    World::getInstance().destroyAtom(*AtomRunner);
    653   // make sure that pointer os not usable
    654   _mol = NULL;
    655644};
    656645
     
    985974    for(const_iterator iter = begin(); iter != end(); ++iter)
    986975      center += (*iter)->getPosition();
    987     if (begin() != end())
    988       center *= 1./(double)size();
     976    center *= 1./(double)size();
    989977    for(const_iterator iter = begin(); iter != end(); ++iter) {
    990978      const Vector &position = (*iter)->getPosition();
     
    1007995}
    1008996
    1009 void molecule::update(Observable *publisher)
    1010 {
    1011   ASSERT(0, "molecule::update() - did not sign on for any general updates.");
    1012 }
    1013 
    1014 void molecule::recieveNotification(Observable *publisher, Notification_ptr notification)
    1015 {
    1016   const atom * const _atom = dynamic_cast<atom *>(publisher);
    1017   if ((_atom != NULL) && containsAtom(_atom)) {
    1018 #ifdef LOG_OBSERVER
    1019     observerLog().addMessage() << "++ Update of Observer "<< observerLog().getName(static_cast<Observer *>(this))
    1020           << " received notification from atom " << _atom->getId() << " for channel "
    1021           << notification->getChannelNo() << ".";
    1022 #endif
    1023     switch (notification->getChannelNo()) {
    1024       case AtomObservable::PositionChanged:
    1025       {
    1026         // emit others about one of our atoms moved
    1027         _lastchangedatom = const_cast<atom *>(_atom);
    1028         OBSERVE;
    1029         NOTIFY(AtomMoved);
    1030         break;
    1031       }
    1032       default:
    1033         ASSERT( 0, "molecule::recieveNotification() - we did not sign up for channel "
    1034             +toString(notification->getChannelNo()));
    1035         break;
    1036     }
    1037   }
    1038 }
    1039 
    1040 void molecule::subjectKilled(Observable *publisher)
    1041 {
    1042   // do nothing, atom does it all
    1043 }
    1044 
    1045 
    1046997// construct idpool
    1047998CONSTRUCT_IDPOOL(atomId_t, continuousId)
Note: See TracChangeset for help on using the changeset viewer.