ionflux.org | Impressum

Ionflux::Tools::ManagedObject Class Reference
[Memory managementGeneral tools]

Base class for managed objects. More...

#include <ManagedObject.hpp>

Inheritance diagram for Ionflux::Tools::ManagedObject:

Inheritance graph
[legend]
Collaboration diagram for Ionflux::Tools::ManagedObject:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ManagedObject ()
 Constructor.
virtual ~ManagedObject ()
 Destructor.
virtual bool setManaged (bool newManage)
 Set memory management flag.
virtual bool isManaged ()
 Get memory management flag.
virtual unsigned int ref ()
 Increase reference count.
virtual unsigned int unref ()
 Decrease reference count.
virtual unsigned int getRefCount ()
 Get reference count.

Static Public Attributes

static const ManagedObjectClassInfo managedObjectClassInfo
 Class information instance.
static const ClassInfoCLASS_INFO
 Class information.

Protected Attributes

bool managed
 Memory management flag.
unsigned int refCount
 Reference count.

Detailed Description

Base class for managed objects.

This class provides a base class for objects the allocated memory of which is managed by another class, called the 'owner' or 'parent' of the object. Making an object managed by another improves the chances that it is properly deleted at the end of its lifetime. This class also provides a reference counting facility that may be used along with or independently of the memory management flag.

Note:
Any entity that references an object is also responsible for removing the references after it has finished using the referenced object. A managed object will usually not be deleted by its parent unless its reference count is zero. A parent object must maintain its own list of managed objects, since the managed object itself does not keep track of its parents or referencing objects. Generally, it should be possible to delete an object with a reference count of zero. This means a parent object should always reference an object on registration in its list of managed objects. Any managed object should be managed by only one parent object. If it is not known precisely which parent object should be responsible for destroying a managed object, reference counting should be used instead.


Constructor & Destructor Documentation

Ionflux::Tools::ManagedObject::ManagedObject  ) 
 

Constructor.

Construct new ManagedObject object.

Ionflux::Tools::ManagedObject::~ManagedObject  )  [virtual]
 

Destructor.

Destruct ManagedObject object.


Member Function Documentation

unsigned int Ionflux::Tools::ManagedObject::getRefCount  )  [virtual]
 

Get reference count.

Get the number of references (reference count).

Returns:
Current reference count.

bool Ionflux::Tools::ManagedObject::isManaged  )  [virtual]
 

Get memory management flag.

Get the memory management flag of this object.

Returns:
true if this object is managed by its parent, false otherwise.

unsigned int Ionflux::Tools::ManagedObject::ref  )  [virtual]
 

Increase reference count.

Increase the reference count.

Warning:
A managed object may not be properly deleted by its parent if references are not removed after the referencing entity has finished using the object.
Returns:
Current reference count after the reference operation.

bool Ionflux::Tools::ManagedObject::setManaged bool  newManage  )  [virtual]
 

Set memory management flag.

This controls whether memory allocated for this object should be managed by its parent object.

Warning:
If this function returns false, no attempts should be made by the caller to manage the object. A return value of false indicates that this object is managed by another parent object (and thus probably indicates a bug in the calling code). The management flag should not be used at all if there are doubts as to which parent object should have the sole responsibility for deleting a managed object. If the parent object cannot be clearly determined, reference counting should be used instead.
Parameters:
newManage Whether memory allocated for this object should be managed by ist parent object.
Returns:
true if this object may be managed by the caller, false otherwise.

unsigned int Ionflux::Tools::ManagedObject::unref  )  [virtual]
 

Decrease reference count.

Decrease the reference count.

Returns:
Current reference count after the reference operation.


Member Data Documentation

const ClassInfo * Ionflux::Tools::ManagedObject::CLASS_INFO [static]
 

Initial value:

Class information.

Reimplemented from Ionflux::Tools::Object.

Reimplemented in Ionflux::Tools::Database, Ionflux::Tools::MySQLDatabase, Ionflux::Tools::Utf8Tokenizer, and Ionflux::Tools::Utf8TokenTypeMap.

bool Ionflux::Tools::ManagedObject::managed [protected]
 

Memory management flag.

const ManagedObjectClassInfo Ionflux::Tools::ManagedObject::managedObjectClassInfo [static]
 

Class information instance.

unsigned int Ionflux::Tools::ManagedObject::refCount [protected]
 

Reference count.


The documentation for this class was generated from the following files:
Generated on Tue Mar 14 21:08:38 2006 for Ionflux Tools Class Library (iftools) by  doxygen 1.4.6