Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members

RefObject Class Reference

#include <yateclass.h>

Inheritance diagram for RefObject:

GenObject Array CallEndpoint ChanAssist DataEndpoint DataNode Channel DataConsumer DataSource ClientChannel DataTranslator ThreadedSource List of all members.

Public Member Functions

 RefObject ()
virtual ~RefObject ()
virtual bool alive () const
bool ref ()
bool deref ()
int refcount () const
virtual void destruct ()

Protected Member Functions

virtual void zeroRefs ()
bool resurrect ()

Detailed Description

A reference counted object. Whenever using multiple inheritance you should inherit this class virtually.


Constructor & Destructor Documentation

RefObject  )  [inline]
 

The constructor initializes the reference counter to 1! Use deref() to destruct the object when safe

virtual ~RefObject  )  [virtual]
 

Destructor.


Member Function Documentation

virtual bool alive  )  const [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.

Returns:
True if the object is referenced and safe to access

Reimplemented from GenObject.

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;
 
Returns:
True if the object may have been deleted, false if it still exists and is safe to access

virtual void destruct  )  [virtual]
 

Refcounted objects should just have the counter decremented. That will destroy them only when the refcount reaches zero.

Reimplemented from GenObject.

bool ref  ) 
 

Increments the reference counter if not already zero

Returns:
True if the object was successfully referenced and is safe to access

int refcount  )  const [inline]
 

Get the current value of the reference counter

Returns:
The value of the reference counter

bool resurrect  )  [protected]
 

Bring the object back alive by setting the reference counter to one. Note that it works only if the counter was zero previously

Returns:
True if the object was resurrected - its name may be Lazarus ;-)

virtual void zeroRefs  )  [protected, virtual]
 

This method is called when the reference count reaches zero. The default behaviour is to delete the object.

Reimplemented in Channel.


The documentation for this class was generated from the following file:
Generated on Mon Sep 18 20:56:12 2006 for Yate by  doxygen 1.4.4