|
Last change
on this file since 86b917 was 86b917, checked in by Tillmann Crueger <crueger@…>, 16 years ago |
|
Added descriptors that allow multiple kinds of access to atoms
|
-
Property mode
set to
100644
|
|
File size:
1.4 KB
|
| Line | |
|---|
| 1 | /*
|
|---|
| 2 | * World.hpp
|
|---|
| 3 | *
|
|---|
| 4 | * Created on: Feb 3, 2010
|
|---|
| 5 | * Author: crueger
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | #ifndef WORLD_HPP_
|
|---|
| 9 | #define WORLD_HPP_
|
|---|
| 10 |
|
|---|
| 11 | #include <boost/thread.hpp>
|
|---|
| 12 | #include <map>
|
|---|
| 13 | #include <vector>
|
|---|
| 14 |
|
|---|
| 15 | #include "Patterns/Observer.hpp"
|
|---|
| 16 | #include "Patterns/Cacheable.hpp"
|
|---|
| 17 |
|
|---|
| 18 | // forward declarations
|
|---|
| 19 | class periodentafel;
|
|---|
| 20 | class MoleculeListClass;
|
|---|
| 21 | class atom;
|
|---|
| 22 | class AtomDescriptor;
|
|---|
| 23 |
|
|---|
| 24 | class World : public Observable
|
|---|
| 25 | {
|
|---|
| 26 | friend class AtomDescriptor;
|
|---|
| 27 | public:
|
|---|
| 28 |
|
|---|
| 29 | /***** getter and setter *****/
|
|---|
| 30 | periodentafel* getPeriode();
|
|---|
| 31 | atom* getAtom(AtomDescriptor& descriptor);
|
|---|
| 32 | std::vector<atom*> getAllAtoms(AtomDescriptor& descriptor);
|
|---|
| 33 | private:
|
|---|
| 34 | periodentafel *periode;
|
|---|
| 35 | std::map<int,atom*> atoms;
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 | /***** singleton Stuff *****/
|
|---|
| 39 | public:
|
|---|
| 40 | static World* get();
|
|---|
| 41 | static void destroy();
|
|---|
| 42 | static World* reset();
|
|---|
| 43 |
|
|---|
| 44 | private:
|
|---|
| 45 | World();
|
|---|
| 46 | virtual ~World();
|
|---|
| 47 |
|
|---|
| 48 | static World *theWorld;
|
|---|
| 49 | // this mutex only saves the singleton pattern...
|
|---|
| 50 | // use other mutexes to protect internal data as well
|
|---|
| 51 | // this mutex handles access to the pointer, not to the object!!!
|
|---|
| 52 | static boost::mutex worldLock;
|
|---|
| 53 |
|
|---|
| 54 | /*****
|
|---|
| 55 | * some legacy stuff that is include for now but will be removed later
|
|---|
| 56 | *****/
|
|---|
| 57 | public:
|
|---|
| 58 | MoleculeListClass *getMolecules();
|
|---|
| 59 |
|
|---|
| 60 | // functions used for the WorldContent template mechanism
|
|---|
| 61 | void registerAtom(atom *theAtom);
|
|---|
| 62 | void unregisterAtom(atom *theAtom);
|
|---|
| 63 | private:
|
|---|
| 64 | MoleculeListClass *molecules;
|
|---|
| 65 | };
|
|---|
| 66 |
|
|---|
| 67 | #endif /* WORLD_HPP_ */
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.