Logo Search packages:      
Sourcecode: poco version File versions

Public Member Functions | Private Attributes

Poco::AutoPtr< C > Class Template Reference

#include <AutoPtr.h>

Inheritance diagram for Poco::AutoPtr< C >:
Inheritance graph
Collaboration diagram for Poco::AutoPtr< C >:
Collaboration graph

List of all members.

Public Member Functions

AutoPtrassign (C *ptr)
AutoPtrassign (C *ptr, bool shared)
AutoPtrassign (const AutoPtr &ptr)
template<class Other >
AutoPtrassign (const AutoPtr< Other > &ptr)
 AutoPtr (const AutoPtr &ptr)
 AutoPtr (C *ptr)
template<class Other >
 AutoPtr (const AutoPtr< Other > &ptr)
 AutoPtr (C *ptr, bool shared)
template<class Other >
AutoPtr< Other > cast () const
C * duplicate ()
C * get ()
const C * get () const
bool isNull () const
 operator C * ()
 operator const C * () const
bool operator! () const
bool operator!= (const C *ptr) const
bool operator!= (C *ptr) const
bool operator!= (const AutoPtr &ptr) const
C & operator* ()
const C & operator* () const
C * operator-> ()
const C * operator-> () const
bool operator< (const AutoPtr &ptr) const
bool operator< (const C *ptr) const
bool operator< (C *ptr) const
bool operator<= (const C *ptr) const
bool operator<= (const AutoPtr &ptr) const
bool operator<= (C *ptr) const
AutoPtroperator= (C *ptr)
AutoPtroperator= (const AutoPtr &ptr)
template<class Other >
AutoPtroperator= (const AutoPtr< Other > &ptr)
bool operator== (const C *ptr) const
bool operator== (C *ptr) const
bool operator== (const AutoPtr &ptr) const
bool operator> (C *ptr) const
bool operator> (const 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
void swap (AutoPtr &ptr)
template<class Other >
AutoPtr< Other > unsafeCast () 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 52 of file AutoPtr.h.

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

Generated by  Doxygen 1.6.0   Back to index