|
Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members File Members
EkRefCount Class Template ReferenceThis provides the smart point reference counting functionality.
More...
#include <EkRefCount.h>
Inheritance diagram for EkRefCount: [legend]Collaboration diagram for EkRefCount:[legend]List of all members.
Detailed Description
template<class mutex_type>
class EkRefCount< mutex_type >
This provides the smart point reference counting functionality.
The smart pointer implementation (EkSmartPtr) is built on the notion of reference counting objects. This means that when someone new starts to point at an object they increment a use count variable in the object they are pointing at. When they cease to point at that object they decrement the use count variable. If the use count variable ever goes to zero the object should be deleted as it is no-longer being referenced by anyone.
Therefore, any class instance that is to be accessed through a smart pointer must support reference counting. The easiest way to obtain reference counting support is to have the class inherit from the EkRefCount class. In the present implementation, each instance of EkRefCount has its own mutex guard.
Usage:
Constructor & Destructor Documentation
template<class mutex_type> |
EkRefCount< mutex_type >::EkRefCount |
( |
void |
|
) |
[inline] |
|
|
Constructor simply sets useCount to zero.
|
template<class mutex_type> |
EkRefCount< mutex_type >::~EkRefCount |
( |
void |
|
) |
[inline] |
|
|
Destructor. Does not throw an error if mUseCount != 0. See also, VEkRefCount.
|
template<class mutex_type> |
EkRefCount< mutex_type >::EkRefCount |
( |
const EkRefCount< mutex_type > & |
obj |
) |
[inline] |
|
|
Copy constructor, does NOT copy useCount.
|
Member Function Documentation
template<class mutex_type> |
void EkRefCount< mutex_type >::addRef |
( |
void |
|
) |
[inline] |
|
|
Increment useCount by one.
|
template<class mutex_type> |
bool EkRefCount< mutex_type >::deleteRef |
( |
void |
|
) |
[inline] |
|
|
Decrements useCount by one, returns true if the object should be deleted.
|
template<class mutex_type> |
EkRefCount< mutex_type > & EkRefCount< mutex_type >::operator= |
( |
const EkRefCount< mutex_type > & |
obj |
) |
[inline] |
|
|
Assignment operator, does NOT copy useCount.
|
template<class mutex_type> |
long EkRefCount< mutex_type >::useCount |
( |
|
) |
const [inline] |
|
|
This returns the useCount.
|
The documentation for this class was generated from the following file:
|