RefCounted< P > Class Template Reference

#include <smart_ptr.h>

List of all members.

Public Types

enum  { destructiveCopy = false }

Public Member Functions

 RefCounted ()
 RefCounted (const RefCounted &rhs)
template<typename P1 >
 RefCounted (const RefCounted< P1 > &rhs)
Clone (const P &val)
bool Release (const P &)
void Swap (RefCounted &rhs)

Private Attributes

unsigned int * pCount_


Detailed Description

template<class P>
class RefCounted< P >

Definition at line 132 of file smart_ptr.h.


Member Enumeration Documentation

template<class P>
anonymous enum

Enumerator:
destructiveCopy 

Definition at line 171 of file smart_ptr.h.

00171 { destructiveCopy = false };


Constructor & Destructor Documentation

template<class P>
RefCounted< P >::RefCounted (  )  [inline]

Definition at line 135 of file smart_ptr.h.

00136         {
00137             pCount_ = new unsigned int;
00138             assert(pCount_);
00139             *pCount_ = 1;
00140         }

template<class P>
RefCounted< P >::RefCounted ( const RefCounted< P > &  rhs  )  [inline]

Definition at line 142 of file smart_ptr.h.

00143         : pCount_(rhs.pCount_)
00144         {}

template<class P>
template<typename P1 >
RefCounted< P >::RefCounted ( const RefCounted< P1 > &  rhs  )  [inline]

Definition at line 148 of file smart_ptr.h.

00149         : pCount_(reinterpret_cast<const RefCounted&>(rhs).pCount_)
00150         {}


Member Function Documentation

template<class P>
P RefCounted< P >::Clone ( const P &  val  )  [inline]

Definition at line 152 of file smart_ptr.h.

00153         {
00154             ++*pCount_;
00155             return val;
00156         }

template<class P>
bool RefCounted< P >::Release ( const P &   )  [inline]

Definition at line 158 of file smart_ptr.h.

00159         {
00160             if (!--*pCount_)
00161             {
00162                 delete pCount_;
00163                 return true;
00164             }
00165             return false;
00166         }

template<class P>
void RefCounted< P >::Swap ( RefCounted< P > &  rhs  )  [inline]

Definition at line 168 of file smart_ptr.h.

00169         { std::swap(pCount_, rhs.pCount_); }


Member Data Documentation

template<class P>
unsigned int* RefCounted< P >::pCount_ [private]

Definition at line 175 of file smart_ptr.h.


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

Generated on Tue Aug 30 02:37:00 2011 for Smacky by  doxygen 1.5.8