Public Member Functions | Private Member Functions | Private Attributes | Friends
Poco::SharedPtr< C, RC, RP > Class Template Reference

#include <SharedPtr.h>

List of all members.

Public Member Functions

SharedPtrassign (C *ptr)
SharedPtrassign (const SharedPtr &ptr)
template<class Other , class OtherRP >
SharedPtrassign (const SharedPtr< Other, RC, OtherRP > &ptr)
template<class Other >
SharedPtr< Other, RC, RP > cast () const
C * get ()
const C * get () const
bool isNull () const
 operator C * ()
 operator const C * () const
bool operator! () const
bool operator!= (const SharedPtr &ptr) const
bool operator!= (const C *ptr) const
bool operator!= (C *ptr) const
C & operator* ()
const C & operator* () const
C * operator-> ()
const C * operator-> () const
bool operator< (const SharedPtr &ptr) const
bool operator< (const C *ptr) const
bool operator< (C *ptr) const
bool operator<= (const SharedPtr &ptr) const
bool operator<= (const C *ptr) const
bool operator<= (C *ptr) const
SharedPtroperator= (C *ptr)
SharedPtroperator= (const SharedPtr &ptr)
template<class Other , class OtherRP >
SharedPtroperator= (const SharedPtr< Other, RC, OtherRP > &ptr)
bool operator== (const SharedPtr &ptr) const
bool operator== (const C *ptr) const
bool operator== (C *ptr) const
bool operator> (const SharedPtr &ptr) const
bool operator> (const C *ptr) const
bool operator> (C *ptr) const
bool operator>= (const SharedPtr &ptr) const
bool operator>= (const C *ptr) const
bool operator>= (C *ptr) const
int referenceCount () const
 SharedPtr ()
 SharedPtr (C *ptr)
template<class Other , class OtherRP >
 SharedPtr (const SharedPtr< Other, RC, OtherRP > &ptr)
 SharedPtr (const SharedPtr &ptr)
void swap (SharedPtr &ptr)
template<class Other >
SharedPtr< Other, RC, RP > unsafeCast () const
 ~SharedPtr ()

Private Member Functions

C * deref () const
void release ()
 SharedPtr (RC *pCounter, C *ptr)

Private Attributes

RC * _pCounter
C * _ptr

Friends

class SharedPtr

Detailed Description

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
class Poco::SharedPtr< C, RC, RP >

SharedPtr is a "smart" pointer for classes implementing reference counting based garbage collection. SharedPtr is thus similar to AutoPtr. Unlike the AutoPtr template, which can only be used with classes that support reference counting, SharedPtr can be used with any class. For this to work, a SharedPtr manages a reference count for the object it manages.

SharedPtr works in the following way: If an SharedPtr is assigned an ordinary pointer to an object (via the constructor or the assignment operator), it takes ownership of the object and the object's reference count is initialized to one. If the SharedPtr is assigned another SharedPtr, the object's reference count is incremented by one. The destructor of SharedPtr decrements the object's reference count by one and deletes the object if the reference count reaches zero. SharedPtr supports dereferencing with both the -> and the * operator. An attempt to dereference a null SharedPtr results in a NullPointerException being thrown. SharedPtr also implements all relational operators and a cast operator in case dynamic casting of the encapsulated data types is required.

Definition at line 96 of file SharedPtr.h.


Constructor & Destructor Documentation

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
Poco::SharedPtr< C, RC, RP >::SharedPtr ( ) [inline]

Definition at line 124 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
Poco::SharedPtr< C, RC, RP >::SharedPtr ( C *  ptr) [inline]

Definition at line 128 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
template<class Other , class OtherRP >
Poco::SharedPtr< C, RC, RP >::SharedPtr ( const SharedPtr< Other, RC, OtherRP > &  ptr) [inline]

Definition at line 133 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
Poco::SharedPtr< C, RC, RP >::SharedPtr ( const SharedPtr< C, RC, RP > &  ptr) [inline]

Definition at line 138 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
Poco::SharedPtr< C, RC, RP >::~SharedPtr ( ) [inline]

Definition at line 143 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
Poco::SharedPtr< C, RC, RP >::SharedPtr ( RC *  pCounter,
C *  ptr 
) [inline, private]

Definition at line 398 of file SharedPtr.h.


Member Function Documentation

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
SharedPtr& Poco::SharedPtr< C, RC, RP >::assign ( C *  ptr) [inline]

Definition at line 148 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
SharedPtr& Poco::SharedPtr< C, RC, RP >::assign ( const SharedPtr< C, RC, RP > &  ptr) [inline]

Definition at line 160 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
template<class Other , class OtherRP >
SharedPtr& Poco::SharedPtr< C, RC, RP >::assign ( const SharedPtr< Other, RC, OtherRP > &  ptr) [inline]

Definition at line 171 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
template<class Other >
SharedPtr<Other, RC, RP> Poco::SharedPtr< C, RC, RP >::cast ( ) const [inline]

Casts the SharedPtr via a dynamic cast to the given type. Returns an SharedPtr containing NULL if the cast fails. Example: (assume class Sub: public Super) SharedPtr<Super> super(new Sub()); SharedPtr<Sub> sub = super.cast<Sub>(); poco_assert (sub.get());

Definition at line 204 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
C* Poco::SharedPtr< C, RC, RP >::deref ( ) const [inline, private]

Definition at line 376 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
C* Poco::SharedPtr< C, RC, RP >::get ( ) [inline]

