imebra  build 2011-09-18_22-24-41
puntoexe::ptr< objectType > Class Template Reference

This class represents a shared pointer which keeps track of the allocated objects that derive from the class baseObject. More...

#include <baseObject.h>

Inherits puntoexe::basePtr.

List of all members.

Public Member Functions

 ptr ()
 Default constructor.
 ptr (objectType *pObject)
 Initializes the ptr object with a reference to a baseObject.
 ptr (ptr< objectType > const &ptrSource)
 Copy constructor.
ptr< objectType > & operator= (const ptr< objectType > &ptrSource)
 Copy the object tracked by another ptr.
bool operator== (const objectType *ptrCompare) const
 Compare the pointer to the tracked object with the pointer specified in the parameter.
bool operator== (const ptr< objectType > &ptrCompare) const
 Compare the pointer to the tracked object with the pointer tracked by another ptr.
objectType * operator-> () const
 Return the pointer to the tracked object.
objectType * get () const
 Return the pointer to the tracked object.
template<class destType >
 operator destType * () const
 Return the pointer to the tracked object, type casted in the specified class pointer.
template<class destType >
 operator ptr< destType > () const
 Return a new ptr object tracking the object tracked by this ptr. A type cast is performed if necessary.

Detailed Description

template<class objectType>
class puntoexe::ptr< objectType >

This class represents a shared pointer which keeps track of the allocated objects that derive from the class baseObject.

Most of the classes in this library derive from baseObject.

When a ptr object is initialized with a pointer to a baseObject derived object then it increases by 1 the reference counter of baseObject.
When ptr goes out of scope (destroyed) then the reference counter of baseObject is decreased by 1, and eventually baseObject is destroyed when its reference counter reaches 0.

Examples:

changeTransferSyntax/changeTransferSyntax.cpp, dicom2jpeg/dicom2jpeg.cpp, and dicomdirItems/dicomdirItems.cpp.


Constructor & Destructor Documentation

template<class objectType>
puntoexe::ptr< objectType >::ptr ( ) [inline]

Default constructor.

Set the internal pointer to null.

template<class objectType>
puntoexe::ptr< objectType >::ptr ( objectType *  pObject) [inline]

Initializes the ptr object with a reference to a baseObject.

The baseObject's reference counter is increased by one: this will keep the baseObject allocate at least until ptr stays allocated, release() is called or a new baseObject is associated to ptr.

Parameters:
pObjecta pointer to the allocated object. The allocated object will be automatically released by the class' destructor.
The object must be allocated by the C++ new statement.
The object's reference counter is increased by this function.
template<class objectType>
puntoexe::ptr< objectType >::ptr ( ptr< objectType > const &  ptrSource) [inline]

Copy constructor.

The object tracked by another ptr is copied into the current ptr and the reference counter is increased.

Parameters:
ptrSourcethe source ptr object that must be copied into the current ptr.

Member Function Documentation

template<class objectType>
objectType* puntoexe::ptr< objectType >::get ( ) const [inline]

Return the pointer to the tracked object.

Returns:
the pointer to the tracked object
template<class objectType>
template<class destType >
puntoexe::ptr< objectType >::operator destType * ( ) const [inline]

Return the pointer to the tracked object, type casted in the specified class pointer.

The cast is static, so its validity is checked at compile time.

Returns:
the pointer to the tracked object
template<class objectType>
template<class destType >
puntoexe::ptr< objectType >::operator ptr< destType > ( ) const [inline]

Return a new ptr object tracking the object tracked by this ptr. A type cast is performed if necessary.

The type cast is static, so its validity is checked at compile time.

Returns:
the pointer to the tracked object
template<class objectType>
objectType* puntoexe::ptr< objectType >::operator-> ( ) const [inline]

Return the pointer to the tracked object.

Returns:
the pointer to the tracked object
template<class objectType>
ptr<objectType>& puntoexe::ptr< objectType >::operator= ( const ptr< objectType > &  ptrSource) [inline]

Copy the object tracked by another ptr.

Parameters:
ptrSourcethe ptr object that is currently tracking the object to be tracked by this ptr object. The reference counter of the new object is increased. The object previously tracked by this ptr is released.
Returns:
a reference to the ptr object.
template<class objectType>
bool puntoexe::ptr< objectType >::operator== ( const objectType *  ptrCompare) const [inline]

Compare the pointer to the tracked object with the pointer specified in the parameter.

Parameters:
ptrComparethe pointer to be compared with the pointer to the tracked object
Returns:
true if the ptrCompare pointer is equal to the pointer of the tracked object
template<class objectType>
bool puntoexe::ptr< objectType >::operator== ( const ptr< objectType > &  ptrCompare) const [inline]

Compare the pointer to the tracked object with the pointer tracked by another ptr.

Parameters:
ptrComparethe ptr tracking the object to be compared
Returns:
true if the ptrCompare pointer is equal to the pointer of the tracked object

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