UniversalManager< T, ParrentClass >::ManagedItem Class Reference

a class wrapping some managed-information for UniversalManager More...

#include <universal_manager.h>

Inherits RefCounter.

Inheritance diagram for UniversalManager< T, ParrentClass >::ManagedItem:

Inheritance graph
[legend]
Collaboration diagram for UniversalManager< T, ParrentClass >::ManagedItem:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ManagedItem (std::string key, T *itemPtr)
 initializes this wrapper of T with key (unique name used for registration) and ptr to data
virtual ~ManagedItem ()
 operator T * (void) const
 reference access
 operator T & (void) const
 type-cast operator to type T
std::string getKey (void)
 key used by manager
T * getPtr (void)
 data pointer
bool isManaged (void)
 managed-status of this item
void disableManaging ()
 disables managing of this item and becomes a "zombie"

Protected Member Functions

virtual void OnZeroRefCount ()
 sends the "ZeroRefCount-event" to the appropriate specialized manager

Private Attributes

std::string mRegKey
 key used in registration (key)
T * mItemPtr
 pointer to the managed item
bool mManaged
 true = owned by manager, false = owned by itself

Detailed Description

template<class T, class ParrentClass>
class UniversalManager< T, ParrentClass >::ManagedItem

a class wrapping some managed-information for UniversalManager

Definition at line 74 of file universal_manager.h.


Constructor & Destructor Documentation

template<class T, class ParrentClass>
UniversalManager< T, ParrentClass >::ManagedItem::ManagedItem std::string  key,
T *  itemPtr
[inline]
 

initializes this wrapper of T with key (unique name used for registration) and ptr to data

Sets managed-state mManaged to true (manager is the owner of this instance).

Definition at line 82 of file universal_manager.h.

template<class T, class ParrentClass>
virtual UniversalManager< T, ParrentClass >::ManagedItem::~ManagedItem  )  [inline, virtual]
 

Definition at line 86 of file universal_manager.h.


Member Function Documentation

template<class T, class ParrentClass>
void UniversalManager< T, ParrentClass >::ManagedItem::disableManaging  )  [inline]
 

disables managing of this item and becomes a "zombie"

If the item is managed, managing is disabled, content (internal data pointer mItemPtr ) is destroyed by the manager and set to null.

Definition at line 127 of file universal_manager.h.

References Singleton< ParrentClass >::getInstance(), UniversalManager< T, ParrentClass >::ManagedItem::getPtr(), UniversalManager< T, ParrentClass >::ManagedItem::isManaged(), UniversalManager< T, ParrentClass >::ManagedItem::mItemPtr, and UniversalManager< T, ParrentClass >::ManagedItem::mManaged.

Here is the call graph for this function:

template<class T, class ParrentClass>
std::string UniversalManager< T, ParrentClass >::ManagedItem::getKey void   )  [inline]
 

key used by manager

Return values:
unique identifier used by manager for registering this item

Definition at line 104 of file universal_manager.h.

References UniversalManager< T, ParrentClass >::ManagedItem::mRegKey.

Referenced by UniversalManager< T, ParrentClass >::OnZeroRefCount().

template<class T, class ParrentClass>
T* UniversalManager< T, ParrentClass >::ManagedItem::getPtr void   )  [inline]
 

data pointer

Return values:
value of data pointer that this item wraps

Definition at line 111 of file universal_manager.h.

References UniversalManager< T, ParrentClass >::ManagedItem::mItemPtr.

Referenced by UniversalManager< T, ParrentClass >::ManagedItem::disableManaging().

template<class T, class ParrentClass>
bool UniversalManager< T, ParrentClass >::ManagedItem::isManaged void   )  [inline]
 

managed-status of this item

Return values:
true,if the item is managed by manager, false otherwise.

Definition at line 118 of file universal_manager.h.

References UniversalManager< T, ParrentClass >::ManagedItem::mManaged.

Referenced by UniversalManager< T, ParrentClass >::ManagedItem::disableManaging(), and UniversalManager< T, ParrentClass >::ManagedItem::OnZeroRefCount().

template<class T, class ParrentClass>
virtual void UniversalManager< T, ParrentClass >::ManagedItem::OnZeroRefCount  )  [inline, protected, virtual]
 

sends the "ZeroRefCount-event" to the appropriate specialized manager

It redefines the behavior of RefCounter::OnZeroRefCount (parrent's ZeroRefCount-event handler). This redefined handler fires a new event for the appropriate UniversalManager (if it is managed) and gives a reference to itself to the manager. The concrete specialized manager is the one who knows what to do, when ZeroRefCount-event has occured. The specialized manager should do all the "destroy-actions" related to freeing the resources allocated with this managed item.

Note:
Manager is notyfied only when state mManaged is true (default true), but manager can set it to false. This is the case when the manager is destroyed, but there still exist some references to managed items. The manager can disable those items this way, remove them from its registry (but doesn't destroy them) and log some warning message.

Reimplemented from RefCounter.

Definition at line 153 of file universal_manager.h.

References Singleton< ParrentClass >::getPtr(), RefCounter::isHeapAllocated(), and UniversalManager< T, ParrentClass >::ManagedItem::isManaged().

Here is the call graph for this function:

template<class T, class ParrentClass>
UniversalManager< T, ParrentClass >::ManagedItem::operator T & void   )  const [inline]
 

type-cast operator to type T

Definition at line 97 of file universal_manager.h.

References UniversalManager< T, ParrentClass >::ManagedItem::mItemPtr.

template<class T, class ParrentClass>
UniversalManager< T, ParrentClass >::ManagedItem::operator T * void   )  const [inline]
 

reference access

Definition at line 91 of file universal_manager.h.

References UniversalManager< T, ParrentClass >::ManagedItem::mItemPtr.


Member Data Documentation

template<class T, class ParrentClass>
T* UniversalManager< T, ParrentClass >::ManagedItem::mItemPtr [private]
 

pointer to the managed item

Definition at line 167 of file universal_manager.h.

Referenced by UniversalManager< T, ParrentClass >::ManagedItem::disableManaging(), UniversalManager< T, ParrentClass >::ManagedItem::getPtr(), UniversalManager< T, ParrentClass >::ManagedItem::operator T &(), and UniversalManager< T, ParrentClass >::ManagedItem::operator T *().

template<class T, class ParrentClass>
bool UniversalManager< T, ParrentClass >::ManagedItem::mManaged [private]
 

true = owned by manager, false = owned by itself

Definition at line 168 of file universal_manager.h.

Referenced by UniversalManager< T, ParrentClass >::ManagedItem::disableManaging(), and UniversalManager< T, ParrentClass >::ManagedItem::isManaged().

template<class T, class ParrentClass>
std::string UniversalManager< T, ParrentClass >::ManagedItem::mRegKey [private]
 

key used in registration (key)

Definition at line 166 of file universal_manager.h.

Referenced by UniversalManager< T, ParrentClass >::ManagedItem::getKey().


The documentation for this class was generated from the following file:
Generated on Wed Apr 12 14:46:46 2006 for bjs by  doxygen 1.4.5