StrongRefHandler Class Reference

#include <baseref.h>

Inheritance diagram for StrongRefHandler:

Detailed Description

StrongRefHandler has to be used as template argument for BaseRef to obtain a reference to objects which support reference counting. Whenever the pointer of such a BaseRef is set, the reference count of the pointee is increased by invocation of AddReference() on the pointee. If a pointer is cleared, the reference count of the pointee is decreased by means of RemoveReference(). If the reference count reaches zero, the pointee releases itself.

Classes

struct  HasAddReference< FlexibleArray< T, COUNT > >
 
struct  HasRemoveReference< DescTranslation >
 
struct  HasRemoveReference< FlexibleArray< T, COUNT > >
 

Static Public Member Functions

template<typename T >
static void InitialReference (const T *o)
 
template<typename T >
static void AddReference (const T *o)
 
template<typename T >
static MAXON_ATTRIBUTE_FORCE_INLINE void RemoveReference (const T *o)
 
template<typename T >
static void AddWeakReference (const T *o, WeakRefBase &weakRef)
 
template<typename T >
static Bool CreateStrongReference (const T *o)
 
template<typename T >
static StrongReferenceCounterGetReferenceCounter (const T *o)
 
template<typename R >
static ResultRef< typename R::ReferencedType > MakeWritable (R &ref, Bool resetOnError)
 

Static Public Attributes

static constexpr VALUEKIND KIND
 

Private Member Functions

 MAXON_MEMBERFUNCTION_DETECTOR (InitialReference)
 
 MAXON_MEMBERFUNCTION_DETECTOR (AddReference)
 
 MAXON_MEMBERFUNCTION_DETECTOR (RemoveReference)
 

Member Function Documentation

◆ MAXON_MEMBERFUNCTION_DETECTOR() [1/3]

MAXON_MEMBERFUNCTION_DETECTOR ( InitialReference  )
private

◆ MAXON_MEMBERFUNCTION_DETECTOR() [2/3]

MAXON_MEMBERFUNCTION_DETECTOR ( AddReference  )
private

◆ MAXON_MEMBERFUNCTION_DETECTOR() [3/3]

MAXON_MEMBERFUNCTION_DETECTOR ( RemoveReference  )
private

◆ InitialReference()

static void InitialReference ( const T *  o)
static

Sets the initial reference to a newly allocated object (slightly more efficient than AddReference).

Parameters
[in]oPointer to the referenced object, must not be nullptr.

◆ AddReference()

static void AddReference ( const T *  o)
static

Adds a reference to the referenced object.

Parameters
[in]oPointer to the referenced object, must not be nullptr.

◆ RemoveReference()

static MAXON_ATTRIBUTE_FORCE_INLINE void RemoveReference ( const T *  o)
static

Removes a reference to the referenced object.

Parameters
[in]oPointer to the referenced object, must not be nullptr.

◆ AddWeakReference()

static void AddWeakReference ( const T *  o,
WeakRefBase weakRef 
)
static

◆ CreateStrongReference()

static Bool CreateStrongReference ( const T *  o)
static

Tries to add a strong reference. If the object is already being released this will return false.

Parameters
[in]oWeakly referenced object (might be nullptr).
Returns
True if a strong reference could be added.

◆ GetReferenceCounter()

static StrongReferenceCounter& GetReferenceCounter ( const T *  o)
static

◆ MakeWritable()

static ResultRef<typename R::ReferencedType> MakeWritable ( R &  ref,
Bool  resetOnError 
)
static

Member Data Documentation

◆ KIND

constexpr VALUEKIND KIND
staticconstexpr