#include <objmgr.h>
Inherited by BazisLib::ObjectManager::ServiceObject.
Classes | |
struct | DebugObjectReference |
Represents a single managed object for debugging purposes. More... | |
Public Types | |
enum | { HEAP_ALLOCATION_SIGNATURE = 'JBOM' } |
Public Member Functions | |
unsigned | Retain () |
Increments the reference counter. | |
unsigned | Release () |
Decrements the reference counter. | |
unsigned | GetReferenceCount () |
Returns the reference counter. | |
virtual ActionStatus | ExecuteSystemCommand (SystemCommand CommandCode, bool Recursive, void *pParam1=NULL, void *pParam2=NULL, void *pParam3=NULL) |
System command handler. | |
virtual ActionStatus | ExecuteCommand (class ServiceObject *Caller, unsigned CommandCode, void *pParam1=NULL, void *pParam2=NULL, void *pParam3=NULL) |
Service-to-client command handler. | |
void * | operator new (unsigned Size) |
Debug heap allocation operator. | |
Protected Types | |
enum | SystemCommand { InvalidCommand, FindCircularReferences, DumpChildren } |
Defines a system command used in ExecuteSystemCommand() method. More... | |
Private Member Functions | |
ManagedObjectBase () | |
Creates a managed object. | |
virtual | ~ManagedObjectBase () |
Deletes a managed object. | |
Private Attributes | |
AtomicInt32 | m_ReferenceCount |
Friends | |
class | ServiceObject |
This class represents a managed object. Any class that supports reference counting should be a descendant of this class. For details on managed objects, see this article.
enum BazisLib::ObjectManager::ManagedObjectBase::SystemCommand [protected] |
Defines a system command used in ExecuteSystemCommand() method.
BazisLib::ObjectManager::ManagedObjectBase::ManagedObjectBase | ( | ) | [inline, private] |
Creates a managed object.
The default constructor creates the managed object and sets its reference counter to 1. It means that a single ManagedObjectBase::Release() call is required to delete it immediately after creation.
virtual BazisLib::ObjectManager::ManagedObjectBase::~ManagedObjectBase | ( | ) | [inline, private, virtual] |
Deletes a managed object.
This destructor deletes a managed object. Note that managed objects should only be freed by calling the ManagedObject::Release() method. Direct call of the delete operator is not allowed. The debug build of the framework checks this.
virtual ActionStatus BazisLib::ObjectManager::ManagedObjectBase::ExecuteCommand | ( | class ServiceObject * | Caller, | |
unsigned | CommandCode, | |||
void * | pParam1 = NULL , |
|||
void * | pParam2 = NULL , |
|||
void * | pParam3 = NULL | |||
) | [inline, virtual] |
Service-to-client command handler.
This method is an overrideable handler for user service-to-client commands. You should use the ServiceObject::CallClients() method to send a command to the clients of a service. Further details on service-to-client commands can be found here.
virtual ActionStatus BazisLib::ObjectManager::ManagedObjectBase::ExecuteSystemCommand | ( | SystemCommand | CommandCode, | |
bool | Recursive, | |||
void * | pParam1 = NULL , |
|||
void * | pParam2 = NULL , |
|||
void * | pParam3 = NULL | |||
) | [inline, virtual] |
System command handler.
This method is an overrideable handler for system service-to-client commands. Such commands differ from user commands (handled by ManagedObjectBase::ExecuteCommand) and can even be recursive. Note that you are not allowed to call this method directly, or use any codes except defined by framework. To handle your own commands, override the ManagedObjectBase::ExecuteCommand method. Further details on service-to-client commands can be found here.
CommandCode | Specifies the command code to execute. | |
Recursive | Specifies whether a service that received a command should forward it to its clients. |
Reimplemented in BazisLib::ObjectManager::ServiceObject.
unsigned BazisLib::ObjectManager::ManagedObjectBase::GetReferenceCount | ( | ) | [inline] |
Returns the reference counter.
This method returns the reference counter of a managed object. This can be useful for debugging, however, you should never make any assumptions about the reference counter value.
void* BazisLib::ObjectManager::ManagedObjectBase::operator new | ( | unsigned | Size | ) | [inline] |
Debug heap allocation operator.
This operator allocates memory for all managed objects when the framwork is built in the debug mode. It initializes the memory with a special pattern: HEAP_ALLOCATION_SIGNATURE, that, in turn, allows constructors to distinguish between heap-allocated objects and static or stack-allocated ones. It also allows to determine whether a reference (or a managed pointer) is a part (field) of a managed object.
unsigned BazisLib::ObjectManager::ManagedObjectBase::Release | ( | ) | [inline] |
Decrements the reference counter.
This method decrements the reference counter of a managed object. When reference counter reaches zero, the object is deleted. It is recommended to use the ManagedPointer class instead of calling Retain()/Release() directly.
unsigned BazisLib::ObjectManager::ManagedObjectBase::Retain | ( | ) | [inline] |
Increments the reference counter.
This method increments the reference counter of a managed object. It is recommended to use the ManagedPointer class instead of calling Retain()/Release() directly.
friend class ServiceObject [friend] |