Celartem::AutoPtr< T > Class Template Reference

#include <cel_autoptr.h>

Inheritance diagram for Celartem::AutoPtr< T >:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 AutoPtr ()
 ~AutoPtr ()
 AutoPtr (T *inPtr)
template<typename U>
 AutoPtr (U *inPtr)
 AutoPtr (const AutoPtr &inPtr)
template<class U>
 AutoPtr (const AutoPtr< U > &inPtr)
AutoPtroperator= (T *inPtr)
template<typename U>
AutoPtroperator= (U *inPtr)
AutoPtroperator= (const AutoPtr &inPtr)
template<class U>
AutoPtroperator= (const AutoPtr< U > &inPtr)
bool isValid () const
T * getPtr () const
T * operator-> () const
bool isLastRef () const
 operator T * () const
 operator AutoPtr< const T > ()
void setObject (T *inPtr)
void swap (AutoPtr< T > &inPtr)
void release ()
T * detach ()


Detailed Description

template<class T>
class Celartem::AutoPtr< T >

This class controls the lifetime of classes that are derived from Referable class.
Although AutoPtr itself is completely thread-safe, you should synchronize the operations if an instance is used between several threads.
See also:
Referable

Definition at line 24 of file cel_autoptr.h.


Constructor & Destructor Documentation

template<class T>
Celartem::AutoPtr< T >::AutoPtr (  )  [inline]

This constuctor initializes AutoPtr without any instance.

Definition at line 30 of file cel_autoptr.h.

template<class T>
Celartem::AutoPtr< T >::~AutoPtr (  )  [inline]

Destructs the AutoPtr and releases containing instance.

Definition at line 37 of file cel_autoptr.h.

template<class T>
Celartem::AutoPtr< T >::AutoPtr ( T *  inPtr  )  [inline]

Parameters:
inPtr a pointer that specifies Referable derivative class instance.

Definition at line 46 of file cel_autoptr.h.

template<class T>
template<typename U>
Celartem::AutoPtr< T >::AutoPtr ( U *  inPtr  )  [inline]

Parameters:
inPtr a pointer that specifies Referable derivative class instance.

Definition at line 55 of file cel_autoptr.h.

template<class T>
Celartem::AutoPtr< T >::AutoPtr ( const AutoPtr< T > &  inPtr  )  [inline]

Parameters:
inPtr Reference to an AutoPtr instance that specifies a Referable derivative class instance.

Definition at line 65 of file cel_autoptr.h.

template<class T>
template<class U>
Celartem::AutoPtr< T >::AutoPtr ( const AutoPtr< U > &  inPtr  )  [inline]

Parameters:
inPtr Reference to an AutoPtr instance that specifies a Referable derivative class instance.

Definition at line 75 of file cel_autoptr.h.


Member Function Documentation

template<class T>
AutoPtr& Celartem::AutoPtr< T >::operator= ( T *  inPtr  )  [inline]

Parameters:
inPtr Pointer to a Referable derivative class instance.

Definition at line 84 of file cel_autoptr.h.

template<class T>
template<typename U>
AutoPtr& Celartem::AutoPtr< T >::operator= ( U *  inPtr  )  [inline]

Parameters:
inPtr Pointer to a Referable derivative class instance.

Definition at line 94 of file cel_autoptr.h.

template<class T>
AutoPtr& Celartem::AutoPtr< T >::operator= ( const AutoPtr< T > &  inPtr  )  [inline]

Parameters:
inPtr Reference to an AutoPtr instance that specifies a Referable derivative class instance.

Definition at line 105 of file cel_autoptr.h.

template<class T>
template<class U>
AutoPtr& Celartem::AutoPtr< T >::operator= ( const AutoPtr< U > &  inPtr  )  [inline]

Parameters:
inPtr Reference to an AutoPtr instance that specifies a Referable derivative class instance.

Definition at line 116 of file cel_autoptr.h.

