Logo Search packages:      
Sourcecode: poco version File versions  Download package

Public Member Functions | Private Member Functions | Private Attributes | Friends

Poco::SharedPtr< C, RC, RP > Class Template Reference

#include <SharedPtr.h>

Inheritance diagram for Poco::SharedPtr< C, RC, RP >:
Inheritance graph
Collaboration diagram for Poco::SharedPtr< C, RC, RP >:
Collaboration graph

List of all members.

Public Member Functions

SharedPtrassign (C *ptr)
template<class Other , class OtherRP >
SharedPtrassign (const SharedPtr< Other, RC, OtherRP > &ptr)
SharedPtrassign (const SharedPtr &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
const C * operator-> () const
C * operator-> ()
bool operator< (const C *ptr) const
bool operator< (C *ptr) const
bool operator< (const SharedPtr &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== (C *ptr) const
bool operator== (const SharedPtr &ptr) const
bool operator== (const C *ptr) const
bool operator> (const C *ptr) const
bool operator> (C *ptr) const
bool operator> (const SharedPtr &ptr) const
bool operator>= (const SharedPtr &ptr) const
bool operator>= (const C *ptr) const
bool operator>= (C *ptr) const
int referenceCount () const
 SharedPtr (const SharedPtr &ptr)
template<class Other , class OtherRP >
 SharedPtr (const SharedPtr< Other, RC, OtherRP > &ptr)
 SharedPtr (C *ptr)
void swap (SharedPtr &ptr)
template<class Other >
SharedPtr< Other, RC, RP > unsafeCast () const

Private Member Functions

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

Private Attributes

RC * _pCounter
C * _ptr


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 110 of file SharedPtr.h.

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

Generated by  Doxygen 1.6.0   Back to index