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

#include <AutoPtr.h>

Public Member Functions

 AutoPtr ()
 
 AutoPtr (C *ptr)
 
 AutoPtr (C *ptr, bool shared)
 
 AutoPtr (const AutoPtr &ptr)
 
 AutoPtr (AutoPtr &&ptr) noexcept
 
template<class Other >
 AutoPtr (const AutoPtr< Other > &ptr)
 
 ~AutoPtr ()
 
AutoPtrassign (C *ptr)
 
AutoPtrassign (C *ptr, bool shared)
 
AutoPtrassign (const AutoPtr &ptr)
 
template<class Other >
AutoPtrassign (const AutoPtr< Other > &ptr)
 
void reset ()
 
void reset (C *ptr)
 
void reset (C *ptr, bool shared)
 
void reset (const AutoPtr &ptr)
 
template<class Other >
void reset (const AutoPtr< Other > &ptr)
 
AutoPtroperator= (C *ptr)
 
AutoPtroperator= (const AutoPtr &ptr)
 
AutoPtroperator= (AutoPtr &&ptr) noexcept
 
template<class Other >
AutoPtroperator= (const AutoPtr< Other > &ptr)
 
void swap (AutoPtr &ptr)
 
template<class Other >
AutoPtr< Other > cast () const
 
template<class Other >
AutoPtr< Other > 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
 
C * duplicate ()
 
bool operator== (const AutoPtr &ptr) const
 
bool operator== (const C *ptr) const
 
bool operator== (C *ptr) const
 
bool operator== (std::nullptr_t ptr) const
 
bool operator!= (const AutoPtr &ptr) const
 
bool operator!= (const C *ptr) const
 
bool operator!= (C *ptr) const
 
bool operator!= (std::nullptr_t ptr) const
 
bool operator< (const AutoPtr &ptr) const
 
bool operator< (const C *ptr) const
 
bool operator< (C *ptr) const
 
bool operator<= (const AutoPtr &ptr) const
 
bool operator<= (const C *ptr) const
 
bool operator<= (C *ptr) const
 
bool operator> (const AutoPtr &ptr) const
 
bool operator> (const C *ptr) const
 
bool operator> (C *ptr) const
 
bool operator>= (const AutoPtr &ptr) const
 
bool operator>= (const C *ptr) const
 
bool operator>= (C *ptr) const
 

Private Attributes

C * _ptr
 

Detailed Description

template<class C>
class Poco::AutoPtr< C >

AutoPtr is a "smart" pointer for classes implementing reference counting based garbage collection. To be usable with the AutoPtr template, a class must implement the following behaviour: A class must maintain a reference count. The constructors of the object initialize the reference count to one. The class must implement a public duplicate() method: void duplicate(); that increments the reference count by one. The class must implement a public release() method: void release() that decrements the reference count by one, and, if the reference count reaches zero, deletes the object.

AutoPtr works in the following way: If an AutoPtr 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 remains unchanged. If the AutoPtr is assigned another AutoPtr, the object's reference count is incremented by one by calling duplicate() on its object. The destructor of AutoPtr calls release() on its object. AutoPtr supports dereferencing with both the -> and the * operator. An attempt to dereference a null AutoPtr results in a NullPointerException being thrown. AutoPtr also implements all relational operators. Note that AutoPtr allows casting of its encapsulated data types.

Definition at line 31 of file AutoPtr.h.

Constructor & Destructor Documentation

◆ AutoPtr() [1/6]

template<class C >
Poco::AutoPtr< C >::AutoPtr ( )
inline

Definition at line 65 of file AutoPtr.h.

◆ AutoPtr() [2/6]

template<class C >
Poco::AutoPtr< C >::AutoPtr ( C * ptr)
inline

Definition at line 69 of file AutoPtr.h.

◆ AutoPtr() [3/6]

template<class C >
Poco::AutoPtr< C >::AutoPtr ( C * ptr,
bool shared )
inline

Definition at line 73 of file AutoPtr.h.

◆ AutoPtr() [4/6]

template<class C >
Poco::AutoPtr< C >::AutoPtr ( const AutoPtr< C > & ptr)
inline

Definition at line 78 of file AutoPtr.h.

◆ AutoPtr() [5/6]

template<class C >
Poco::AutoPtr< C >::AutoPtr ( AutoPtr< C > && ptr)
inlinenoexcept

Definition at line 83 of file AutoPtr.h.

◆ AutoPtr() [6/6]

template<class C >
template<class Other >
Poco::AutoPtr< C >::AutoPtr ( const AutoPtr< Other > & ptr)
inline

Definition at line 89 of file AutoPtr.h.

