Line | |
---|
1 | #ifndef _BBCMESH_H |
---|
2 | #define _BBCMESH_H |
---|
3 | |
---|
4 | #include <BBCPrerequisites.h> |
---|
5 | |
---|
6 | namespace BBC { |
---|
7 | |
---|
8 | using namespace Ogre; |
---|
9 | |
---|
10 | //Fordward declaration |
---|
11 | class Mesh; |
---|
12 | |
---|
13 | namespace boost
|
---|
14 | {
|
---|
15 | void intrusive_ptr_add_ref(Mesh * p);
|
---|
16 | void intrusive_ptr_release(Mesh * p);
|
---|
17 | }; |
---|
18 | |
---|
19 | class _BBCExport Mesh |
---|
20 | { |
---|
21 | protected: |
---|
22 | Ogre::Mesh* mMesh; |
---|
23 | |
---|
24 | private:
|
---|
25 | long references;
|
---|
26 | friend void boost::intrusive_ptr_add_ref(Mesh * p);
|
---|
27 | friend void boost::intrusive_ptr_release(Mesh * p);
|
---|
28 | |
---|
29 | public: |
---|
30 | |
---|
31 | Mesh(Ogre::Mesh* mesh): references(0) // initialize references to 0 |
---|
32 | { |
---|
33 | mMesh = mesh; |
---|
34 | } |
---|
35 | |
---|
36 | Ogre::Mesh* get() |
---|
37 | { |
---|
38 | return mMesh; |
---|
39 | } |
---|
40 | |
---|
41 | virtual ~Mesh(); |
---|
42 | }; |
---|
43 | |
---|
44 | // class specific addref/release implementation
|
---|
45 | // the two function overloads must be in the boost namespace on most compilers:
|
---|
46 | namespace boost
|
---|
47 | {
|
---|
48 | inline void intrusive_ptr_add_ref(Mesh * p)
|
---|
49 | {
|
---|
50 | // increment reference count of object *p
|
---|
51 | ++(p->references);
|
---|
52 | }
|
---|
53 |
|
---|
54 | inline void intrusive_ptr_release(Mesh * p)
|
---|
55 | {
|
---|
56 | // decrement reference count, and delete object when reference count reaches 0
|
---|
57 | if (--(p->references) == 0)
|
---|
58 | delete p;
|
---|
59 | }
|
---|
60 | } // namespace boost
|
---|
61 |
|
---|
62 | typedef ::boost::intrusive_ptr<Mesh> MeshPtr;
|
---|
63 | |
---|
64 | } |
---|
65 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.