Nazara Engine  0.4
A fast, complete, cross-platform API designed for game development
Nz::RefCounted Class Reference

Core class that represents a reference with a counter. More...

Inheritance diagram for Nz::RefCounted:
Nz::AbstractBackground Nz::InstancedRenderable Nz::Material Nz::MaterialPipeline Nz::ParticleController Nz::ParticleDeclaration Nz::ParticleGenerator Nz::ParticleRenderer Nz::SoundBuffer

Public Member Functions

 RefCounted (bool persistent=true)
 Constructs a RefCounted object with a persistance aspect. More...
 
 RefCounted (const RefCounted &)=delete
 
 RefCounted (RefCounted &&)=default
 
virtual ~RefCounted ()
 Destructs the object. More...
 
void AddReference () const
 Adds a reference to the object.
 
unsigned int GetReferenceCount () const
 Gets the number of references to the object. More...
 
bool IsPersistent () const
 Checks whether the object is persistent. More...
 
bool RemoveReference () const
 Removes a reference to the object. More...
 
bool SetPersistent (bool persistent=true, bool checkReferenceCount=false)
 Sets the persistence of the object. More...
 
RefCountedoperator= (const RefCounted &)=delete
 
RefCountedoperator= (RefCounted &&)=default
 

Detailed Description

Core class that represents a reference with a counter.

Constructor & Destructor Documentation

◆ RefCounted()

Nz::RefCounted::RefCounted ( bool  persistent = true)

Constructs a RefCounted object with a persistance aspect.

Parameters
persistentif false, object is destroyed when no more referenced

◆ ~RefCounted()

Nz::RefCounted::~RefCounted ( )
virtual

Destructs the object.

Remarks
Produces a NazaraWarning if still referenced with NAZARA_CORE_SAFE defined

Member Function Documentation

◆ GetReferenceCount()

unsigned int Nz::RefCounted::GetReferenceCount ( ) const

Gets the number of references to the object.

Returns
Number of references

◆ IsPersistent()

bool Nz::RefCounted::IsPersistent ( ) const

Checks whether the object is persistent.

Returns
true if object is not destroyed when no more referenced

◆ RemoveReference()

bool Nz::RefCounted::RemoveReference ( ) const

Removes a reference to the object.

Returns
true if object is deleted because no more referenced
Remarks
Produces a NazaraError if counter is already 0 with NAZARA_CORE_SAFE defined

◆ SetPersistent()

bool Nz::RefCounted::SetPersistent ( bool  persistent = true,
bool  checkReferenceCount = false 
)

Sets the persistence of the object.

Returns
true if object is deleted because no more referenced
Parameters
persistentSets the persistence of the object
checkReferenceCountChecks if the object should be destroyed if true

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