HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UT_IntrusiveRefCounter< DerivedT, Deleter, CounterPolicyT > Class Template Reference

A reference counter base class for use with UT_IntrusivePtr. More...

#include <UT_IntrusivePtr.h>

Public Member Functions

SYS_FORCE_INLINE UT_IntrusiveRefCounter ()
 Default constructor: Sets counter to 0. More...
 
SYS_FORCE_INLINE UT_IntrusiveRefCounter (const UT_IntrusiveRefCounter &)
 Copy constructor: Sets counter to 0. More...
 
UT_IntrusiveRefCounteroperator= (const UT_IntrusiveRefCounter &)
 Assignment operator: Does not modify counter. More...
 
SYS_FORCE_INLINE uint32 use_count () const
 Return current counter. More...
 

Protected Member Functions

SYS_FORCE_INLINE ~UT_IntrusiveRefCounter ()
 Destructor: Only derived classes can destruct this. More...
 

Friends

void intrusive_ptr_add_ref (const UT_IntrusiveRefCounter< DerivedT, Deleter, CounterPolicyT > *p)
 
void intrusive_ptr_release (const UT_IntrusiveRefCounter< DerivedT, Deleter, CounterPolicyT > *p)
 

Detailed Description

template<typename DerivedT, typename Deleter = std::default_delete<DerivedT>, typename CounterPolicyT = UT_IntrusiveThreadSafeCounterPolicy>
class UT_IntrusiveRefCounter< DerivedT, Deleter, CounterPolicyT >

A reference counter base class for use with UT_IntrusivePtr.

This base class can be used with user-defined classes to add support for UT_IntrusivePtr. The class contains a reference counter defined by the CounterPolicyT. Upon releasing the last UT_IntrusivePtr referencing the object derived from the UT_IntrusiveRefCounter class, operator delete is automatically called on the pointer to the object.

The other template parameter, DerivedT, is the user's class that derives from UT_IntrusiveRefCounter.

Example:

class MyClass : public UT_IntrusiveRefCounter<MyClass>
{ ... };
typedef UT_IntrusivePtr<MyClass> MyClassPtr;

Definition at line 138 of file UT_IntrusivePtr.h.

Constructor & Destructor Documentation

template<typename DerivedT, typename Deleter = std::default_delete<DerivedT>, typename CounterPolicyT = UT_IntrusiveThreadSafeCounterPolicy>
SYS_FORCE_INLINE UT_IntrusiveRefCounter< DerivedT, Deleter, CounterPolicyT >::UT_IntrusiveRefCounter ( )
inline

Default constructor: Sets counter to 0.

Definition at line 174 of file UT_IntrusivePtr.h.

template<typename DerivedT, typename Deleter = std::default_delete<DerivedT>, typename CounterPolicyT = UT_IntrusiveThreadSafeCounterPolicy>
SYS_FORCE_INLINE UT_IntrusiveRefCounter< DerivedT, Deleter, CounterPolicyT >::UT_IntrusiveRefCounter ( const UT_IntrusiveRefCounter< DerivedT, Deleter, CounterPolicyT > &  )
inline

Copy constructor: Sets counter to 0.

Definition at line 180 of file UT_IntrusivePtr.h.

template<typename DerivedT, typename Deleter = std::default_delete<DerivedT>, typename CounterPolicyT = UT_IntrusiveThreadSafeCounterPolicy>
SYS_FORCE_INLINE UT_IntrusiveRefCounter< DerivedT, Deleter, CounterPolicyT >::~UT_IntrusiveRefCounter ( )
inlineprotected

Destructor: Only derived classes can destruct this.

Definition at line 199 of file UT_IntrusivePtr.h.

Member Function Documentation

template<typename DerivedT, typename Deleter = std::default_delete<DerivedT>, typename CounterPolicyT = UT_IntrusiveThreadSafeCounterPolicy>
UT_IntrusiveRefCounter& UT_IntrusiveRefCounter< DerivedT, Deleter, CounterPolicyT >::operator= ( const UT_IntrusiveRefCounter< DerivedT, Deleter, CounterPolicyT > &  )
inline

Assignment operator: Does not modify counter.

Definition at line 185 of file UT_IntrusivePtr.h.

template<typename DerivedT, typename Deleter = std::default_delete<DerivedT>, typename CounterPolicyT = UT_IntrusiveThreadSafeCounterPolicy>
SYS_FORCE_INLINE uint32 UT_IntrusiveRefCounter< DerivedT, Deleter, CounterPolicyT >::use_count ( ) const
inline

Return current counter.

Definition at line 191 of file UT_IntrusivePtr.h.

Friends And Related Function Documentation

template<typename DerivedT, typename Deleter = std::default_delete<DerivedT>, typename CounterPolicyT = UT_IntrusiveThreadSafeCounterPolicy>
void intrusive_ptr_add_ref ( const UT_IntrusiveRefCounter< DerivedT, Deleter, CounterPolicyT > *  p)
friend

Definition at line 214 of file UT_IntrusivePtr.h.

template<typename DerivedT, typename Deleter = std::default_delete<DerivedT>, typename CounterPolicyT = UT_IntrusiveThreadSafeCounterPolicy>
void intrusive_ptr_release ( const UT_IntrusiveRefCounter< DerivedT, Deleter, CounterPolicyT > *  p)
friend

Definition at line 221 of file UT_IntrusivePtr.h.


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