Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members | Related Pages | Examples

VOS::RefCounted Class Reference

This is a simple base class for reference counting objects. More...

#include <vos/corelibs/vos/refcount.hh>

Inheritance diagram for VOS::RefCounted:

VOS::Message VOS::MessageBlock VOS::MessageContext VOS::Vobject VOS::Vobject::ParentChildRelation VOS::VobjectEvent VOS::MetaObject VOS::VobjectImplementation VOS::LocalMetaObject VOS::RemoteMetaObject VOS::Site VOS::LocalVobject VOS::RemoteVobject VOS::LocalSite VOS::RemoteSite VOS::LocalSite VOS::RemoteSite VOS::LocalMetaObject VOS::RemoteMetaObject VOS::LocalSocketSite VOS::RemoteSocketSite VOS::RemoteStreamSite VOS::LocalSocketSite VOS::RemoteSocketSite VOS::RemoteStreamSite VOS::LocalSite VOS::RemoteSite List of all members.

Public Member Functions


Detailed Description

This is a simple base class for reference counting objects.

It also provides a facility for tracking references to this object, so that they may be notified when the application wants this object to be deleted. You can use vRef to automatically release RefCounted objects when they would normally be destroyed (go out of scope).

Note:
When you inherit from this make sure you inherit it as a virtual base class. That means
    class Foo : public virtual RefCounted { ... };
Otherwise you could have two (or more) seperate reference counters for the same object, and that won't do at all.

Definition at line 153 of file refcount.hh.


Constructor & Destructor Documentation

VOS::RefCounted::RefCounted  )  [inline]
 

Construct the refcount object with a starting count of 1.

Definition at line 160 of file refcount.hh.

VOS::RefCounted::RefCounted const RefCounted  )  [inline]
 

copy constructor, need to reset count for copy

Definition at line 163 of file refcount.hh.

virtual VOS::RefCounted::~RefCounted  )  [inline, virtual]
 

Destructor.

(Cleans up excise listeners)

Definition at line 166 of file refcount.hh.


Member Function Documentation

virtual void VOS::RefCounted::acquire  )  [virtual]
 

Increment the reference count.

Reimplemented in VOS::LocalMetaObject, VOS::MetaObject, VOS::RemoteMetaObject, and VOS::RemoteVobject.

Referenced by VOS::VobjectImplementation::addChildListener(), VOS::VobjectImplementation::addParentListener(), VOS::VobjectImplementation::addTypeListener(), VOS::VobjectImplementation::DispatchTemplate< T >::DispatchTemplate(), VOS::RemoteSite::excise(), VOS::VobjectImplementation::findChild(), VOS::VobjectImplementation::findObject(), VOS::Message::getMessageContext(), VOS::MessageContext::getParentContext(), VOS::Message::setMessageContext(), VOS::MessageContext::setParentContext(), VOS::VobjectEvent::VobjectEvent(), and VOS::VobjectNotifyEvent::VobjectNotifyEvent().

virtual void VOS::RefCounted::addExciseListener ObjectExciseListener oel  )  [virtual]
 

Add an excise listener.

When the excise method is called on this object, each excise listener will be notified so that it may clean up any references to this object.

Referenced by VOS::VobjectImplementation::addChildListener(), VOS::VobjectImplementation::addMessageHandler(), VOS::VobjectImplementation::addParentListener(), VOS::VobjectImplementation::addTypeListener(), and VOS::VobjectImplementation::addUpdateHandler().

virtual void VOS::RefCounted::destroy  )  [virtual]
 

This method is used by release() to destroy this object if the refcount reaches 0.

By default, it simply calls "delete this". However, you can override it in a subclass if you need to do something other than deleting this object.

virtual void VOS::RefCounted::excise  )  [virtual]
 

Try to cause all known references to this object to release their references so the object will be deleted, by calling ObjectExciseListener::notifyObjectExcise().

Note:
This method is virtual and objects making use of this class will probably want to supply their own code to detach from linking data structures. Overriding excise() will probably be sufficient for most uses; the purpose of the ObjectExciseListener facility is for plugin/application level hooks which may be beyond the scope of your immediate code.

Reimplemented in VOS::LocalMetaObject, VOS::MetaObject, VOS::RemoteMetaObject, VOS::RemoteSite, VOS::RemoteSocketSite, and VOS::VobjectImplementation.

Referenced by VOS::RemoteSite::excise().

virtual int VOS::RefCounted::getCount  )  [virtual]
 

Get the current reference count.

Reimplemented in VOS::LocalMetaObject, VOS::MetaObject, and VOS::RemoteMetaObject.

Referenced by VOS::RemoteVobject::acquire(), VOS::VobjectImplementation::excise(), and VOS::RemoteVobject::release().

virtual void VOS::RefCounted::release  )  [virtual]
 

Decrement the reference count.

The object will be deleted if (count == 0)

Reimplemented in VOS::LocalMetaObject, VOS::MetaObject, VOS::RemoteMetaObject, VOS::RemoteSite, and VOS::RemoteVobject.

Referenced by VOS::VobjectImplementation::excise(), VOS::RemoteSite::excise(), VOS::RemoteStreamSite::flushIncomingBuffers(), VOS::RemoteSocketSite::flushIncomingBuffers(), VOS::VobjectImplementation::removeChildListener(), VOS::VobjectImplementation::removeParentListener(), VOS::VobjectImplementation::removeTypeListener(), VOS::VobjectImplementation::setChild(), VOS::Message::setMessageContext(), VOS::MessageContext::setParentContext(), VOS::VobjectImplementation::DispatchTemplate< T >::~DispatchTemplate(), VOS::Message::~Message(), VOS::MessageContext::~MessageContext(), VOS::RemoteStreamSite::~RemoteStreamSite(), VOS::VobjectEvent::~VobjectEvent(), VOS::VobjectImplementation::~VobjectImplementation(), and VOS::VobjectNotifyEvent::~VobjectNotifyEvent().

virtual void VOS::RefCounted::removeExciseListener ObjectExciseListener oel,
bool  releaseIfRefcounted = true
[virtual]
 

Remove an excise listener.

See also:
addExciseListener()
Parameters:
oel the ObjectExciseListener to remove
releaseIfRefcounted Should we test the object excise listener to see if it is refcounted, and if so release it? Under certain special circumstances (such as calling "removeExciseListener(this)" from a destructor) this behavior is undesirable.

Referenced by VOS::VobjectImplementation::excise(), VOS::VobjectImplementation::removeChildListener(), VOS::VobjectImplementation::removeMessageHandler(), VOS::VobjectImplementation::removeParentListener(), VOS::VobjectImplementation::removeTypeListener(), VOS::VobjectImplementation::removeUpdateHandler(), and VOS::VobjectImplementation::~VobjectImplementation().


The documentation for this class was generated from the following file:
Generated on Tue Aug 12 03:56:05 2003 for Interreality Project - VOS by doxygen 1.3.2