RefCountable Class Reference

This class represents objects that can be reference-counted using the Ref class. More...

#include <RefCount.h>

Inheritance diagram for RefCountable:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 RefCountable ()
 Default constructor.
 RefCountable (const RefCountable &)
 Copy constructor -- ref count and manager settings are deliberately not copied over!
virtual ~RefCountable ()
 Virtual destructor, to keep C++ honest.
RefCountableoperator= (const RefCountable &)
 Assigment operator.
void IncrementRefCount () const
 Increments the counter and returns true iff the new value is zero.
bool DecrementRefCount () const
 Decrements the counter and returns true iff the new value is zero.
void SetManager (AbstractObjectManager *manager)
 Sets the recycle-pointer for this object.
AbstractObjectManagerGetManager () const
 Returns this object's current recyler pointer.
uint32 GetRefCount () const
 Returns this object's current reference count.

Detailed Description

This class represents objects that can be reference-counted using the Ref class.

Note that any object that can be reference counted can also be pooled and recycled.

Definition at line 16 of file RefCount.h.


Constructor & Destructor Documentation

RefCountable::RefCountable (  )  [inline]

Default constructor.

Refcount begins at zero.

Definition at line 20 of file RefCount.h.

virtual RefCountable::~RefCountable (  )  [inline, virtual]

Virtual destructor, to keep C++ honest.

Don't remove this unless you like crashing

Definition at line 26 of file RefCount.h.


Member Function Documentation

RefCountable& RefCountable::operator= ( const RefCountable  )  [inline]

Assigment operator.

deliberately implemented as a no-op!

Definition at line 29 of file RefCount.h.

void RefCountable::IncrementRefCount (  )  const [inline]

Increments the counter and returns true iff the new value is zero.

Thread safe.

Definition at line 32 of file RefCount.h.

References AtomicCounter::AtomicIncrement().

bool RefCountable::DecrementRefCount (  )  const [inline]

Decrements the counter and returns true iff the new value is zero.

Thread safe.

Definition at line 35 of file RefCount.h.

References AtomicCounter::AtomicDecrement().

void RefCountable::SetManager ( AbstractObjectManager manager  )  [inline]

Sets the recycle-pointer for this object.

If set to non-NULL, this pointer is used by the ObjectPool class to recycle this object when it is no longer in use, so as to avoid the overhead of having to delete it and re-create it later on. The RefCountable class itself does nothing with this pointer. Default value is NULL.

Parameters:
manager Pointer to the new manager object to use, or NULL to use no manager.

Definition at line 44 of file RefCount.h.

uint32 RefCountable::GetRefCount (  )  const [inline]

Returns this object's current reference count.

Note that the value returned by this method is volatile in multithreaded environments, so it may already be wrong by the time it is returned. Be careful!

Definition at line 54 of file RefCount.h.

References AtomicCounter::GetCount().


The documentation for this class was generated from the following file:
Generated on Thu Jun 5 17:48:29 2008 for MUSCLE by  doxygen 1.5.1