Changes in src/molecule.cpp [a7aebd:833b15]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/molecule.cpp
ra7aebd r833b15 49 49 #include "CodePatterns/enumeration.hpp" 50 50 #include "CodePatterns/Log.hpp" 51 #include "CodePatterns/Observer/Notification.hpp"52 51 #include "config.hpp" 53 52 #include "Descriptors/AtomIdDescriptor.hpp" … … 147 146 OBSERVE; 148 147 if(atomIdPool.reserveId(newNr)){ 149 _lastchangedatom = target;150 148 NOTIFY(AtomNrChanged); 151 149 if (oldNr != -1) // -1 is reserved and indicates no number … … 209 207 { 210 208 OBSERVE; 209 NOTIFY(AtomRemoved); 211 210 const_iterator iter = loc; 212 211 ++iter; 213 212 atom * const _atom = const_cast<atom *>(*loc); 214 {215 _lastchangedatom = _atom;216 NOTIFY(AtomRemoved);217 }218 213 atomIds.erase( _atom->getId() ); 219 214 { … … 231 226 { 232 227 OBSERVE; 233 { 234 _lastchangedatom = key; 235 NOTIFY(AtomRemoved); 236 } 228 NOTIFY(AtomRemoved); 237 229 const_iterator iter = find(key); 238 230 if (iter != end()){ … … 255 247 OBSERVE; 256 248 NOTIFY(AtomInserted); 257 _lastchangedatom = key;258 249 std::pair<iterator,bool> res = atomIds.insert(key->getId()); 259 250 if (res.second) { // push atom if went well … … 646 637 /** Destroys all atoms inside this molecule. 647 638 */ 648 void removeAtomsinMolecule(molecule *&_mol)639 void molecule::removeAtomsinMolecule() 649 640 { 650 641 // 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()) 652 643 World::getInstance().destroyAtom(*AtomRunner); 653 // make sure that pointer os not usable654 _mol = NULL;655 644 }; 656 645 … … 985 974 for(const_iterator iter = begin(); iter != end(); ++iter) 986 975 center += (*iter)->getPosition(); 987 if (begin() != end()) 988 center *= 1./(double)size(); 976 center *= 1./(double)size(); 989 977 for(const_iterator iter = begin(); iter != end(); ++iter) { 990 978 const Vector &position = (*iter)->getPosition(); … … 1007 995 } 1008 996 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_OBSERVER1019 observerLog().addMessage() << "++ Update of Observer "<< observerLog().getName(static_cast<Observer *>(this))1020 << " received notification from atom " << _atom->getId() << " for channel "1021 << notification->getChannelNo() << ".";1022 #endif1023 switch (notification->getChannelNo()) {1024 case AtomObservable::PositionChanged:1025 {1026 // emit others about one of our atoms moved1027 _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 all1043 }1044 1045 1046 997 // construct idpool 1047 998 CONSTRUCT_IDPOOL(atomId_t, continuousId)
Note:
See TracChangeset
for help on using the changeset viewer.