Changes in src/World.hpp [6e97e5:88d586]
- File:
-
- 1 edited
-
src/World.hpp (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/World.hpp
r6e97e5 r88d586 16 16 #include <boost/shared_ptr.hpp> 17 17 18 #include "types.hpp" 19 #include "Descriptors/SelectiveIterator.hpp" 18 #include "defs.hpp" 20 19 #include "Patterns/Observer.hpp" 21 20 #include "Patterns/Cacheable.hpp" 22 #include "Patterns/Singleton.hpp"23 24 21 25 22 // forward declarations … … 36 33 class AtomsCalculation; 37 34 38 39 40 class World : public Singleton<World>, public Observable 35 class World : public Observable 41 36 { 42 43 // Make access to constructor and destructor possible from inside the singleton44 friend class Singleton<World>;45 46 37 // necessary for coupling with descriptors 47 38 friend class AtomDescriptor_impl; … … 54 45 template<typename> friend class AtomsCalculation; 55 46 public: 56 57 // Types for Atom and Molecule structures58 47 typedef std::map<atomId_t,atom*> AtomSet; 59 48 typedef std::map<moleculeId_t,molecule*> MoleculeSet; … … 161 150 162 151 // Atoms 163 typedef SelectiveIterator<atom*,AtomSet,AtomDescriptor> AtomIterator; 152 153 class AtomIterator { 154 public: 155 AtomIterator(); 156 AtomIterator(AtomDescriptor, World*); 157 AtomIterator(const AtomIterator&); 158 AtomIterator& operator=(const AtomIterator&); 159 AtomIterator& operator++(); // prefix 160 AtomIterator operator++(int); // postfix with dummy parameter 161 bool operator==(const AtomIterator&); 162 bool operator==(const AtomSet::iterator&); 163 bool operator!=(const AtomIterator&); 164 bool operator!=(const AtomSet::iterator&); 165 atom* operator*(); 166 167 int getCount(); 168 protected: 169 void advanceState(); 170 AtomSet::iterator state; 171 boost::shared_ptr<AtomDescriptor_impl> descr; 172 int index; 173 174 World* world; 175 }; 164 176 165 177 /** … … 175 187 * used for internal purposes, like AtomProcesses and AtomCalculations. 176 188 */ 177 Atom Iterator atomEnd();189 AtomSet::iterator atomEnd(); 178 190 179 191 // Molecules 180 192 181 typedef SelectiveIterator<molecule*,MoleculeSet,MoleculeDescriptor> MoleculeIterator; 193 class MoleculeIterator { 194 public: 195 MoleculeIterator(); 196 MoleculeIterator(MoleculeDescriptor, World*); 197 MoleculeIterator(const MoleculeIterator&); 198 MoleculeIterator& operator=(const MoleculeIterator&); 199 MoleculeIterator& operator++(); // prefix 200 MoleculeIterator operator++(int); // postfix with dummy parameter 201 bool operator==(const MoleculeIterator&); 202 bool operator==(const MoleculeSet::iterator&); 203 bool operator!=(const MoleculeIterator&); 204 bool operator!=(const MoleculeSet::iterator&); 205 molecule* operator*(); 206 207 int getCount(); 208 protected: 209 void advanceState(); 210 MoleculeSet::iterator state; 211 boost::shared_ptr<MoleculeDescriptor_impl> descr; 212 int index; 213 214 World* world; 215 }; 182 216 183 217 /** … … 193 227 * used for internal purposes, like MoleculeProcesses and MoleculeCalculations. 194 228 */ 195 Molecule Iterator moleculeEnd();229 MoleculeSet::iterator moleculeEnd(); 196 230 197 231 … … 206 240 207 241 periodentafel *periode; 208 public:209 242 AtomSet atoms; 210 private:211 243 std::set<atomId_t> atomIdPool; //<!stores the pool for all available AtomIds below currAtomId 212 244 atomId_t currAtomId; //!< stores the next available Id for atoms 213 245 MoleculeSet molecules; 214 246 moleculeId_t currMoleculeId; 247 248 249 /***** singleton Stuff *****/ 250 public: 251 252 /** 253 * get the currently active instance of the World. 254 */ 255 static World* get(); 256 257 /** 258 * destroy the currently active instance of the World. 259 */ 260 static void destroy(); 261 262 /** 263 * destroy the currently active instance of the World and immidiately 264 * create a new one. Use this to reset while somebody is still Observing 265 * the world and should reset the observed instance. All observers will be 266 * sent the subjectKille() message from the old world. 267 */ 268 static World* reset(); 269 215 270 private: 216 271 /** … … 225 280 */ 226 281 virtual ~World(); 282 283 static World *theWorld; 284 // this mutex only saves the singleton pattern... 285 // use other mutexes to protect internal data as well 286 // this mutex handles access to the pointer, not to the object!!! 287 static boost::mutex worldLock; 227 288 228 289 /*****
Note:
See TracChangeset
for help on using the changeset viewer.
