Public Member Functions

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

Referenced by Celartem::AutoPtr< Storage >::~AutoPtr().

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

Destructs the AutoPtr and releases containing instance.

Referenced by Celartem::AutoPtr< Storage >::~AutoPtr().

template<class T>
Celartem::AutoPtr< T >::AutoPtr ( T *  inPtr  )  [inline]
Parameters:
inPtr a pointer that specifies Referable derivative class instance.
template<class T>
template<typename U >
Celartem::AutoPtr< T >::AutoPtr ( U *  inPtr  )  [inline]
Parameters:
inPtr a pointer that specifies Referable derivative class instance.
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.
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.

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]
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::RegularExpression::findFirst(), Celartem::RegularExpression::findNext(), Celartem::RegularExpression::isVaild(), and Celartem::DiskStorageLock::unlock().

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>
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.
template<class T>
AutoPtr& Celartem::AutoPtr< T >::operator= ( T *  inPtr  )  [inline]
Parameters:
inPtr Pointer to a Referable derivative class instance.

Referenced by Celartem::AutoPtr< Storage >::~AutoPtr().

template<class T>
template<typename U >
AutoPtr& Celartem::AutoPtr< T >::operator= ( U *  inPtr  )  [inline]
Parameters:
inPtr Pointer to a Referable derivative class instance.
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.
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]

Set a new pointer to this AutoPtr.

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

Referenced by Celartem::AutoPtr< Storage >::isValid(), and Celartem::AutoPtr< Storage >::~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.

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


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

This document is made with doxygen 1.7.1 at Sun Sep 5 2010 13:03:37.
Caminova Logo