Scarab  2.8.1
Project 8 C++ Utility Library
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
Object Class Referenceabstract

Reference counted object base class. More...

#include <object.h>

Public Member Functions

 Object ()
 Default constructor. More...
 
 Object (const Object &)
 Copy constructor. More...
 
int getRefCount () const
 Return the current reference count. More...
 
void incRef () const
 Increase the object's reference count by one. More...
 
void decRef (bool dealloc=true) const
 Decrease the reference count of the object and possibly deallocate it. More...
 
virtual std::string toString () const =0
 

Protected Member Functions

virtual ~Object ()
 Virtual protected deconstructor. (Will only be called by ref) More...
 

Private Attributes

std::atomic< int > m_refCount { 0 }
 

Detailed Description

Reference counted object base class.

Definition at line 8 of file object.h.

Constructor & Destructor Documentation

◆ Object() [1/2]

Object ( )
inline

Default constructor.

Definition at line 11 of file object.h.

◆ Object() [2/2]

Object ( const Object )
inline

Copy constructor.

Definition at line 14 of file object.h.

◆ ~Object()

virtual ~Object ( )
inlineprotectedvirtual

Virtual protected deconstructor. (Will only be called by ref)

Definition at line 41 of file object.h.

Member Function Documentation

◆ decRef()

void decRef ( bool  dealloc = true) const
inline

Decrease the reference count of the object and possibly deallocate it.

The object will automatically be deallocated once the reference count reaches zero.

Definition at line 28 of file object.h.

◆ getRefCount()

int getRefCount ( ) const
inline

Return the current reference count.

Definition at line 17 of file object.h.

◆ incRef()

void incRef ( ) const
inline

Increase the object's reference count by one.

Definition at line 20 of file object.h.

◆ toString()

virtual std::string toString ( ) const
pure virtual

Member Data Documentation

◆ m_refCount

std::atomic<int> m_refCount { 0 }
mutableprivate

Definition at line 43 of file object.h.


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