Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
SharedPtr< T > Class Template Reference

Reference counting smart pointer. More...

Public Types

typedef T Type
 

Public Member Functions

 SharedPtr (T *p=0)
 
 ~SharedPtr ()
 
T & operator* () const
 
T * operator-> () const
 
T * get () const
 
 operator bool () const
 
void reset (T *p=0)
 

Private Member Functions

 SharedPtr (const SharedPtr &)
 
SharedPtroperator= (const SharedPtr &p)
 
void operator== (const SharedPtr &) const
 
void operator!= (const SharedPtr &) const
 

Private Attributes

T * m_ptr
 

Detailed Description

template<class T>
class SharedPtr< T >

Reference counting smart pointer.

Definition at line 96 of file context.cpp.

Member Typedef Documentation

template<class T>
typedef T SharedPtr< T >::Type

Definition at line 106 of file context.cpp.

Constructor & Destructor Documentation

template<class T>
SharedPtr< T >::SharedPtr ( const SharedPtr< T > &  )
private
template<class T>
SharedPtr< T >::SharedPtr ( T *  p = 0)
inlineexplicit

Definition at line 107 of file context.cpp.

107 : m_ptr(p) { if (m_ptr) m_ptr->addRef(); }
p
Definition: test.py:223
T * m_ptr
Definition: context.cpp:99
template<class T>
SharedPtr< T >::~SharedPtr ( )
inline

Definition at line 108 of file context.cpp.

108 { if (m_ptr) m_ptr->release(); };
T * m_ptr
Definition: context.cpp:99

Member Function Documentation

template<class T>
T* SharedPtr< T >::get ( ) const
inline

Definition at line 111 of file context.cpp.

111 { return m_ptr; }
T * m_ptr
Definition: context.cpp:99
template<class T>
SharedPtr< T >::operator bool ( ) const
inline

Definition at line 112 of file context.cpp.

112 { return m_ptr!=0; }
T * m_ptr
Definition: context.cpp:99
template<class T>
void SharedPtr< T >::operator!= ( const SharedPtr< T > &  ) const
private
template<class T>
T& SharedPtr< T >::operator* ( ) const
inline

Definition at line 109 of file context.cpp.

109 { return *m_ptr; }
T * m_ptr
Definition: context.cpp:99
template<class T>
T* SharedPtr< T >::operator-> ( ) const
inline

Definition at line 110 of file context.cpp.

110 { return m_ptr; }
T * m_ptr
Definition: context.cpp:99
template<class T>
SharedPtr& SharedPtr< T >::operator= ( const SharedPtr< T > &  p)
private
template<class T>
void SharedPtr< T >::operator== ( const SharedPtr< T > &  ) const
private
template<class T>
void SharedPtr< T >::reset ( T *  p = 0)
inline

Definition at line 113 of file context.cpp.

114  {
115  if (p) p->addRef();
116  if (m_ptr) m_ptr->release();
117  m_ptr = p;
118  }
p
Definition: test.py:223
T * m_ptr
Definition: context.cpp:99

Member Data Documentation

template<class T>
T* SharedPtr< T >::m_ptr
private

Definition at line 99 of file context.cpp.


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