#ifndef _BBCMESH_H #define _BBCMESH_H #include namespace BBC { using namespace Ogre; //Fordward declaration class Mesh; namespace boost { void intrusive_ptr_add_ref(Mesh * p); void intrusive_ptr_release(Mesh * p); }; class _BBCExport Mesh { protected: Ogre::Mesh* mMesh; private: long references; friend void boost::intrusive_ptr_add_ref(Mesh * p); friend void boost::intrusive_ptr_release(Mesh * p); public: Mesh(Ogre::Mesh* mesh): references(0) // initialize references to 0 { mMesh = mesh; } Ogre::Mesh* get() { return mMesh; } virtual ~Mesh(); }; // 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(Mesh * p) { // increment reference count of object *p ++(p->references); } inline void intrusive_ptr_release(Mesh * p) { // decrement reference count, and delete object when reference count reaches 0 if (--(p->references) == 0) delete p; } } // namespace boost typedef ::boost::intrusive_ptr MeshPtr; } #endif