nux-0.9.48
|
The base class of Nux objects. More...
#include <NuxCore/Object.h>
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 |
The base class of Nux objects.
nux::Object::Object | ( | bool | OwnTheReference = true , |
NUX_FILE_LINE_PROTO | |||
) |
Constructor.
virtual nux::Object::~Object | ( | ) | [protected, virtual] |
Private destructor.
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().
Reimplemented from nux::Trackable.
int nux::Object::GetReferenceCount | ( | ) | const |
Get the reference count of this object.
Referenced by nux::IOpenGLResource::RefCount().
int nux::Object::GetWeakReferenceCount | ( | ) | const |
Get 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.
Reimplemented from nux::Trackable.
virtual bool nux::Object::SinkReference | ( | ) | [virtual] |
Mark the object as owned.
Reimplemented from nux::Trackable.
bool nux::Object::UnReference | ( | ) | [virtual] |
Decrease reference count.
Reimplemented from nux::Trackable.
friend class ObjectPtr [friend] |
friend class ObjectStats [friend] |
friend class ObjectWeakPtr [friend] |
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.
NThreadSafeCounter* nux::Object::_objectptr_count [protected] |
Number of ObjectPtr hosting the object.
NThreadSafeCounter* nux::Object::_reference_count [protected] |
Reference count.
NThreadSafeCounter* nux::Object::_weak_reference_count [protected] |
Weak reference count.
sigc::signal<void, Object *> nux::Object::OnDestroyed |
Signal emitted immediately before the object is destroyed.