Rev | Line | |
---|
[700] | 1 | #ifndef _BBCENTITYDISTRIBUTION_H |
---|
| 2 | #define _BBCENTITYDISTRIBUTION_H |
---|
| 3 | |
---|
| 4 | #include <BBCEntity.h> |
---|
| 5 | |
---|
| 6 | namespace BBC { |
---|
| 7 | |
---|
[721] | 8 | // Forward declarations
|
---|
| 9 | class EntityDistribution;
|
---|
| 10 |
|
---|
| 11 |
|
---|
| 12 | namespace boost
|
---|
| 13 | {
|
---|
| 14 | void intrusive_ptr_add_ref(EntityDistribution * p);
|
---|
| 15 | void intrusive_ptr_release(EntityDistribution * p);
|
---|
| 16 | }; |
---|
| 17 | |
---|
| 18 | class _BBCExport EntityDistribution |
---|
| 19 | { |
---|
| 20 | private:
|
---|
| 21 | long references;
|
---|
| 22 | friend void boost::intrusive_ptr_add_ref(EntityDistribution * p);
|
---|
| 23 | friend void boost::intrusive_ptr_release(EntityDistribution * p); |
---|
| 24 | |
---|
[700] | 25 | protected: |
---|
[721] | 26 | std::vector<EntityPtr> mEntityList; |
---|
[700] | 27 | |
---|
| 28 | public: |
---|
[721] | 29 | EntityDistribution(); |
---|
[700] | 30 | |
---|
[721] | 31 | virtual ~EntityDistribution(); |
---|
[700] | 32 | |
---|
[721] | 33 | EntityPtr getEntity(unsigned int value); |
---|
| 34 | |
---|
| 35 | void addEntity(EntityPtr value); |
---|
| 36 | |
---|
[700] | 37 | void removeEntity(unsigned int value); |
---|
| 38 | |
---|
| 39 | unsigned int getNumEntities(void); |
---|
| 40 | }; |
---|
| 41 | |
---|
[721] | 42 | |
---|
| 43 | // class specific addref/release implementation
|
---|
| 44 | // the two function overloads must be in the boost namespace on most compilers:
|
---|
| 45 | namespace boost
|
---|
| 46 | {
|
---|
| 47 | inline void intrusive_ptr_add_ref(EntityDistribution * p)
|
---|
| 48 | {
|
---|
| 49 | // increment reference count of object *p
|
---|
| 50 | ++(p->references);
|
---|
| 51 | }
|
---|
| 52 |
|
---|
| 53 |
|
---|
| 54 |
|
---|
| 55 | inline void intrusive_ptr_release(EntityDistribution * p)
|
---|
| 56 | {
|
---|
| 57 | // decrement reference count, and delete object when reference count reaches 0
|
---|
| 58 | if (--(p->references) == 0)
|
---|
| 59 | delete p;
|
---|
| 60 | }
|
---|
| 61 | } // namespace boost
|
---|
| 62 |
|
---|
| 63 | typedef ::boost::intrusive_ptr<EntityDistribution> EntityDistributionPtr; |
---|
| 64 | |
---|
[700] | 65 | } |
---|
| 66 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.