Changeset 9ef76a
- Timestamp:
- Feb 19, 2010, 11:49:54 AM (16 years ago)
- Children:
- 01d28a
- Parents:
- 5d4edf
- Location:
- molecuilder/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/Actions/ManipulateAtomsProcess.cpp
r5d4edf r9ef76a 23 23 24 24 void ManipulateAtomsProcess::call(){ 25 World* world = World::get(); 25 World::get()->doManipulate(this); 26 } 27 28 void ManipulateAtomsProcess::undo(){ 29 30 } 31 32 bool ManipulateAtomsProcess::canUndo(){ 33 return false; 34 } 35 36 void ManipulateAtomsProcess::doManipulate(World *world){ 26 37 setMaxSteps(world->numAtoms()); 27 38 start(); … … 33 44 stop(); 34 45 } 35 36 void ManipulateAtomsProcess::undo(){37 38 }39 40 bool ManipulateAtomsProcess::canUndo(){41 return false;42 } -
molecuilder/src/Actions/ManipulateAtomsProcess.hpp
r5d4edf r9ef76a 21 21 virtual void undo(); 22 22 virtual bool canUndo(); 23 24 virtual void doManipulate(World *); 23 25 private: 24 26 AtomDescriptor descr; -
molecuilder/src/World.cpp
r5d4edf r9ef76a 37 37 return molecules_deprecated->ListOfMolecules.size(); 38 38 } 39 40 /******************** Methods to change World state *********************/ 39 41 40 42 molecule* World::createMolecule(){ … … 53 55 } 54 56 57 /********************* Internal Change methods for double Callback and Observer mechanism ********/ 58 59 void World::doManipulate(ManipulateAtomsProcess *proc){ 60 proc->signOn(this); 61 { 62 OBSERVE; 63 proc->doManipulate(this); 64 } 65 proc->signOff(this); 66 } 67 55 68 /******************************* Iterators ********************************/ 56 69 -
molecuilder/src/World.hpp
r5d4edf r9ef76a 80 80 AtomList::iterator atomEnd(); 81 81 82 /******* Internal manipulation routines for double callback and Observer mechanism ******/ 83 void doManipulate(ManipulateAtomsProcess *); 84 82 85 private: 83 86 periodentafel *periode; -
molecuilder/src/unittests/manipulateAtomsTest.cpp
r5d4edf r9ef76a 49 49 }; 50 50 51 class countObserver : public Observer{ 52 public: 53 countObserver() : 54 count(0) 55 {} 56 virtual ~countObserver(){} 57 58 void update(Observable *){ 59 count++; 60 } 61 62 void subjectKilled(Observable *) 63 {} 64 65 int count; 66 }; 51 67 52 68 // set up and tear down … … 131 147 } 132 148 149 void manipulateAtomsTest::testObserver(){ 150 countObserver *obs = new countObserver(); 151 World::get()->signOn(obs); 152 ManipulateAtomsProcess *proc = World::get()->manipulateAtoms(boost::bind(operation,_1),"FOO",AllAtoms() && !AtomById(ATOM_COUNT/2)); 153 proc->call(); 154 155 CPPUNIT_ASSERT_EQUAL(1,obs->count); 156 World::get()->signOff(obs); 157 delete obs; 158 } 159 133 160 /********************************************** Main routine **************************************/ 134 161 -
molecuilder/src/unittests/manipulateAtomsTest.hpp
r5d4edf r9ef76a 20 20 CPPUNIT_TEST ( testManipulateSimple ); 21 21 CPPUNIT_TEST ( testManipulateExcluded ); 22 CPPUNIT_TEST ( testObserver ); 22 23 CPPUNIT_TEST_SUITE_END(); 23 24 … … 28 29 void testManipulateSimple(); 29 30 void testManipulateExcluded(); 31 void testObserver(); 30 32 31 33 private:
Note:
See TracChangeset
for help on using the changeset viewer.