| 1 | /*
|
|---|
| 2 | * AtomDescriptor.hpp
|
|---|
| 3 | *
|
|---|
| 4 | * Created on: Feb 5, 2010
|
|---|
| 5 | * Author: crueger
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | #ifndef ATOMDESCRIPTOR_HPP_
|
|---|
| 9 | #define ATOMDESCRIPTOR_HPP_
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 | #include <vector>
|
|---|
| 13 | #include <map>
|
|---|
| 14 | #include <boost/shared_ptr.hpp>
|
|---|
| 15 | #include "World.hpp"
|
|---|
| 16 |
|
|---|
| 17 | class World;
|
|---|
| 18 | class atom;
|
|---|
| 19 |
|
|---|
| 20 | // internal implementation, allows assignment, copying etc
|
|---|
| 21 | class AtomDescripter_impl;
|
|---|
| 22 |
|
|---|
| 23 | class AtomDescriptor {
|
|---|
| 24 | // close coupling to the world to allow access
|
|---|
| 25 | friend atom* World::getAtom(AtomDescriptor descriptor);
|
|---|
| 26 | friend std::vector<atom*> World::getAllAtoms(AtomDescriptor descriptor);
|
|---|
| 27 | friend class World::AtomIterator;
|
|---|
| 28 |
|
|---|
| 29 | friend AtomDescriptor operator&&(const AtomDescriptor &lhs, const AtomDescriptor &rhs);
|
|---|
| 30 | friend AtomDescriptor operator||(const AtomDescriptor &lhs, const AtomDescriptor &rhs);
|
|---|
| 31 | friend AtomDescriptor operator!(const AtomDescriptor &arg);
|
|---|
| 32 |
|
|---|
| 33 | public:
|
|---|
| 34 | typedef boost::shared_ptr<AtomDescriptor_impl> impl_ptr;
|
|---|
| 35 |
|
|---|
| 36 | AtomDescriptor(impl_ptr);
|
|---|
| 37 | AtomDescriptor(const AtomDescriptor&);
|
|---|
| 38 | ~AtomDescriptor();
|
|---|
| 39 |
|
|---|
| 40 | AtomDescriptor &operator=(AtomDescriptor &);
|
|---|
| 41 |
|
|---|
| 42 | protected:
|
|---|
| 43 | atom* find();
|
|---|
| 44 | std::vector<atom*> findAll();
|
|---|
| 45 | impl_ptr get_impl() const;
|
|---|
| 46 |
|
|---|
| 47 | private:
|
|---|
| 48 | impl_ptr impl;
|
|---|
| 49 | };
|
|---|
| 50 |
|
|---|
| 51 | // Functions to construct actual descriptors
|
|---|
| 52 | AtomDescriptor AllAtoms();
|
|---|
| 53 | AtomDescriptor NoAtoms();
|
|---|
| 54 |
|
|---|
| 55 | // no true short circuit, but the test of the second descriptor wont be done
|
|---|
| 56 | AtomDescriptor operator&&(const AtomDescriptor &lhs, const AtomDescriptor &rhs);
|
|---|
| 57 | AtomDescriptor operator||(const AtomDescriptor &lhs, const AtomDescriptor &rhs);
|
|---|
| 58 | AtomDescriptor operator!(const AtomDescriptor &arg);
|
|---|
| 59 |
|
|---|
| 60 | #endif /* ATOMDESCRIPTOR_HPP_ */
|
|---|