Ocean
Ocean::ObjectRef< T >::ObjectHolder Class Reference

This class implements a helper object for the actual object reference class. More...

Public Member Functions

 ObjectHolder (T *object, const ReleaseCallback &releaseCallback=ReleaseCallback())
 Creates a new ObjectHolder object. More...
 
ObjectHolderref ()
 Increases the reference counter. More...
 
void unref ()
 Decreases the reference counter and disposes the encapsulated object and the holder itself if the reference counter reaches zero. More...
 
unsigned int references () const
 Returns the number of references. More...
 

Protected Attributes

T * object_ = nullptr
 Pointer to the internal object. More...
 
std::atomic< unsigned int > atomicReferenceCounter_
 Reference counter of the internal object. More...
 
ReleaseCallback callback_
 Release callback. More...
 

Friends

class ObjectRef< T >
 

Detailed Description

template<typename T>
class Ocean::ObjectRef< T >::ObjectHolder

This class implements a helper object for the actual object reference class.

ObjectRef objects sharing the same encapsulated object share the same holder object of the encapsulated object. The holder is created only once for the very first ObjectRef object, while the pointer to this holder is shared to the subsequent ObjectRef objects (which access the same encapsulated object).

Constructor & Destructor Documentation

◆ ObjectHolder()

template<typename T >
Ocean::ObjectRef< T >::ObjectHolder::ObjectHolder ( T *  object,
const ReleaseCallback releaseCallback = ReleaseCallback() 
)
inlineexplicit

Creates a new ObjectHolder object.

Parameters
objectPointer to the internal object
releaseCallbackCallback for release event

Member Function Documentation

◆ ref()

template<typename T >
ObjectRef< T >::ObjectHolder * Ocean::ObjectRef< T >::ObjectHolder::ref
inline

Increases the reference counter.

Returns
Pointer to this object

◆ references()

template<typename T >
unsigned int Ocean::ObjectRef< T >::ObjectHolder::references
inline

Returns the number of references.

Returns
Reference number

◆ unref()

template<typename T >
void Ocean::ObjectRef< T >::ObjectHolder::unref

Decreases the reference counter and disposes the encapsulated object and the holder itself if the reference counter reaches zero.

Friends And Related Function Documentation

◆ ObjectRef< T >

template<typename T >
friend class ObjectRef< T >
friend

Field Documentation

◆ atomicReferenceCounter_

template<typename T >
std::atomic<unsigned int> Ocean::ObjectRef< T >::ObjectHolder::atomicReferenceCounter_
protected

Reference counter of the internal object.

◆ callback_

template<typename T >
ReleaseCallback Ocean::ObjectRef< T >::ObjectHolder::callback_
protected

Release callback.

◆ object_

template<typename T >
T* Ocean::ObjectRef< T >::ObjectHolder::object_ = nullptr
protected

Pointer to the internal object.


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