Definition at line 250 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
const C* Poco::SharedPtr< C, RC, RP >::get ( ) const [inline]

Definition at line 255 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
bool Poco::SharedPtr< C, RC, RP >::isNull ( ) const [inline]

Definition at line 275 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
Poco::SharedPtr< C, RC, RP >::operator C * ( ) [inline]

Definition at line 260 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
Poco::SharedPtr< C, RC, RP >::operator const C * ( ) const [inline]

Definition at line 265 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
bool Poco::SharedPtr< C, RC, RP >::operator! ( ) const [inline]

Definition at line 270 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
bool Poco::SharedPtr< C, RC, RP >::operator!= ( const SharedPtr< C, RC, RP > &  ptr) const [inline]

Definition at line 295 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
bool Poco::SharedPtr< C, RC, RP >::operator!= ( const C *  ptr) const [inline]

Definition at line 300 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
bool Poco::SharedPtr< C, RC, RP >::operator!= ( C *  ptr) const [inline]

Definition at line 305 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
C& Poco::SharedPtr< C, RC, RP >::operator* ( ) [inline]

Definition at line 240 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
const C& Poco::SharedPtr< C, RC, RP >::operator* ( ) const [inline]

Definition at line 245 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
C* Poco::SharedPtr< C, RC, RP >::operator-> ( ) [inline]

Definition at line 230 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
const C* Poco::SharedPtr< C, RC, RP >::operator-> ( ) const [inline]

Definition at line 235 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
bool Poco::SharedPtr< C, RC, RP >::operator< ( const SharedPtr< C, RC, RP > &  ptr) const [inline]

Definition at line 310 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
bool Poco::SharedPtr< C, RC, RP >::operator< ( const C *  ptr) const [inline]

Definition at line 315 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
bool Poco::SharedPtr< C, RC, RP >::operator< ( C *  ptr) const [inline]

Definition at line 320 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
bool Poco::SharedPtr< C, RC, RP >::operator<= ( const SharedPtr< C, RC, RP > &  ptr) const [inline]

Definition at line 325 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
bool Poco::SharedPtr< C, RC, RP >::operator<= ( const C *  ptr) const [inline]

Definition at line 330 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
bool Poco::SharedPtr< C, RC, RP >::operator<= ( C *  ptr) const [inline]

Definition at line 335 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
SharedPtr& Poco::SharedPtr< C, RC, RP >::operator= ( C *  ptr) [inline]

Definition at line 181 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
SharedPtr& Poco::SharedPtr< C, RC, RP >::operator= ( const SharedPtr< C, RC, RP > &  ptr) [inline]

Definition at line 186 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
template<class Other , class OtherRP >
SharedPtr& Poco::SharedPtr< C, RC, RP >::operator= ( const SharedPtr< Other, RC, OtherRP > &  ptr) [inline]

Definition at line 192 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
bool Poco::SharedPtr< C, RC, RP >::operator== ( const SharedPtr< C, RC, RP > &  ptr) const [inline]

Definition at line 280 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
bool Poco::SharedPtr< C, RC, RP >::operator== ( const C *  ptr) const [inline]

Definition at line 285 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
bool Poco::SharedPtr< C, RC, RP >::operator== ( C *  ptr) const [inline]

Definition at line 290 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
bool Poco::SharedPtr< C, RC, RP >::operator> ( const SharedPtr< C, RC, RP > &  ptr) const [inline]

Definition at line 340 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
bool Poco::SharedPtr< C, RC, RP >::operator> ( const C *  ptr) const [inline]

Definition at line 345 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
bool Poco::SharedPtr< C, RC, RP >::operator> ( C *  ptr) const [inline]

Definition at line 350 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
bool Poco::SharedPtr< C, RC, RP >::operator>= ( const SharedPtr< C, RC, RP > &  ptr) const [inline]

Definition at line 355 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
bool Poco::SharedPtr< C, RC, RP >::operator>= ( const C *  ptr) const [inline]

Definition at line 360 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
bool Poco::SharedPtr< C, RC, RP >::operator>= ( C *  ptr) const [inline]

Definition at line 365 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
int Poco::SharedPtr< C, RC, RP >::referenceCount ( ) const [inline]

Definition at line 370 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
void Poco::SharedPtr< C, RC, RP >::release ( ) [inline, private]

Definition at line 384 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
void Poco::SharedPtr< C, RC, RP >::swap ( SharedPtr< C, RC, RP > &  ptr) [inline]

Definition at line 197 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
template<class Other >
SharedPtr<Other, RC, RP> Poco::SharedPtr< C, RC, RP >::unsafeCast ( ) const [inline]

Casts the SharedPtr via a static cast to the given type. Example: (assume class Sub: public Super) SharedPtr<Super> super(new Sub()); SharedPtr<Sub> sub = super.unsafeCast<Sub>(); poco_assert (sub.get());

Definition at line 219 of file SharedPtr.h.


Friends And Related Function Documentation

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
friend class SharedPtr [friend]

Definition at line 409 of file SharedPtr.h.


Member Data Documentation

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
RC* Poco::SharedPtr< C, RC, RP >::_pCounter [private]

Definition at line 406 of file SharedPtr.h.

template<class C, class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
C* Poco::SharedPtr< C, RC, RP >::_ptr [private]

Definition at line 407 of file SharedPtr.h.


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


pluginlib
Author(s): Tully Foote and Eitan Marder-Eppstein
autogenerated on Sat Dec 28 2013 17:20:20