Main Page | Modules | Class Hierarchy | Class List | File List | Class Members | File Members

CountRef< T > Class Template Reference

#include <CountRef.h>

List of all members.

Public Member Functions

 CountRef (void *)
void use (void)
void release (void)

Public Attributes

void * ptr


Detailed Description

template<typename T>
class CountRef< T >

Class implementing simple reference counting mechanism.

This class is used instead of simple pointers to enable sharing of objects using simple reference counting mechanism. It encapsulates the given (pointer to) object and remembers the number of references to it. Taking and getting rid of the reference to encapsulated object is explicit by calling member functions use() and release().


Constructor & Destructor Documentation

template<typename T>
CountRef< T >::CountRef void *  p  ) 
 

Encapsulate the given object and set reference count to 1.


Member Function Documentation

template<typename T>
void CountRef< T >::release void   ) 
 

Decrease the reference count, possibly deallocating the encapsulated object.

This method should be called when the holder no longer plans to use the encapsulated object, instead of deleting it.

template<typename T>
void CountRef< T >::use void   ) 
 

Increase the number of references to the object.

This method should be called every time the pointer (ie. this instance) is copied.


Member Data Documentation

template<typename T>
void* CountRef< T >::ptr
 

Pointer to the encapsulated object.


The documentation for this class was generated from the following file:
Generated on Wed Jun 27 13:43:06 2007 for Glite LB Client: CPP - Interface by doxygen 1.3.5