nux-0.9.48

nux::Object Class Reference

The base class of Nux objects. More...

#include <NuxCore/Object.h>

Inheritance diagram for nux::Object:
nux::Trackable nux::ActionItem nux::CachedResourceData nux::FontTexture nux::InitiallyUnownedObject nux::IOpenGLResource nux::MenuBarItem nux::RadioButtonGroup nux::ResourceData nux::Timeline

Public Member Functions

 NUX_DECLARE_OBJECT_TYPE (BaseObject, Trackable)
 Object (bool OwnTheReference=true, NUX_FILE_LINE_PROTO)
 Constructor.
bool Reference ()
 Increase reference count.
bool UnReference ()
 Decrease reference count.
virtual bool SinkReference ()
 Mark the object as owned.
virtual bool Dispose ()
 Destroy and object that has a floating reference.
int GetReferenceCount () const
 Get the reference count of this object.
int GetWeakReferenceCount () const
 Get the weak reference count of this object.

Data Fields

sigc::signal< void, Object * > OnDestroyed
 Signal emitted immediately before the object is destroyed.

Protected Member Functions

virtual ~Object ()
 Private destructor.
void IncrementWeakCounter ()
void DecrementWeakCounter ()

Protected Attributes

NThreadSafeCounter_reference_count
 Reference count.
NThreadSafeCounter_weak_reference_count
 Weak reference count.
NThreadSafeCounter_objectptr_count
 Number of ObjectPtr hosting the object.
bool * _destroyed

Friends

class ObjectPtr
class ObjectWeakPtr
class ObjectStats

Detailed Description

The base class of Nux objects.


Constructor & Destructor Documentation

nux::Object::Object ( bool  OwnTheReference = true,
NUX_FILE_LINE_PROTO   
)

Constructor.

virtual nux::Object::~Object ( ) [protected, virtual]

Private destructor.


Member Function Documentation

void nux::Object::DecrementWeakCounter ( ) [protected]
virtual bool nux::Object::Dispose ( ) [virtual]

Destroy and object that has a floating reference.

If this object is not owned, calling SinkReference() as the same effect as calling Reference().

Returns:
True is the object has been destroyed

Reimplemented from nux::Trackable.

int nux::Object::GetReferenceCount ( ) const

Get the reference count of this object.

Returns:
The reference count of this object.

Referenced by nux::IOpenGLResource::RefCount().

int nux::Object::GetWeakReferenceCount ( ) const

Get the weak reference count of this object.

Returns:
The weak reference count of this object.
void nux::Object::IncrementWeakCounter ( ) [protected]
nux::Object::NUX_DECLARE_OBJECT_TYPE ( BaseObject  ,
Trackable   
)
bool nux::Object::Reference ( ) [virtual]

Increase reference count.

Returns:
True if the object has successfully referenced.

Reimplemented from nux::Trackable.

virtual bool nux::Object::SinkReference ( ) [virtual]

Mark the object as owned.

Returns:
True if the object was not owned previously

Reimplemented from nux::Trackable.

bool nux::Object::UnReference ( ) [virtual]

Decrease reference count.

Returns:
True if the object reference count has reached 0 and the object has been destroyed.

Reimplemented from nux::Trackable.


Friends And Related Function Documentation

friend class ObjectPtr [friend]
friend class ObjectStats [friend]
friend class ObjectWeakPtr [friend]

Field Documentation

bool* nux::Object::_destroyed [protected]

Between the time an object goes into Destroy () and the moment it goes into ~Object (), there is the possibility that some weak smart pointer references of the object will be destroyed. For these smart pointers, the reference count of the object is 0 and the weak reference count is > 0. We want the last weak pointer reference to set the object _reference_count and _weak_reference_count variable to 0 after deleting them (rather than leaving them as invalid pointers). So when the object goes into the destructor (~Object ()) we can do some additional checks and verifications. _destroyed is set to true before the destructor returns.

Number of ObjectPtr hosting the object.

Reference count.

Weak reference count.

sigc::signal<void, Object *> nux::Object::OnDestroyed

Signal emitted immediately before the object is destroyed.


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