#ifndef _BBCENTITYDISTRIBUTION_H #define _BBCENTITYDISTRIBUTION_H #include namespace BBC { // Forward declarations class EntityDistribution; namespace boost { void intrusive_ptr_add_ref(EntityDistribution * p); void intrusive_ptr_release(EntityDistribution * p); }; class _BBCExport EntityDistribution { private: long references; friend void boost::intrusive_ptr_add_ref(EntityDistribution * p); friend void boost::intrusive_ptr_release(EntityDistribution * p); protected: std::vector mEntityList; public: EntityDistribution(); virtual ~EntityDistribution(); EntityPtr getEntity(unsigned int value); void addEntity(EntityPtr value); void removeEntity(unsigned int value); unsigned int getNumEntities(void); }; // class specific addref/release implementation // the two function overloads must be in the boost namespace on most compilers: namespace boost { inline void intrusive_ptr_add_ref(EntityDistribution * p) { // increment reference count of object *p ++(p->references); } inline void intrusive_ptr_release(EntityDistribution * p) { // decrement reference count, and delete object when reference count reaches 0 if (--(p->references) == 0) delete p; } } // namespace boost typedef ::boost::intrusive_ptr EntityDistributionPtr; } #endif