Public Member Functions | List of all members
Celartem::AutoPtr< T > Class Template Reference

#include <cel_autoptr.h>

Inheritance diagram for Celartem::AutoPtr< T >:
Inheritance graph
[legend]

Public Member Functions

 AutoPtr ()
 
 ~AutoPtr ()
 
 AutoPtr (T *inPtr)
 
template<typename U >
 AutoPtr (U *inPtr)
 
 AutoPtr (const AutoPtr< T > &inPtr)
 
template<class U >
 AutoPtr (const AutoPtr< U > &inPtr)
 
AutoPtr< T > & operator= (T *inPtr)
 
template<typename U >
AutoPtr< T > & operator= (U *inPtr)
 
AutoPtr< T > & operator= (const AutoPtr< T > &inPtr)
 
template<class U >
AutoPtr< T > & operator= (const AutoPtr< U > &inPtr)
 
bool isValid () const
 
T * getPtr () const
 
T * operator-> () const
 
bool isLastRef () const
 
 operator T * () const
 
 operator AutoPtr< const T > () const
 
template<typename U >
 operator AutoPtr< U > () const
 
template<typename U >
 operator AutoPtr< const U > () const
 
T * removeConst () const
 
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

Constructor & Destructor Documentation

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

This constuctor initializes AutoPtr without any instance.

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

Destructs the AutoPtr and releases containing instance.

template<class T>
Celartem::AutoPtr< T >::AutoPtr ( T *  inPtr)
inline
Parameters
inPtra pointer that specifies Referable derivative class instance.
template<class T>
template<typename U >
Celartem::AutoPtr< T >::AutoPtr ( U *  inPtr)
inline
Parameters
inPtra pointer that specifies Referable derivative class instance.
template<class T>
Celartem::AutoPtr< T >::AutoPtr ( const AutoPtr< T > &  inPtr)
inline
Parameters
inPtrReference to an AutoPtr instance that specifies a Referable derivative class instance.
template<class T>
template<class U >
Celartem::AutoPtr< T >::AutoPtr ( const AutoPtr< U > &  inPtr)
inline
Parameters
inPtrReference to an AutoPtr instance that specifies a Referable derivative class instance.

Member Function Documentation

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.
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.

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

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 AutoPtr instances.

Returns
true if this is the last reference, otherwise false.
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.

Referenced by Celartem::AutoPtr< const Celartem::DjVu::Data >::isLastRef().

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

This function realizes implicit cast to const pointer types.

template<class T>
template<typename U >
Celartem::AutoPtr< T >::operator AutoPtr< const U > ( ) const
inline

This function realizes implicit cast to static_cast-able pointer types.

template<class T>
template<typename U >
Celartem::AutoPtr< T >::operator AutoPtr< U > ( ) const
inline

This function realizes implicit cast to static_cast-able pointer types.

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

This function realizes implicit cast to static_cast-able pointer types.

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

This method is to fake the raw pointer.

template<class T>
AutoPtr<T>& Celartem::AutoPtr< T >::operator= ( T *  inPtr)
inline
Parameters
inPtrPointer to a Referable derivative class instance.
template<class T>
template<typename U >
AutoPtr<T>& Celartem::AutoPtr< T >::operator= ( U *  inPtr)
inline
Parameters
inPtrPointer to a Referable derivative class instance.
template<class T>
AutoPtr<T>& Celartem::AutoPtr< T >::operator= ( const AutoPtr< T > &  inPtr)
inline
Parameters
inPtrReference to an AutoPtr instance that specifies a Referable derivative class instance.
template<class T>
template<class U >
AutoPtr<T>& Celartem::AutoPtr< T >::operator= ( const AutoPtr< U > &  inPtr)
inline
Parameters
inPtrReference to an AutoPtr instance that specifies a Referable derivative class instance.
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.

template<class T>
T* Celartem::AutoPtr< T >::removeConst ( ) const
inline

This function does const_cast<> on this instance.
This should not be used frequently...

Returns
De-const-ed pointer to this instance.
template<class T>
void Celartem::AutoPtr< T >::setObject ( T *  inPtr)
inline
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
inPtrAutoPtr instance to exchange the pointer.

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

Cuminas DjVu SDK 3.0.33103
This document is made with doxygen 1.8.5 at Sun Dec 15 2013 19:38:06.
Cuminas Logo