TrueReality  v0.1.1912
trBase::Base Class Referenceabstract

This is a Base class that carries the Class name and Unique ID of all the derived classes. More...

#include <Base.h>

Inheritance diagram for trBase::Base:
Collaboration diagram for trBase::Base:

Public Types

using BaseClass = trBase::SmrtClass
 
- Public Types inherited from trBase::SmrtClass
using BaseClass = osg::Referenced
 

Public Member Functions

 Base (const std::string &name=CLASS_TYPE)
 Holds the class type name for efficient comparisons. More...
 
virtual const std::string & GetType () const override=0
 Returns the class type. More...
 
virtual void SetName (const std::string &name)
 Sets this instances name. More...
 
virtual const std::string & GetName ()
 Returns this instances name. More...
 
virtual const std::string & GetName () const
 Returns this instances name. More...
 
virtual void SetUUID (const trBase::UniqueId &id)
 Overwrites the default internal UUID with the passed in one. More...
 
virtual const trBase::UniqueIdGetUUID (void)
 Returns the instances Universally Unique ID. More...
 
- Public Member Functions inherited from trBase::SmrtClass
 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...
 

Static Public Attributes

static const trUtil::RefStr CLASS_TYPE = trUtil::RefStr("trBase::Base")
 Adds an easy and swappable access to the base class. More...
 

Protected Member Functions

 ~Base ()
 Base destructor. More...
 
- Protected Member Functions inherited from trBase::SmrtClass
 ~SmrtClass ()
 

Private Attributes

trUtil::RefStr mName
 
trBase::UniqueId mId
 

Additional Inherited Members

- Static Public Member Functions inherited from trBase::SmrtClass
static OpenThreads::Mutex * GetGlobalReferencedMutex ()
 Get the optional global Referenced mutex, this can be shared between all trBase::SmrtClass. More...
 

Detailed Description

This is a Base class that carries the Class name and Unique ID of all the derived classes.

Definition at line 36 of file trBase/Base.h.

Member Typedef Documentation

◆ BaseClass

Definition at line 40 of file trBase/Base.h.

Constructor & Destructor Documentation

◆ Base()

trBase::Base::Base ( const std::string &  name = CLASS_TYPE)

Holds the class type name for efficient comparisons.

ctor.

Parameters
name(Optional) The name.

Definition at line 31 of file Base.cpp.

References GetName(), and LOG_D.

Here is the call graph for this function:

◆ ~Base()

trBase::Base::~Base ( )
protected

Base destructor.

Note, that it is protected so that classes cannot be deleted other than by being dereferenced and the reference count being zero (see trBase::SmrtClass), preventing the deletion of nodes which are still in use. This also means that Nodes cannot be created on stack i.e Node node will not compile, forcing all nodes to be created on the heap i.e Node* node = new Node().

Definition at line 37 of file Base.cpp.

References GetName(), and LOG_D.

Here is the call graph for this function:

Member Function Documentation

◆ GetName() [1/2]

◆ GetName() [2/2]

const std::string & trBase::Base::GetName ( ) const
virtual

Returns this instances name.

Returns
The name.

Definition at line 55 of file Base.cpp.

References mName.

◆ GetType()

◆ GetUUID()

◆ SetName()

void trBase::Base::SetName ( const std::string &  name)
virtual

◆ SetUUID()

void trBase::Base::SetUUID ( const trBase::UniqueId id)
virtual

Overwrites the default internal UUID with the passed in one.

This should be done very carefully.

Parameters
idThe identifier.

Definition at line 61 of file Base.cpp.

References mId.

Member Data Documentation

◆ CLASS_TYPE

const trUtil::RefStr trBase::Base::CLASS_TYPE = trUtil::RefStr("trBase::Base")
static

Adds an easy and swappable access to the base class.

Definition at line 42 of file trBase/Base.h.

◆ mId

trBase::UniqueId trBase::Base::mId
private

Definition at line 120 of file trBase/Base.h.

Referenced by GetUUID(), and SetUUID().

◆ mName

trUtil::RefStr trBase::Base::mName
private

Definition at line 119 of file trBase/Base.h.

Referenced by GetName(), and SetName().


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