◆ ~AutoPtr()

template<class C >
Poco::AutoPtr< C >::~AutoPtr ( )
inline

Definition at line 94 of file AutoPtr.h.

Member Function Documentation

◆ assign() [1/4]

template<class C >
AutoPtr & Poco::AutoPtr< C >::assign ( C * ptr)
inline

Definition at line 99 of file AutoPtr.h.

◆ assign() [2/4]

template<class C >
AutoPtr & Poco::AutoPtr< C >::assign ( C * ptr,
bool shared )
inline

Definition at line 109 of file AutoPtr.h.

◆ assign() [3/4]

template<class C >
AutoPtr & Poco::AutoPtr< C >::assign ( const AutoPtr< C > & ptr)
inline

Definition at line 120 of file AutoPtr.h.

◆ assign() [4/4]

template<class C >
template<class Other >
AutoPtr & Poco::AutoPtr< C >::assign ( const AutoPtr< Other > & ptr)
inline

Definition at line 132 of file AutoPtr.h.

◆ cast()

template<class C >
template<class Other >
AutoPtr< Other > Poco::AutoPtr< C >::cast ( ) const
inline

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

Definition at line 203 of file AutoPtr.h.

◆ duplicate()

template<class C >
C * Poco::AutoPtr< C >::duplicate ( )
inline

Definition at line 289 of file AutoPtr.h.

◆ get() [1/2]

template<class C >
C * Poco::AutoPtr< C >::get ( )
inline

Definition at line 259 of file AutoPtr.h.

◆ get() [2/2]

template<class C >
const C * Poco::AutoPtr< C >::get ( ) const
inline

Definition at line 264 of file AutoPtr.h.

◆ isNull()

template<class C >
bool Poco::AutoPtr< C >::isNull ( ) const
inline

Definition at line 284 of file AutoPtr.h.

◆ operator C*()

template<class C >
Poco::AutoPtr< C >::operator C* ( )
inline

Definition at line 269 of file AutoPtr.h.

◆ operator const C *()

template<class C >
Poco::AutoPtr< C >::operator const C * ( ) const
inline

Definition at line 274 of file AutoPtr.h.

◆ operator!()

template<class C >
bool Poco::AutoPtr< C >::operator! ( ) const
inline

Definition at line 279 of file AutoPtr.h.

◆ operator!=() [1/4]

template<class C >
bool Poco::AutoPtr< C >::operator!= ( C * ptr) const
inline

Definition at line 325 of file AutoPtr.h.

◆ operator!=() [2/4]

template<class C >
bool Poco::AutoPtr< C >::operator!= ( const AutoPtr< C > & ptr) const
inline

Definition at line 315 of file AutoPtr.h.

◆ operator!=() [3/4]

template<class C >
bool Poco::AutoPtr< C >::operator!= ( const C * ptr) const
inline

Definition at line 320 of file AutoPtr.h.

◆ operator!=() [4/4]

template<class C >
bool Poco::AutoPtr< C >::operator!= ( std::nullptr_t ptr) const
inline

Definition at line 330 of file AutoPtr.h.

◆ operator*() [1/2]

template<class C >
C & Poco::AutoPtr< C >::operator* ( )
inline

Definition at line 243 of file AutoPtr.h.

◆ operator*() [2/2]

template<class C >
const C & Poco::AutoPtr< C >::operator* ( ) const
inline

Definition at line 251 of file AutoPtr.h.

◆ operator->() [1/2]

template<class C >
C * Poco::AutoPtr< C >::operator-> ( )
inline

Definition at line 227 of file AutoPtr.h.

+ Here is the caller graph for this function:

◆ operator->() [2/2]

template<class C >
const C * Poco::AutoPtr< C >::operator-> ( ) const
inline

Definition at line 235 of file AutoPtr.h.

+ Here is the caller graph for this function:

◆ operator<() [1/3]

template<class C >
bool Poco::AutoPtr< C >::operator< ( C * ptr) const
inline

Definition at line 345 of file AutoPtr.h.

◆ operator<() [2/3]

template<class C >
bool Poco::AutoPtr< C >::operator< ( const AutoPtr< C > & ptr) const
inline

Definition at line 335 of file AutoPtr.h.

◆ operator<() [3/3]

template<class C >
bool Poco::AutoPtr< C >::operator< ( const C * ptr) const
inline

Definition at line 340 of file AutoPtr.h.

◆ operator<=() [1/3]

template<class C >
bool Poco::AutoPtr< C >::operator<= ( C * ptr) const
inline

Definition at line 360 of file AutoPtr.h.

◆ operator<=() [2/3]

