TrueReality  v0.1.1912
trBase::SmrtClass Class Referenceabstract

This class is part of the internal garbage collection system. More...

#include <SmrtClass.h>

Inheritance diagram for trBase::SmrtClass:
Collaboration diagram for trBase::SmrtClass:

Public Types

using BaseClass = osg::Referenced
 

Public Member Functions

 SmrtClass ()
 Adds an easy and swappable access to the base class. More...
 
 SmrtClass (bool threadSafeRefUnref)
 Constructor. More...
 
 SmrtClass (const SmrtClass &inst)
 Copy constructor. More...
 
virtual bool GetThreadSafeRefUnref ()
 Get whether a mutex is used to ensure Ref() and UnRef() are thread safe. More...
 
OpenThreads::Mutex * GetRefMutex () const
 Get the mutex used to ensure thread safety of Ref()/UnRef(). More...
 
int Ref () const
 Increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
int Unref () const
 Decrement the reference count by one, indicating that a pointer to this object is no longer referencing it. More...
 
int UnRefNoDelete () const
 Decrement the reference count by one, indicating that a pointer to this object is no longer referencing it. More...
 
int ReferenceCount () const
 Return the number of pointers currently referencing this object. More...
 
virtual const std::string & GetType () const =0
 Returns the class type. More...
 

Static Public Member Functions

static OpenThreads::Mutex * GetGlobalReferencedMutex ()
 Get the optional global Referenced mutex, this can be shared between all trBase::SmrtClass. More...
 

Protected Member Functions

 ~SmrtClass ()
 

Detailed Description

This class is part of the internal garbage collection system.

Anything that inherits it can also use the smart pointer interface (trBase::SmrtPtr)

It inherits osg::Referenced and uses the OSG garbage collection in its core

Definition at line 38 of file SmrtClass.h.

Member Typedef Documentation

◆ BaseClass

using trBase::SmrtClass::BaseClass = osg::Referenced

Definition at line 42 of file SmrtClass.h.

Constructor & Destructor Documentation

◆ SmrtClass() [1/3]

trBase::SmrtClass::SmrtClass ( )
inline

Adds an easy and swappable access to the base class.

Default constructor.

Definition at line 49 of file SmrtClass.h.

◆ SmrtClass() [2/3]

trBase::SmrtClass::SmrtClass ( bool  threadSafeRefUnref)
inlineexplicit

Constructor.

Parameters
threadSafeRefUnrefTrue to thread safe reference unref.

Definition at line 59 of file SmrtClass.h.

◆ SmrtClass() [3/3]

trBase::SmrtClass::SmrtClass ( const SmrtClass inst)
inline

Copy constructor.

Parameters
instThe instance.

Definition at line 69 of file SmrtClass.h.

◆ ~SmrtClass()

trBase::SmrtClass::~SmrtClass ( )
inlineprotected

Definition at line 153 of file SmrtClass.h.

Member Function Documentation

◆ GetGlobalReferencedMutex()

OpenThreads::Mutex * trBase::SmrtClass::GetGlobalReferencedMutex ( )
static

Get the optional global Referenced mutex, this can be shared between all trBase::SmrtClass.

Returns
Null if it fails, else the global referenced mutex.

Definition at line 39 of file SmrtClass.cpp.

◆ GetRefMutex()

OpenThreads::Mutex * trBase::SmrtClass::GetRefMutex ( ) const

Get the mutex used to ensure thread safety of Ref()/UnRef().

Returns
Null if it fails, else the reference mutex.

Definition at line 33 of file SmrtClass.cpp.

◆ GetThreadSafeRefUnref()

bool trBase::SmrtClass::GetThreadSafeRefUnref ( )
virtual

Get whether a mutex is used to ensure Ref() and UnRef() are thread safe.

Returns
True if it succeeds, false if it fails.

Definition at line 27 of file SmrtClass.cpp.

◆ GetType()

◆ Ref()

int trBase::SmrtClass::Ref ( ) const
inline

Increment the reference count by one, indicating that this object has another pointer which is referencing it.

Returns
An int.

Definition at line 45 of file SmrtClass.cpp.

◆ ReferenceCount()

int trBase::SmrtClass::ReferenceCount ( ) const
inline

Return the number of pointers currently referencing this object.

Returns
An int.

Definition at line 63 of file SmrtClass.cpp.

◆ Unref()

int trBase::SmrtClass::Unref ( ) const
inline

Decrement the reference count by one, indicating that a pointer to this object is no longer referencing it.

If the reference count goes to zero, it is assumed that this object is no longer referenced and is automatically deleted.

Returns
An int.

Definition at line 51 of file SmrtClass.cpp.

◆ UnRefNoDelete()

int trBase::SmrtClass::UnRefNoDelete ( ) const

Decrement the reference count by one, indicating that a pointer to this object is no longer referencing it.

However, do not delete it, even if ref count goes to 0. Warning, UnRefNoDelete() should only be called if the user knows exactly who will be responsible for it, one should prefer UnRef() over UnRefNoDelete() as the latter can lead to memory leaks.

Returns
An int.

Definition at line 57 of file SmrtClass.cpp.


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