ARC SDK
Data Structures | Public Member Functions
Arc::CountedPointer< T > Class Template Reference

Wrapper for pointer with automatic destruction and multiple references. More...

#include <arc/Utils.h>

Public Member Functions

 CountedPointer (T *p=NULL)
 
 CountedPointer (const CountedPointer< T > &p)
 
CountedPointer< T > & operator= (T *p)
 
CountedPointer< T > & operator= (const CountedPointer< T > &p)
 
T & operator* (void) const
 For referring wrapped object. More...
 
T * operator-> (void) const
 For referring wrapped object. More...
 
 operator bool (void) const
 Returns false if pointer is NULL and true otherwise. More...
 
bool operator! (void) const
 Returns true if pointer is NULL and false otherwise. More...
 
bool operator== (const CountedPointer &p) const
 Returns true if pointers are equal. More...
 
bool operator!= (const CountedPointer &p) const
 Returns true if pointers are not equal. More...
 
bool operator< (const CountedPointer &p) const
 Comparison operator. More...
 
T * Ptr (void) const
 Cast to original pointer. More...
 
T * Release (void)
 Release referred object so that it can be passed to other container. More...
 

Detailed Description

template<typename T>
class Arc::CountedPointer< T >

Wrapper for pointer with automatic destruction and multiple references.

If ordinary pointer is wrapped in instance of this class it will be automatically destroyed when all instances referring to it are destroyed. This is useful for maintaining pointers referred from multiple structures with automatic destruction of original object when last reference is destroyed. It is similar to Java approach with a difference that destruction time is strictly defined. Only pointers returned by new() are supported. This class is not thread-safe.


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