Yate
|
#include <yateclass.h>
Public Member Functions | |
RefObject () | |
virtual | ~RefObject () |
virtual void * | getObject (const String &name) const |
virtual bool | alive () const |
bool | ref () |
bool | deref () |
int | refcount () const |
virtual void | destruct () |
Public Member Functions inherited from GenObject | |
GenObject () | |
virtual | ~GenObject () |
virtual const String & | toString () const |
NamedCounter * | getObjCounter () const |
NamedCounter * | setObjCounter (NamedCounter *counter) |
Static Public Member Functions | |
static bool | alive (const RefObject *obj) |
static bool | efficientIncDec () |
Static Public Member Functions inherited from GenObject | |
static void * | getObject (const String &name, const GenObject *obj) |
static bool | getObjCounting () |
static void | setObjCounting (bool enable) |
static NamedCounter * | getObjCounter (const String &name, bool create=true) |
static ObjList & | getObjCounters () |
Protected Member Functions | |
virtual void | zeroRefs () |
bool | resurrect () |
virtual void | destroyed () |
A reference counted object. Whenever using multiple inheritance you should inherit this class virtually.
RefObject | ( | ) |
The constructor initializes the reference counter to 1! Use deref() to destruct the object when safe
|
virtual |
Destructor.
|
virtual |
Check if the object is still referenced and safe to access. Note that you should not trust this result unless the object is locked by other means.
Reimplemented from GenObject.
|
inlinestatic |
Check if a refcounted object is still alive
obj | Pointer to the object to check |
References RefObject::refcount().
bool deref | ( | ) |
Decrements the reference counter, destroys the object if it reaches zero
// Deref this object, return quickly if the object was deleted if (deref()) return;
|
protectedvirtual |
Pre-destruction notification, called just before the object is deleted. Unlike in the destructor it is safe to call virtual methods here. Reimplementing this method allows to perform any object cleanups.
Reimplemented in DurationUpdate, MucRoom, ClientContact, ClientAccount, ClientChannel, CallEndpoint, DataEndpoint, ThreadedSource, DataSource, and DataConsumer.
|
virtual |
Refcounted objects should just have the counter decremented. That will destroy them only when the refcount reaches zero.
Reimplemented from GenObject.
|
static |
Check if reference counter manipulations are efficient on this platform. If platform does not support atomic operations a mutex pool is used.
|
virtual |
Get a pointer to a derived class given that class name
name | Name of the class we are asking for |
Reimplemented from GenObject.
Reimplemented in Channel, Array, CallEndpoint, DataEndpoint, DataTranslator, DataSource, and DataConsumer.
Referenced by Message::userObject().
bool ref | ( | ) |
Increments the reference counter if not already zero
Referenced by MucRoom::status().
|
inline |
Get the current value of the reference counter
Referenced by RefObject::alive().
|
protected |
Bring the object back alive by setting the reference counter to one. Note that it works only if the counter was zero previously
|
protectedvirtual |
This method is called when the reference count reaches zero after unlocking the mutex if the call to zeroRefsTest() returned true. The default behaviour is to delete the object.
Reimplemented in Channel.