template<class T>
bool Celartem::AutoPtr< T >::isValid (  )  const [inline]

This method checks whether the AutoPtr points to a valid Referable instance or not.

Returns:
true if it is valid, otherwise false.

Definition at line 128 of file cel_autoptr.h.

Referenced by Celartem::AutoPtr< Celartem::ColorProfile >::isLastRef().

template<class T>
T* Celartem::AutoPtr< T >::getPtr (  )  const [inline]

This method returns the raw pointer; although AutoPtr class also supports implicit cast to raw pointer, it sometimes doesn't work and you may happen to use this function instead.

Returns:
the pointer to the Referable instance.

Definition at line 136 of file cel_autoptr.h.

Referenced by Celartem::DataStore::at(), Celartem::AutoPtr< Celartem::ColorProfile >::AutoPtr(), Celartem::DjVu::MemoryData::create(), Celartem::DataArray< T >::deserialize(), Celartem::DjVu::MemoryData::duplicate(), Celartem::DataArray< T >::duplicate(), Celartem::DjVu::PageInfo::encodeINFOChunk(), Celartem::DataStore::get(), and Celartem::AutoPtr< Celartem::ColorProfile >::operator=().

template<class T>
T* Celartem::AutoPtr< T >::operator-> (  )  const [inline]

This method is to fake the raw pointer.

Definition at line 141 of file cel_autoptr.h.

template<class T>
bool Celartem::AutoPtr< T >::isLastRef (  )  const [inline]

This method is to check whether the reference count is 1 or not.
If the reference count is equal to 1, this AutoPtr is the last reference which is keeping the instance in memory and if this AutoPtr releases the reference, the instance will be disposed. In other words, this is the only one reference to the instance and it is not shared with other AutoPtrs.

Returns:
true if this is the last reference, otherwise false.

Definition at line 158 of file cel_autoptr.h.

template<class T>
Celartem::AutoPtr< T >::operator T * (  )  const [inline]

This function realizes implicit cast into T*.

Definition at line 166 of file cel_autoptr.h.

template<class T>
Celartem::AutoPtr< T >::operator AutoPtr< const T > (  )  [inline]

This function realizes cast to AutoPtr<const T>.

Definition at line 171 of file cel_autoptr.h.

template<class T>
void Celartem::AutoPtr< T >::setObject ( T *  inPtr  )  [inline]

Set a new pointer to this AutoPtr.

Parameters:
inPtr a pointer that specifies Referable derivative class instance.

Definition at line 181 of file cel_autoptr.h.

Referenced by Celartem::AutoPtr< Celartem::ColorProfile >::AutoPtr(), Celartem::AutoPtr< Celartem::ColorProfile >::operator=(), Celartem::AutoPtr< Celartem::ColorProfile >::release(), and Celartem::AutoPtr< Celartem::ColorProfile >::~AutoPtr().

template<class T>
void Celartem::AutoPtr< T >::swap ( AutoPtr< T > &  inPtr  )  [inline]

This method swaps the pointers to the objects without reference count operation.

Parameters:
inPtr AutoPtr instance to exchange the pointer.

Definition at line 200 of file cel_autoptr.h.

template<class T>
void Celartem::AutoPtr< T >::release (  )  [inline]

This method releases the current instance. Usually, AutoPtr can automatically release the instance when it is removed.

Definition at line 214 of file cel_autoptr.h.

template<class T>
T* Celartem::AutoPtr< T >::detach (  )  [inline]

This method gives up the ownership of its holding instance; The pointer that has been held is not released by this AutoPtr instance, and you should manually call Referable::releaseRef method of that instance. This method is for advanced purpose only.

Returns:
Pointer to the instance.

Definition at line 224 of file cel_autoptr.h.


The documentation for this class was generated from the following file:
This document is automatically generated using doxygen 1.5.4 at Fri Jun 27 18:23:13 2008.