refcount_ptr< T > Class Template Reference

Back to the index.

Public Member Functions | List of all members
refcount_ptr< T > Class Template Reference

A template class representing a reference counted pointer. More...

#include <refcount_ptr.h>

Public Member Functions

 refcount_ptr (T *p=NULL)
 
 ~refcount_ptr ()
 
 refcount_ptr (const refcount_ptr &other)
 
refcount_ptroperator= (const refcount_ptr &other)
 
 operator T* ()
 
T & operator* ()
 
T * operator-> ()
 
 operator const T * () const
 
const T & operator* () const
 
const T * operator-> () const
 
bool IsNULL () const
 Checks whether or not an object is referenced by the reference counted pointer. More...
 
bool operator< (const refcount_ptr &other) const
 Less-than operator, e.g. for sorting. More...
 
bool operator== (const refcount_ptr &other) const
 Equals operator. More...
 
bool operator!= (const refcount_ptr &other) const
 Not-Equals operator. More...
 

Detailed Description

template<class T>
class refcount_ptr< T >

A template class representing a reference counted pointer.

Basically, when a pointer assigned to the reference counted pointer, it increases the reference count of the pointed-to object. When the reference counted pointer is destroyed (or NULL is assigned to it), it decreases the reference count of the pointed-to object. If the reference count reaches zero, the object is deleted.

Definition at line 33 of file refcount_ptr.h.

Constructor & Destructor Documentation

◆ refcount_ptr() [1/2]

template<class T >
refcount_ptr< T >::refcount_ptr ( T *  p = NULL)
inline

Constructor for a reference counted pointer.

Parameters
pPointer to an object; default is NULL.

Definition at line 129 of file refcount_ptr.h.

◆ ~refcount_ptr()

template<class T >
refcount_ptr< T >::~refcount_ptr ( )
inline

The destructor causes the reference count to be decreased by one. If the reference count of the object reaches zero, it is deleted (freed).

Definition at line 141 of file refcount_ptr.h.

◆ refcount_ptr() [2/2]

template<class T >
refcount_ptr< T >::refcount_ptr ( const refcount_ptr< T > &  other)
inline

Copy constructor, which causes the reference count of the pointed-to object to be increased.

Parameters
otherThe reference counted pointer to copy from.

Definition at line 152 of file refcount_ptr.h.

Member Function Documentation

◆ IsNULL()

template<class T >
bool refcount_ptr< T >::IsNULL ( ) const
inline

◆ operator const T *()

template<class T >
refcount_ptr< T >::operator const T * ( ) const
inline

Definition at line 194 of file refcount_ptr.h.

◆ operator T*()

template<class T >
refcount_ptr< T >::operator T* ( )
inline

Definition at line 179 of file refcount_ptr.h.

◆ operator!=()

template<class T >
bool refcount_ptr< T >::operator!= ( const refcount_ptr< T > &  other) const
inline

Not-Equals operator.

Parameters
otherThe reference counted pointer to compare this object to.
Returns
true if the pointed to objects have different address, false otherwise.

Definition at line 256 of file refcount_ptr.h.

◆ operator*() [1/2]

template<class T >
T& refcount_ptr< T >::operator* ( )
inline

Definition at line 184 of file refcount_ptr.h.

◆ operator*() [2/2]

template<class T >
const T& refcount_ptr< T >::operator* ( ) const
inline

Definition at line 199 of file refcount_ptr.h.

◆ operator->() [1/2]

template<class T >
T* refcount_ptr< T >::operator-> ( )
inline

Definition at line 189 of file refcount_ptr.h.

◆ operator->() [2/2]

template<class T >
const T* refcount_ptr< T >::operator-> ( ) const
inline

Definition at line 204 of file refcount_ptr.h.

◆ operator<()

template<class T >
bool refcount_ptr< T >::operator< ( const refcount_ptr< T > &  other) const
inline

Less-than operator, e.g. for sorting.

Parameters
otherThe reference counted pointer to compare this object to.
Returns
true if the plain pointer of this object is less than the plain pointer of the other object.

Definition at line 229 of file refcount_ptr.h.

◆ operator=()

template<class T >
refcount_ptr& refcount_ptr< T >::operator= ( const refcount_ptr< T > &  other)
inline

Assignment operator. If an object is already referenced, it is released (i.e. its reference is decreased, and if it is zero, it is freed). The object referenced to by the other reference counted pointer then gets its reference count increased.

Parameters
otherThe reference counted pointer to assign from.

Definition at line 168 of file refcount_ptr.h.

◆ operator==()

template<class T >
bool refcount_ptr< T >::operator== ( const refcount_ptr< T > &  other) const
inline

Equals operator.

Parameters
otherThe reference counted pointer to compare this object to.
Returns
true if the pointed to objects have the same address, false otherwise.

Definition at line 243 of file refcount_ptr.h.


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

Generated on Tue Mar 24 2020 14:04:48 for GXemul by doxygen 1.8.17