HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_IntrusivePtr< T > Class Template Reference

Wrapper around hboost::intrusive_ptr. More...

#include <UT_IntrusivePtr.h>

+ Inheritance diagram for UT_IntrusivePtr< T >:

Public Member Functions

SYS_FORCE_INLINE UT_IntrusivePtr () noexcept
 
SYS_FORCE_INLINE UT_IntrusivePtr (T *p)
 
SYS_FORCE_INLINE UT_IntrusivePtr (T *p, bool add_ref)
 
SYS_FORCE_INLINE UT_IntrusivePtr (const UT_IntrusivePtr< T > &p)
 
template<typename Y >
SYS_FORCE_INLINE UT_IntrusivePtr (const UT_IntrusivePtr< Y > &p)
 
SYS_FORCE_INLINE UT_IntrusivePtr (UT_IntrusivePtr< T > &&p)
 
template<typename Y >
SYS_FORCE_INLINE UT_IntrusivePtr (UT_IntrusivePtr< Y > &&p)
 
SYS_FORCE_INLINE
UT_IntrusivePtr< T > & 
operator= (const UT_IntrusivePtr< T > &that)
 
template<typename Y >
SYS_FORCE_INLINE
UT_IntrusivePtr< T > & 
operator= (const UT_IntrusivePtr< Y > &that)
 
SYS_FORCE_INLINE
UT_IntrusivePtr< T > & 
operator= (UT_IntrusivePtr< T > &&that)
 
template<typename Y >
SYS_FORCE_INLINE
UT_IntrusivePtr< T > & 
operator= (UT_IntrusivePtr< Y > &&that)
 

Detailed Description

template<class T>
class UT_IntrusivePtr< T >

Wrapper around hboost::intrusive_ptr.

An intrusive pointer assumes that the referenced object implements reference counting on itself. The reference counting is implemented using the methods intrusive_ptr_add_ref() and intrusive_ptr_release().

For simple usages, simply derive from UT_IntrusiveRefCounter.

Here's a roll your own example:

class Foo {
public:
Foo() : myCount(0) {}
~Foo() {}
void incref()
{
myCount.add(1);
}
void decref()
{
if (myCount.add(-1) == 0)
delete this;
}
SYS_AtomicInt32 myCount;
};
static inline void intrusive_ptr_add_ref(Foo *o) { o->incref(); }
static inline void intrusive_ptr_release(Foo *o) { o->decref(); }
using FooHandle = UT_IntrusivePtr<Foo>;
See Also
UT_SharedPtr
Examples:
packedshareddata/GU_PackedSharedData.C, packedsphere/GU_PackedSphere.C, and SOP/SOP_BouncyAgent.C.

Definition at line 52 of file UT_IntrusivePtr.h.

Constructor & Destructor Documentation

template<class T>
SYS_FORCE_INLINE UT_IntrusivePtr< T >::UT_IntrusivePtr ( )
inlinenoexcept

Definition at line 56 of file UT_IntrusivePtr.h.

template<class T>
SYS_FORCE_INLINE UT_IntrusivePtr< T >::UT_IntrusivePtr ( T p)
inline

Definition at line 63 of file UT_IntrusivePtr.h.

template<class T>
SYS_FORCE_INLINE UT_IntrusivePtr< T >::UT_IntrusivePtr ( T p,
bool  add_ref 
)
inline

Definition at line 67 of file UT_IntrusivePtr.h.

template<class T>
SYS_FORCE_INLINE UT_IntrusivePtr< T >::UT_IntrusivePtr ( const UT_IntrusivePtr< T > &  p)
inline

Definition at line 71 of file UT_IntrusivePtr.h.

template<class T>
template<typename Y >
SYS_FORCE_INLINE UT_IntrusivePtr< T >::UT_IntrusivePtr ( const UT_IntrusivePtr< Y > &  p)
inline

Definition at line 76 of file UT_IntrusivePtr.h.

template<class T>
SYS_FORCE_INLINE UT_IntrusivePtr< T >::UT_IntrusivePtr ( UT_IntrusivePtr< T > &&  p)
inline

Definition at line 80 of file UT_IntrusivePtr.h.

template<class T>
template<typename Y >
SYS_FORCE_INLINE UT_IntrusivePtr< T >::UT_IntrusivePtr ( UT_IntrusivePtr< Y > &&  p)
inline

Definition at line 85 of file UT_IntrusivePtr.h.

Member Function Documentation

template<class T>
SYS_FORCE_INLINE UT_IntrusivePtr<T>& UT_IntrusivePtr< T >::operator= ( const UT_IntrusivePtr< T > &  that)
inline

Definition at line 89 of file UT_IntrusivePtr.h.

template<class T>
template<typename Y >
SYS_FORCE_INLINE UT_IntrusivePtr<T>& UT_IntrusivePtr< T >::operator= ( const UT_IntrusivePtr< Y > &  that)
inline

Definition at line 97 of file UT_IntrusivePtr.h.

template<class T>
SYS_FORCE_INLINE UT_IntrusivePtr<T>& UT_IntrusivePtr< T >::operator= ( UT_IntrusivePtr< T > &&  that)
inline

Definition at line 104 of file UT_IntrusivePtr.h.

template<class T>
template<typename Y >
SYS_FORCE_INLINE UT_IntrusivePtr<T>& UT_IntrusivePtr< T >::operator= ( UT_IntrusivePtr< Y > &&  that)
inline

Definition at line 112 of file UT_IntrusivePtr.h.


The documentation for this class was generated from the following file: