Core Library
Public Member Functions | Private Member Functions | Private Attributes | Friends
Core::SharedPtr< T > Class Template Reference

A reference counted smart pointer. More...

#include <SharedPtr.hpp>

Inheritance diagram for Core::SharedPtr< T >:
Core::SmartPtr< T >

List of all members.

Public Member Functions

 SharedPtr ()
 Default constructor.
 SharedPtr (T *pPointer)
 Construction from a raw pointer.
 SharedPtr (const SharedPtr< T > &oPointer)
 Copy constructor.
template<typename U >
 SharedPtr (const SharedPtr< U > &oPointer)
 Copy constructor for sub-types of T.
 ~SharedPtr ()
 Destructor.
SharedPtroperator= (const SharedPtr &oPointer)
 Assignment operator.
template<typename U >
SharedPtroperator= (const SharedPtr< U > &oPointer)
 Assignment operator for sub-types of T.
void reset (T *pPointer=nullptr)
 Change pointer ownership.

Private Member Functions

 SharedPtr (T *pPointer, long *pRefCnt)
 Private constructor for use by cast functions.

Private Attributes

long * m_pRefCnt
 The pointer reference count.

Friends

class SharedPtr
 Allow member access for SharedPtrs of sub-types.
template<typename P , typename U >
SharedPtr< P > static_ptr_cast (const SharedPtr< U > &oPointer)
 Allow member access for the static_cast like function.
template<typename P , typename U >
SharedPtr< P > dynamic_ptr_cast (const SharedPtr< U > &oPointer)
 Allow member access for the dynamic_cast like function.

Detailed Description

template<typename T>
class Core::SharedPtr< T >

A reference counted smart pointer.


Constructor & Destructor Documentation

template<typename T >
Core::SharedPtr< T >::SharedPtr ( )

Default constructor.

template<typename T >
Core::SharedPtr< T >::SharedPtr ( T *  pPointer) [inline, explicit]

Construction from a raw pointer.

Takes ownership of a new pointer.

template<typename T >
Core::SharedPtr< T >::SharedPtr ( const SharedPtr< T > &  oPointer) [inline]

Copy constructor.

Takes shared ownership of another pointer.

template<typename T >
template<typename U >
Core::SharedPtr< T >::SharedPtr ( const SharedPtr< U > &  oPointer) [inline]

Copy constructor for sub-types of T.

Takes shared ownership of another pointer that must be a sub-type of T..

template<typename T >
Core::SharedPtr< T >::~SharedPtr ( ) [inline]

Destructor.

Frees the pointer if the last reference.

template<typename T >
Core::SharedPtr< T >::SharedPtr ( T *  pPointer,
long *  pRefCnt 
) [inline, private]

Private constructor for use by cast functions.


Member Function Documentation

template<typename T >
SharedPtr< T > & Core::SharedPtr< T >::operator= ( const SharedPtr< T > &  oPointer) [inline]

Assignment operator.

Frees the current pointer if the last reference and takes shared ownership of another pointer.

template<typename T >
template<typename U >
SharedPtr< T > & Core::SharedPtr< T >::operator= ( const SharedPtr< U > &  oPointer) [inline]

Assignment operator for sub-types of T.

Frees the current pointer if the last reference and takes shared ownership of another pointer that must be a sub-type of T.

template<typename T >
void Core::SharedPtr< T >::reset ( T *  pPointer = nullptr) [inline]

Change pointer ownership.

Frees the current pointer if the last reference and takes shared ownership of another pointer, if provided.


Friends And Related Function Documentation

template<typename T >
Core::SharedPtr< T >::SharedPtr [friend]

Allow member access for SharedPtrs of sub-types.

Default constructor.

Sets pointer and reference count to NULL.

template<typename T >
template<typename P , typename U >
SharedPtr<P> static_ptr_cast ( const SharedPtr< U > &  oPointer) [friend]

Allow member access for the static_cast like function.

template<typename T >
template<typename P , typename U >
SharedPtr<P> dynamic_ptr_cast ( const SharedPtr< U > &  oPointer) [friend]

Allow member access for the dynamic_cast like function.


Member Data Documentation

template<typename T >
long* Core::SharedPtr< T >::m_pRefCnt [private]

The pointer reference count.


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