Ark Server API (ASE) - Wiki
Loading...
Searching...
No Matches
Poco::SharedPtr< C, RC, RP > Class Template Reference

#include <SharedPtr.h>

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

Public Types

typedef C Type
 

Public Member Functions

 SharedPtr ()
 
 SharedPtr (C *ptr)
 
template<class Other , class OtherRP >
 SharedPtr (const SharedPtr< Other, RC, OtherRP > &ptr)
 
 SharedPtr (const SharedPtr &ptr)
 
 SharedPtr (SharedPtr &&ptr) noexcept
 
 ~SharedPtr ()
 
SharedPtrassign (C *ptr)
 
SharedPtrassign (const SharedPtr &ptr)
 
template<class Other , class OtherRP >
SharedPtrassign (const SharedPtr< Other, RC, OtherRP > &ptr)
 
void reset ()
 
void reset (C *ptr)
 
void reset (const SharedPtr &ptr)
 
template<class Other , class OtherRP >
void reset (const SharedPtr< Other, RC, OtherRP > &ptr)
 
SharedPtroperator= (C *ptr)
 
SharedPtroperator= (const SharedPtr &ptr)
 
SharedPtroperator= (SharedPtr &&ptr) noexcept
 
template<class Other , class OtherRP >
SharedPtroperator= (const SharedPtr< Other, RC, OtherRP > &ptr)
 
void swap (SharedPtr &ptr)
 
template<class Other >
SharedPtr< Other, RC, RP > cast () const
 
template<class Other >
SharedPtr< Other, RC, RP > unsafeCast () const
 
C * operator-> ()
 
const C * operator-> () const
 
C & operator* ()
 
const C & operator* () const
 
C * get ()
 
const C * get () const
 
 operator C* ()
 
 operator const C * () const
 
bool operator! () const
 
bool isNull () const
 
bool operator== (const SharedPtr &ptr) const
 
bool operator== (const C *ptr) const
 
bool operator== (C *ptr) const
 
bool operator== (std::nullptr_t ptr) const
 
bool operator!= (const SharedPtr &ptr) const
 
bool operator!= (const C *ptr) const
 
bool operator!= (C *ptr) const
 
bool operator!= (std::nullptr_t 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
 
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
 

Private Member Functions

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

Private Attributes

RC * _pCounter
 
C * _ptr
 

Friends

template<class OtherC , class OtherRC , class OtherRP >
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 89 of file SharedPtr.h.

Member Typedef Documentation

◆ Type

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

Definition at line 117 of file SharedPtr.h.

Constructor & Destructor Documentation

◆ SharedPtr() [1/6]

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

Definition at line 119 of file SharedPtr.h.

◆ SharedPtr() [2/6]

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

Definition at line 125 of file SharedPtr.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SharedPtr() [3/6]

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

◆ SharedPtr() [4/6]

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

◆ SharedPtr() [5/6]

template<class C , class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
Poco::SharedPtr< C, RC, RP >::SharedPtr ( SharedPtr< C, RC, RP > && ptr)
inlinenoexcept

Definition at line 151 of file SharedPtr.h.

◆ ~SharedPtr()

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

Definition at line 159 of file SharedPtr.h.

+ Here is the call graph for this function:

◆ SharedPtr() [6/6]

template<class C , class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
Poco::SharedPtr< C, RC, RP >::SharedPtr ( RC * pCounter,
C * ptr )
inlineprivate

Definition at line 451 of file SharedPtr.h.

Member Function Documentation

◆ assign() [1/3]

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

Definition at line 164 of file SharedPtr.h.

◆ assign() [2/3]

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

◆ assign() [3/3]

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

◆ cast()

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

◆ deref()

template<class C , class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
C * Poco::SharedPtr< C, RC, RP >::deref ( ) const
inlineprivate

Definition at line 431 of file SharedPtr.h.

◆ get() [1/2]

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

Definition at line 295 of file SharedPtr.h.

◆ get() [2/2]

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

Definition at line 300 of file SharedPtr.h.

◆ isNull()

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

Definition at line 320 of file SharedPtr.h.

◆ operator C*()

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

Definition at line 305 of file SharedPtr.h.

◆ operator const C *()

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

Definition at line 310 of file SharedPtr.h.

◆ operator!()

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

Definition at line 315 of file SharedPtr.h.

◆ operator!=() [1/4]

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

Definition at line 355 of file SharedPtr.h.

◆ operator!=() [2/4]

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

◆ operator!=() [3/4]

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

◆ operator!=() [4/4]

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

Definition at line 360 of file SharedPtr.h.

◆ operator*() [1/2]

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

Definition at line 285 of file SharedPtr.h.

◆ operator*() [2/2]

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

Definition at line 290 of file SharedPtr.h.

◆ operator->() [1/2]

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

Definition at line 275 of file SharedPtr.h.

◆ operator->() [2/2]

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

Definition at line 280 of file SharedPtr.h.

◆ operator<() [1/3]

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

Definition at line 375 of file SharedPtr.h.

◆ operator<() [2/3]

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

◆ operator<() [3/3]

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

◆ operator<=() [1/3]

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

Definition at line 390 of file SharedPtr.h.

◆ operator<=() [2/3]

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

◆ operator<=() [3/3]

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

◆ operator=() [1/4]

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

Definition at line 216 of file SharedPtr.h.

◆ operator=() [2/4]

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

◆ operator=() [3/4]

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

◆ operator=() [4/4]

template<class C , class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
SharedPtr & Poco::SharedPtr< C, RC, RP >::operator= ( SharedPtr< C, RC, RP > && ptr)
inlinenoexcept

Definition at line 226 of file SharedPtr.h.

◆ operator==() [1/4]

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.

◆ operator==() [2/4]

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.

◆ operator==() [3/4]

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.

◆ operator==() [4/4]

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

Definition at line 340 of file SharedPtr.h.

◆ operator>() [1/3]

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

Definition at line 405 of file SharedPtr.h.

◆ operator>() [2/3]

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

◆ operator>() [3/3]

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

◆ operator>=() [1/3]

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

Definition at line 420 of file SharedPtr.h.

◆ operator>=() [2/3]

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

◆ operator>=() [3/3]

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

◆ referenceCount()

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

Definition at line 425 of file SharedPtr.h.

◆ release()

template<class C , class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
void Poco::SharedPtr< C, RC, RP >::release ( )
inlineprivatenoexcept

Definition at line 439 of file SharedPtr.h.

+ Here is the caller graph for this function:

◆ reset() [1/4]

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

Definition at line 195 of file SharedPtr.h.

◆ reset() [2/4]

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

Definition at line 200 of file SharedPtr.h.

◆ reset() [3/4]

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

Definition at line 205 of file SharedPtr.h.

◆ reset() [4/4]

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

Definition at line 211 of file SharedPtr.h.

◆ swap()

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

◆ unsafeCast()

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

Friends And Related Symbol Documentation

◆ SharedPtr

template<class C , class RC = ReferenceCounter, class RP = ReleasePolicy<C>>
template<class OtherC , class OtherRC , class OtherRP >
friend class SharedPtr
friend

Definition at line 462 of file SharedPtr.h.

Member Data Documentation

◆ _pCounter

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

Definition at line 459 of file SharedPtr.h.

◆ _ptr

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

Definition at line 460 of file SharedPtr.h.


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