#include <SharedPtr.h>
Public Member Functions | |
template<class Other , class OtherRP > | |
SharedPtr & | assign (const SharedPtr< Other, RC, OtherRP > &ptr) |
SharedPtr & | assign (const SharedPtr &ptr) |
SharedPtr & | assign (C *ptr) |
template<class Other > | |
SharedPtr< Other, RC, RP > | cast () const |
const C * | get () const |
C * | get () |
bool | isNull () const |
operator C * () | |
operator const C * () const | |
bool | operator! () const |
bool | operator!= (C *ptr) const |
bool | operator!= (const C *ptr) const |
bool | operator!= (const SharedPtr &ptr) const |
const C & | operator* () const |
C & | operator* () |
const C * | operator-> () const |
C * | operator-> () |
bool | operator< (C *ptr) const |
bool | operator< (const C *ptr) const |
bool | operator< (const SharedPtr &ptr) const |
bool | operator<= (C *ptr) const |
bool | operator<= (const C *ptr) const |
bool | operator<= (const SharedPtr &ptr) const |
template<class Other , class OtherRP > | |
SharedPtr & | operator= (const SharedPtr< Other, RC, OtherRP > &ptr) |
SharedPtr & | operator= (const SharedPtr &ptr) |
SharedPtr & | operator= (C *ptr) |
bool | operator== (C *ptr) const |
bool | operator== (const C *ptr) const |
bool | operator== (const SharedPtr &ptr) const |
bool | operator> (C *ptr) const |
bool | operator> (const C *ptr) const |
bool | operator> (const SharedPtr &ptr) const |
bool | operator>= (C *ptr) const |
bool | operator>= (const C *ptr) const |
bool | operator>= (const SharedPtr &ptr) const |
int | referenceCount () const |
SharedPtr (const SharedPtr &ptr) | |
template<class Other , class OtherRP > | |
SharedPtr (const SharedPtr< Other, RC, OtherRP > &ptr) | |
SharedPtr (C *ptr) | |
SharedPtr () | |
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 |
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.
Poco::SharedPtr< C, RC, RP >::SharedPtr | ( | ) | [inline] |
Definition at line 124 of file SharedPtr.h.
Poco::SharedPtr< C, RC, RP >::SharedPtr | ( | C * | ptr | ) | [inline] |
Definition at line 128 of file SharedPtr.h.
Poco::SharedPtr< C, RC, RP >::SharedPtr | ( | const SharedPtr< Other, RC, OtherRP > & | ptr | ) | [inline] |
Definition at line 133 of file SharedPtr.h.
Poco::SharedPtr< C, RC, RP >::SharedPtr | ( | const SharedPtr< C, RC, RP > & | ptr | ) | [inline] |
Definition at line 138 of file SharedPtr.h.
Poco::SharedPtr< C, RC, RP >::~SharedPtr | ( | ) | [inline] |
Definition at line 143 of file SharedPtr.h.
Poco::SharedPtr< C, RC, RP >::SharedPtr | ( | RC * | pCounter, | |
C * | ptr | |||
) | [inline, private] |
Definition at line 398 of file SharedPtr.h.
SharedPtr& Poco::SharedPtr< C, RC, RP >::assign | ( | const SharedPtr< Other, RC, OtherRP > & | ptr | ) | [inline] |
Definition at line 171 of file SharedPtr.h.
SharedPtr& Poco::SharedPtr< C, RC, RP >::assign | ( | const SharedPtr< C, RC, RP > & | ptr | ) | [inline] |
Definition at line 160 of file SharedPtr.h.
SharedPtr& Poco::SharedPtr< C, RC, RP >::assign | ( | C * | ptr | ) | [inline] |
Definition at line 148 of file SharedPtr.h.
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.
C* Poco::SharedPtr< C, RC, RP >::deref | ( | ) | const [inline, private] |
Definition at line 376 of file SharedPtr.h.
const C* Poco::SharedPtr< C, RC, RP >::get | ( | ) | const [inline] |
Definition at line 255 of file SharedPtr.h.
C* Poco::SharedPtr< C, RC, RP >::get | ( | ) | [inline] |
Definition at line 250 of file SharedPtr.h.
bool Poco::SharedPtr< C, RC, RP >::isNull | ( | ) | const [inline] |
Definition at line 275 of file SharedPtr.h.
Poco::SharedPtr< C, RC, RP >::operator C * | ( | ) | [inline] |
Definition at line 260 of file SharedPtr.h.
Poco::SharedPtr< C, RC, RP >::operator const C * | ( | ) | const [inline] |
Definition at line 265 of file SharedPtr.h.
bool Poco::SharedPtr< C, RC, RP >::operator! | ( | ) | const [inline] |
Definition at line 270 of file SharedPtr.h.
bool Poco::SharedPtr< C, RC, RP >::operator!= | ( | C * | ptr | ) | const [inline] |
Definition at line 305 of file SharedPtr.h.
bool Poco::SharedPtr< C, RC, RP >::operator!= | ( | const C * | ptr | ) | const [inline] |
Definition at line 300 of file SharedPtr.h.
bool Poco::SharedPtr< C, RC, RP >::operator!= | ( | const SharedPtr< C, RC, RP > & | ptr | ) | const [inline] |
Definition at line 295 of file SharedPtr.h.
const C& Poco::SharedPtr< C, RC, RP >::operator* | ( | ) | const [inline] |
Definition at line 245 of file SharedPtr.h.
C& Poco::SharedPtr< C, RC, RP >::operator* | ( | ) | [inline] |
Definition at line 240 of file SharedPtr.h.
const C* Poco::SharedPtr< C, RC, RP >::operator-> | ( | ) | const [inline] |
Definition at line 235 of file SharedPtr.h.
C* Poco::SharedPtr< C, RC, RP >::operator-> | ( | ) | [inline] |
Definition at line 230 of file SharedPtr.h.
bool Poco::SharedPtr< C, RC, RP >::operator< | ( | C * | ptr | ) | const [inline] |
Definition at line 320 of file SharedPtr.h.
bool Poco::SharedPtr< C, RC, RP >::operator< | ( | const C * | ptr | ) | const [inline] |
Definition at line 315 of file SharedPtr.h.
bool Poco::SharedPtr< C, RC, RP >::operator< | ( | const SharedPtr< C, RC, RP > & | ptr | ) | const [inline] |
Definition at line 310 of file SharedPtr.h.
bool Poco::SharedPtr< C, RC, RP >::operator<= | ( | C * | ptr | ) | const [inline] |
Definition at line 335 of file SharedPtr.h.
bool Poco::SharedPtr< C, RC, RP >::operator<= | ( | const C * | ptr | ) | const [inline] |
Definition at line 330 of file SharedPtr.h.
bool Poco::SharedPtr< C, RC, RP >::operator<= | ( | const SharedPtr< C, RC, RP > & | ptr | ) | const [inline] |
Definition at line 325 of file SharedPtr.h.
SharedPtr& Poco::SharedPtr< C, RC, RP >::operator= | ( | const SharedPtr< Other, RC, OtherRP > & | ptr | ) | [inline] |
Definition at line 192 of file SharedPtr.h.
SharedPtr& Poco::SharedPtr< C, RC, RP >::operator= | ( | const SharedPtr< C, RC, RP > & | ptr | ) | [inline] |
Definition at line 186 of file SharedPtr.h.
SharedPtr& Poco::SharedPtr< C, RC, RP >::operator= | ( | C * | ptr | ) | [inline] |
Definition at line 181 of file SharedPtr.h.
bool Poco::SharedPtr< C, RC, RP >::operator== | ( | C * | ptr | ) | const [inline] |
Definition at line 290 of file SharedPtr.h.
bool Poco::SharedPtr< C, RC, RP >::operator== | ( | const C * | ptr | ) | const [inline] |
Definition at line 285 of file SharedPtr.h.
bool Poco::SharedPtr< C, RC, RP >::operator== | ( | const SharedPtr< C, RC, RP > & | ptr | ) | const [inline] |
Definition at line 280 of file SharedPtr.h.
bool Poco::SharedPtr< C, RC, RP >::operator> | ( | C * | ptr | ) | const [inline] |
Definition at line 350 of file SharedPtr.h.
bool Poco::SharedPtr< C, RC, RP >::operator> | ( | const C * | ptr | ) | const [inline] |
Definition at line 345 of file SharedPtr.h.
bool Poco::SharedPtr< C, RC, RP >::operator> | ( | const SharedPtr< C, RC, RP > & | ptr | ) | const [inline] |
Definition at line 340 of file SharedPtr.h.
bool Poco::SharedPtr< C, RC, RP >::operator>= | ( | C * | ptr | ) | const [inline] |
Definition at line 365 of file SharedPtr.h.
bool Poco::SharedPtr< C, RC, RP >::operator>= | ( | const C * | ptr | ) | const [inline] |
Definition at line 360 of file SharedPtr.h.
bool Poco::SharedPtr< C, RC, RP >::operator>= | ( | const SharedPtr< C, RC, RP > & | ptr | ) | const [inline] |
Definition at line 355 of file SharedPtr.h.
int Poco::SharedPtr< C, RC, RP >::referenceCount | ( | ) | const [inline] |
Definition at line 370 of file SharedPtr.h.
void Poco::SharedPtr< C, RC, RP >::release | ( | ) | [inline, private] |
Definition at line 384 of file SharedPtr.h.
void Poco::SharedPtr< C, RC, RP >::swap | ( | SharedPtr< C, RC, RP > & | ptr | ) | [inline] |
Definition at line 197 of file SharedPtr.h.
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.
friend class SharedPtr [friend] |
Definition at line 409 of file SharedPtr.h.
RC* Poco::SharedPtr< C, RC, RP >::_pCounter [private] |
Definition at line 406 of file SharedPtr.h.
C* Poco::SharedPtr< C, RC, RP >::_ptr [private] |
Definition at line 407 of file SharedPtr.h.