template<class C >
bool Poco::AutoPtr< C >::operator<= ( const AutoPtr< C > & ptr) const
inline

Definition at line 350 of file AutoPtr.h.

◆ operator<=() [3/3]

template<class C >
bool Poco::AutoPtr< C >::operator<= ( const C * ptr) const
inline

Definition at line 355 of file AutoPtr.h.

◆ operator=() [1/4]

template<class C >
AutoPtr & Poco::AutoPtr< C >::operator= ( AutoPtr< C > && ptr)
inlinenoexcept

Definition at line 183 of file AutoPtr.h.

◆ operator=() [2/4]

template<class C >
AutoPtr & Poco::AutoPtr< C >::operator= ( C * ptr)
inline

Definition at line 173 of file AutoPtr.h.

+ Here is the caller graph for this function:

◆ operator=() [3/4]

template<class C >
AutoPtr & Poco::AutoPtr< C >::operator= ( const AutoPtr< C > & ptr)
inline

Definition at line 178 of file AutoPtr.h.

◆ operator=() [4/4]

template<class C >
template<class Other >
AutoPtr & Poco::AutoPtr< C >::operator= ( const AutoPtr< Other > & ptr)
inline

Definition at line 192 of file AutoPtr.h.

◆ operator==() [1/4]

template<class C >
bool Poco::AutoPtr< C >::operator== ( C * ptr) const
inline

Definition at line 305 of file AutoPtr.h.

◆ operator==() [2/4]

template<class C >
bool Poco::AutoPtr< C >::operator== ( const AutoPtr< C > & ptr) const
inline

Definition at line 295 of file AutoPtr.h.

◆ operator==() [3/4]

template<class C >
bool Poco::AutoPtr< C >::operator== ( const C * ptr) const
inline

Definition at line 300 of file AutoPtr.h.

◆ operator==() [4/4]

template<class C >
bool Poco::AutoPtr< C >::operator== ( std::nullptr_t ptr) const
inline

Definition at line 310 of file AutoPtr.h.

◆ operator>() [1/3]

template<class C >
bool Poco::AutoPtr< C >::operator> ( C * ptr) const
inline

Definition at line 375 of file AutoPtr.h.

◆ operator>() [2/3]

template<class C >
bool Poco::AutoPtr< C >::operator> ( const AutoPtr< C > & ptr) const
inline

Definition at line 365 of file AutoPtr.h.

◆ operator>() [3/3]

template<class C >
bool Poco::AutoPtr< C >::operator> ( const C * ptr) const
inline

Definition at line 370 of file AutoPtr.h.

◆ operator>=() [1/3]

template<class C >
bool Poco::AutoPtr< C >::operator>= ( C * ptr) const
inline

Definition at line 390 of file AutoPtr.h.

◆ operator>=() [2/3]

template<class C >
bool Poco::AutoPtr< C >::operator>= ( const AutoPtr< C > & ptr) const
inline

Definition at line 380 of file AutoPtr.h.

◆ operator>=() [3/3]

template<class C >
bool Poco::AutoPtr< C >::operator>= ( const C * ptr) const
inline

Definition at line 385 of file AutoPtr.h.

◆ reset() [1/5]

template<class C >
void Poco::AutoPtr< C >::reset ( )
inline

Definition at line 143 of file AutoPtr.h.

◆ reset() [2/5]

template<class C >
void Poco::AutoPtr< C >::reset ( C * ptr)
inline

Definition at line 152 of file AutoPtr.h.

◆ reset() [3/5]

template<class C >
void Poco::AutoPtr< C >::reset ( C * ptr,
bool shared )
inline

Definition at line 157 of file AutoPtr.h.

◆ reset() [4/5]

template<class C >
void Poco::AutoPtr< C >::reset ( const AutoPtr< C > & ptr)
inline

Definition at line 162 of file AutoPtr.h.

◆ reset() [5/5]

template<class C >
template<class Other >
void Poco::AutoPtr< C >::reset ( const AutoPtr< Other > & ptr)
inline

Definition at line 168 of file AutoPtr.h.

◆ swap()

template<class C >
void Poco::AutoPtr< C >::swap ( AutoPtr< C > & ptr)
inline

Definition at line 197 of file AutoPtr.h.

◆ unsafeCast()

template<class C >
template<class Other >
AutoPtr< Other > Poco::AutoPtr< C >::unsafeCast ( ) const
inline

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

Definition at line 216 of file AutoPtr.h.

Member Data Documentation

◆ _ptr

template<class C >
C* Poco::AutoPtr< C >::_ptr
private

Definition at line 396 of file AutoPtr.h.


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