35 #ifndef IE_CORE_REFCOUNTED_H
36 #define IE_CORE_REFCOUNTED_H
40 #include "tbb/atomic.h"
42 #include "IECore/Export.h"
43 #include "boost/noncopyable.hpp"
44 #include "boost/intrusive_ptr.hpp"
49 #define IE_CORE_DECLAREPTR( TYPENAME ) \
50 typedef boost::intrusive_ptr< TYPENAME > TYPENAME ## Ptr; \
51 typedef boost::intrusive_ptr< const TYPENAME > Const ## TYPENAME ## Ptr; \
53 #define IE_CORE_DECLAREMEMBERPTR( TYPENAME ) \
54 typedef boost::intrusive_ptr< TYPENAME > Ptr; \
55 typedef boost::intrusive_ptr< const TYPENAME > ConstPtr;
59 #define IE_CORE_DECLAREMEMBERPTR2( PART1, PART2 ) \
60 typedef boost::intrusive_ptr< PART1, PART2 > Ptr; \
61 typedef boost::intrusive_ptr< const PART1, PART2 > ConstPtr;
65 #define IE_CORE_DECLAREMEMBERPTR3( PART1, PART2, PART3 ) \
66 typedef boost::intrusive_ptr< PART1, PART2, PART3 > Ptr; \
67 typedef boost::intrusive_ptr< const PART1, PART2, PART3 > ConstPtr;
69 #define IE_CORE_FORWARDDECLARE( TYPENAME ) \
71 IE_CORE_DECLAREPTR( TYPENAME ) \
73 class IECORE_API RefCounted :
private boost::noncopyable
128 IE_CORE_DECLAREMEMBERPTR( RefCounted );
130 typedef size_t RefCount;
135 inline void addRef()
const { m_numRefs++; };
140 assert( m_numRefs > 0 );
148 inline RefCount
refCount()
const {
return m_numRefs; };
156 mutable tbb::atomic<RefCount> m_numRefs;
160 IE_CORE_DECLAREPTR( RefCounted )
176 inline size_t tbb_hasher(
const boost::intrusive_ptr<T> &ptr )
179 const size_t h =
reinterpret_cast<size_t>( ptr.get() );
186 #endif // IE_CORE_REFCOUNTED_H
size_t tbb_hasher(const boost::intrusive_ptr< T > &ptr)
Definition: RefCounted.h:176
void removeRef() const
Remove a reference from the current object.
Definition: RefCounted.h:138
RefCount refCount() const
Returns the current reference count.
Definition: RefCounted.h:148
IECORE_API void intrusive_ptr_add_ref(const IECore::RefCounted *r)
Functions required to allow use of RefCounted with boost::intrusive_ptr.
Definition: RefCounted.h:163
void addRef() const
Add a reference to the current object.
Definition: RefCounted.h:135
Definition: RefCounted.h:124
This namespace contains all components of the core library.
Definition: AddSmoothSkinningInfluencesOp.h:43