ZNC  trunk
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | List of all members
CSmartPtr< T > Class Template Reference

This is a standard reference counting pointer. Be careful not to have two of these point to the same raw pointer or one will be deleted while the other still thinks it is valid. More...

#include <Utils.h>

Public Member Functions

 CSmartPtr ()
 Standard constructor, points to nothing. More...
 
 CSmartPtr (T *pRawPtr)
 Attach to an existing raw pointer, be CAREFUL not to have more than one CSmartPtr attach to the same raw pointer or bad things will happen. More...
 
 CSmartPtr (const CSmartPtr< T > &CopyFrom)
 Copy constructor, will copy the raw pointer and counter locations and increment the reference counter. More...
 
 ~CSmartPtr ()
 Destructor will Release() the raw pointer and delete it if this was the last reference. More...
 
T & operator* () const
 
T * operator-> () const
 
CSmartPtr< T > & operator= (T *pRawPtr)
 Attach() to a raw pointer. More...
 
CSmartPtr< T > & operator= (const CSmartPtr< T > &CopyFrom)
 Copies an existing CSmartPtr adding another reference to the counter. More...
 
 operator bool () const
 Implicit type conversion to bool for things like if (!ptr) {} and if (ptr) {}. More...
 
bool IsNull () const
 Check to see if the underlying raw pointer is null. More...
 
CSmartPtr< T > & Attach (T *pRawPtr)
 Attach to a given raw pointer, it will Release() the current raw pointer and assign the new one. More...
 
void Release ()
 Releases the underlying raw pointer and cleans up if we were the last reference to said pointer. More...
 
T * GetPtr () const
 
unsigned int GetCount () const
 

Detailed Description

template<typename T>
class CSmartPtr< T >

This is a standard reference counting pointer. Be careful not to have two of these point to the same raw pointer or one will be deleted while the other still thinks it is valid.

Author
prozac proza.nosp@m.c@ro.nosp@m.ttenb.nosp@m.oy.c.nosp@m.om

Constructor & Destructor Documentation

template<typename T>
CSmartPtr< T >::CSmartPtr ( )
inline

Standard constructor, points to nothing.

template<typename T>
CSmartPtr< T >::CSmartPtr ( T *  pRawPtr)
inline

Attach to an existing raw pointer, be CAREFUL not to have more than one CSmartPtr attach to the same raw pointer or bad things will happen.

Parameters
pRawPtrThe raw pointer to attach to
template<typename T>
CSmartPtr< T >::CSmartPtr ( const CSmartPtr< T > &  CopyFrom)
inline

Copy constructor, will copy the raw pointer and counter locations and increment the reference counter.

Parameters
CopyFromA reference of another CSmartPtr to copy from
template<typename T>
CSmartPtr< T >::~CSmartPtr ( )
inline

Destructor will Release() the raw pointer and delete it if this was the last reference.

Member Function Documentation

template<typename T>
CSmartPtr<T>& CSmartPtr< T >::Attach ( T *  pRawPtr)
inline

Attach to a given raw pointer, it will Release() the current raw pointer and assign the new one.

Parameters
pRawPtrThe raw pointer to keep track of, ***WARNING*** Do NOT allow more than one CSmartPtr keep track of the same raw pointer
Returns
Reference to self

Referenced by CSmartPtr< CWebSession >::CSmartPtr(), and CSmartPtr< CWebSession >::operator=().

template<typename T>
unsigned int CSmartPtr< T >::GetCount ( ) const
inline
template<typename T>
T* CSmartPtr< T >::GetPtr ( ) const
inline

Referenced by operator==().

template<typename T>
bool CSmartPtr< T >::IsNull ( ) const
inline

Check to see if the underlying raw pointer is null.

Returns
Whether or not underlying raw pointer is null

Referenced by CSmartPtr< CWebSession >::operator bool(), and CSmartPtr< CWebSession >::operator=().

template<typename T>
CSmartPtr< T >::operator bool ( ) const
inline

Implicit type conversion to bool for things like if (!ptr) {} and if (ptr) {}.

Returns
See Also
IsNull()
template<typename T>
T& CSmartPtr< T >::operator* ( ) const
inline
template<typename T>
T* CSmartPtr< T >::operator-> ( ) const
inline
template<typename T>
CSmartPtr<T>& CSmartPtr< T >::operator= ( T *  pRawPtr)
inline

Attach() to a raw pointer.

Parameters
pRawPtrThe raw pointer to keep track of, ***WARNING*** Do NOT allow more than one CSmartPtr keep track of the same raw pointer
Returns
Reference to self
template<typename T>
CSmartPtr<T>& CSmartPtr< T >::operator= ( const CSmartPtr< T > &  CopyFrom)
inline

Copies an existing CSmartPtr adding another reference to the counter.

Parameters
CopyFromA reference to another CSmartPtr to be copied
Returns
Reference to self
template<typename T>
void CSmartPtr< T >::Release ( )
inline

Releases the underlying raw pointer and cleans up if we were the last reference to said pointer.

Referenced by CSmartPtr< CWebSession >::Attach(), CSmartPtr< CWebSession >::operator=(), and CSmartPtr< CWebSession >::~CSmartPtr().


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