ALBA
Public Member Functions | Protected Attributes | List of all members
albaReferenceCounted Class Reference

#include <albaReferenceCounted.h>

Inheritance diagram for albaReferenceCounted:
Inheritance graph
[legend]
Collaboration diagram for albaReferenceCounted:
Collaboration graph
[legend]

Public Member Functions

 albaReferenceCounted ()
 
virtual ~albaReferenceCounted ()
 
 albaAbstractTypeMacro (albaReferenceCounted, albaObject)
 
virtual void Delete ()
 
void Register (void *obj)
 
virtual void UnRegister (void *obj)
 
int GetReferenceCount ()
 
void SetReferenceCount (int)
 
- Public Member Functions inherited from albaObject
 albaObject ()
 
virtual ~albaObject ()
 
virtual void Delete ()
 
virtual const char * GetTypeName () const
 
virtual bool IsA (const char *type_name) const
 
virtual bool IsA (const albaTypeID &type_id) const
 
virtual albaObjectNewObjectInstance () const =0
 
virtual const albaTypeIDGetTypeId () const
 
virtual void Print (std::ostream &os, const int indent=0) const
 
 albaObject (const albaObject &c)
 

Protected Attributes

int m_ReferenceCount
 
- Protected Attributes inherited from albaObject
bool m_HeapFlag
 

Additional Inherited Members

- Static Public Member Functions inherited from albaObject
static const char * GetStaticTypeName ()
 
static bool IsStaticType (const char *type_name)
 
static bool IsStaticType (const albaTypeID &type_id)
 
static const albaTypeIDGetStaticTypeId ()
 
static albaObjectSafeDownCast (albaObject *o)
 

Detailed Description

albaReferenceCounted - abstract base class for ALBA objects with reference counting.

albaReferenceCounted is the base class for all reference counted classes in the ALBA. albaReferenceCounteds are also albaObjects, thus implementing all RTTI APIs. albaReferenceCounted performs reference counting: objects that are reference counted exist as long as another object uses them. Once the last reference to a reference counted object is removed, the object will spontaneously destruct.

Reference counting works only if the object is allocated dynamically with the New() static function, in all other cases trying to use Register/UnRegister simply throws an error. When allocated with New, the object should also be deallocated with Delete() or UnRegister().

Definition at line 34 of file albaReferenceCounted.h.

Constructor & Destructor Documentation

◆ albaReferenceCounted()

albaReferenceCounted::albaReferenceCounted ( )

◆ ~albaReferenceCounted()

virtual albaReferenceCounted::~albaReferenceCounted ( )
virtual

Member Function Documentation

◆ albaAbstractTypeMacro()

albaReferenceCounted::albaAbstractTypeMacro ( albaReferenceCounted  ,
albaObject   
)

◆ Delete()

virtual void albaReferenceCounted::Delete ( )
virtual

Delete a ALBA object.

This method should be used to delete an object when the New() method was used to create it. Using the C++ delete method will not work with reference counting. This is the same as UnRegister(NULL)

Reimplemented from albaObject.

◆ Register()

void albaReferenceCounted::Register ( void *  obj)

Increase the reference count (mark as used by another object).

◆ UnRegister()

virtual void albaReferenceCounted::UnRegister ( void *  obj)
virtual

Decrease the reference count (release by another object).

This has the same effect as invoking Delete() (i.e., it reduces the reference count by 1).

Reimplemented in albaVME.

◆ GetReferenceCount()

int albaReferenceCounted::GetReferenceCount ( )
inline

Return the current reference count of this object.

Definition at line 59 of file albaReferenceCounted.h.

◆ SetReferenceCount()

void albaReferenceCounted::SetReferenceCount ( int  )

Sets the reference count.

(This is very dangerous, use with care.)

Member Data Documentation

◆ m_ReferenceCount

int albaReferenceCounted::m_ReferenceCount
protected

Number of uses of this object by other objects.

Definition at line 65 of file albaReferenceCounted.h.


The documentation for this class was generated from the following file: