ACE_Utils::Auto_Functor< X, Functor > Class Template Reference

Helper template to implement auto_ptr<>-like classes, but executing a functor in the destructor, instead of always deleting things. More...

#include <Auto_Functor.h>

Collaboration diagram for ACE_Utils::Auto_Functor< X, Functor >:

Collaboration graph
[legend]
List of all members.

Public Types

typedef X element_type
typedef Functor functor_type

Public Member Functions

 Auto_Functor (X *p=0, Functor functor=Functor()) throw ()
 Constructor.

 Auto_Functor (Auto_Functor &rhs) throw ()
Auto_Functor< X, Functor > & operator= (Auto_Functor &rhs) throw ()
template<typename Y>  Auto_Functor (Auto_Functor< Y, Functor > &rhs) throw ()
template<typename Y> Auto_Functor< X, Functor > & operator= (Auto_Functor< Y, Functor > &rhs) throw ()
 ~Auto_Functor () throw ()
X & operator * () const throw ()
X * operator-> () const throw ()
X * get () throw ()
X * release () throw ()
void reset (X *p=0) throw ()
void reset (X *p, Functor f) throw ()
Functor const & functor () const throw ()
 Auto_Functor (Auto_Functor_Ref< X, Functor > rhs) throw ()
Auto_Functor< X, Functor > & operator= (Auto_Functor_Ref< X, Functor > rhs) throw ()
template<typename Y>  operator Auto_Functor_Ref () throw ()
template<typename Y>  operator Auto_Functor () throw ()

Private Attributes

X * p_
Functor f_

Detailed Description

template<typename X, typename Functor>
class ACE_Utils::Auto_Functor< X, Functor >

Helper template to implement auto_ptr<>-like classes, but executing a functor in the destructor, instead of always deleting things.

The functor is called in the destructor, and it must implement:

Functor() throw();
Functor(Functor const &) throw();
Functor & operator=(Functor const &) throw();
void operator()(X * p) throw();

Definition at line 58 of file Auto_Functor.h.


Member Typedef Documentation

template<typename X, typename Functor>
typedef X ACE_Utils::Auto_Functor< X, Functor >::element_type
 

Definition at line 61 of file Auto_Functor.h.

template<typename X, typename Functor>
typedef Functor ACE_Utils::Auto_Functor< X, Functor >::functor_type
 

Definition at line 62 of file Auto_Functor.h.


Constructor & Destructor Documentation

template<typename X, typename Functor>
ACE_INLINE ACE_Utils::Auto_Functor< X, Functor >::Auto_Functor X *  p = 0,
Functor  functor = Functor()
throw () [explicit]
 

Constructor.

Definition at line 16 of file Auto_Functor.inl.

00018   : p_(p)
00019   , f_(f)
00020 {
00021 }

template<typename X, typename Functor>
ACE_INLINE ACE_Utils::Auto_Functor< X, Functor >::Auto_Functor Auto_Functor< X, Functor > &  rhs  )  throw ()
 

Definition at line 24 of file Auto_Functor.inl.

00026   : p_(rhs.release())
00027   , f_(rhs.f_)
00028 {
00029 }

template<typename X, typename Functor>
template<typename Y>
ACE_INLINE ACE_Utils::Auto_Functor< X, Functor >::Auto_Functor Auto_Functor< Y, Functor > &  rhs  )  throw ()
 

Definition at line 43 of file Auto_Functor.inl.

00045   : p_(rhs.release())
00046   , f_(rhs.f_)
00047 {
00048 }

template<typename X, typename Functor>
ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_Utils::Auto_Functor< X, Functor >::~Auto_Functor  )  throw ()
 

Definition at line 15 of file Auto_Functor.cpp.

00017 {
00018   reset(0);
00019 }

template<typename X, typename Functor>
ACE_INLINE ACE_Utils::Auto_Functor< X, Functor >::Auto_Functor Auto_Functor_Ref< X, Functor >  rhs  )  throw ()
 

Definition at line 102 of file Auto_Functor.inl.

00104   : p_(rhs.p_)
00105   , f_(rhs.f_)
00106 {
00107 }


Member Function Documentation

template<typename X, typename Functor>
ACE_INLINE Functor const & ACE_Utils::Auto_Functor< X, Functor >::functor  )  const throw ()
 

Definition at line 95 of file Auto_Functor.inl.

00097 {
00098   return f_;
00099 }

template<typename X, typename Functor>
ACE_INLINE X * ACE_Utils::Auto_Functor< X, Functor >::get  )  throw ()
 

Definition at line 77 of file Auto_Functor.inl.

00079 {
00080   return p_;
00081 }

template<typename X, typename Functor>
ACE_INLINE X & ACE_Utils::Auto_Functor< X, Functor >::operator *  )  const throw ()
 

Definition at line 61 of file Auto_Functor.inl.

00063 {
00064   return *p_;
00065 }

template<typename X, typename Functor>
template<typename Y>
ACE_Utils::Auto_Functor< X, Functor >::operator Auto_Functor  )  throw ()
 

template<typename X, typename Functor>
template<typename Y>
ACE_Utils::Auto_Functor< X, Functor >::operator Auto_Functor_Ref  )  throw ()
 

template<typename X, typename Functor>
ACE_INLINE X * ACE_Utils::Auto_Functor< X, Functor >::operator->  )  const throw ()
 

Definition at line 69 of file Auto_Functor.inl.

00071 {
00072   return p_;
00073 }

template<typename X, typename Functor>
ACE_INLINE ACE_Utils::Auto_Functor< X, Functor > & ACE_Utils::Auto_Functor< X, Functor >::operator= Auto_Functor_Ref< X, Functor >  rhs  )  throw ()
 

Definition at line 111 of file Auto_Functor.inl.

00113 {
00114   if(rhs.p_ != p_)
00115   {
00116     reset(rhs.p_);
00117     f_ = rhs.f_;
00118   }
00119   return *this;
00120 }

template<typename X, typename Functor>
template<typename Y>
ACE_INLINE ACE_Utils::Auto_Functor< X, Functor > & ACE_Utils::Auto_Functor< X, Functor >::operator= Auto_Functor< Y, Functor > &  rhs  )  throw ()
 

Definition at line 52 of file Auto_Functor.inl.

00054 {
00055   reset(rhs.release());
00056   return *this;
00057 }

template<typename X, typename Functor>
ACE_INLINE ACE_Utils::Auto_Functor< X, Functor > & ACE_Utils::Auto_Functor< X, Functor >::operator= Auto_Functor< X, Functor > &  rhs  )  throw ()
 

Definition at line 33 of file Auto_Functor.inl.

00035 {
00036   reset(rhs.release());
00037   f_ = rhs.f_;
00038   return *this;
00039 }

template<typename X, typename Functor>
ACE_INLINE X * ACE_Utils::Auto_Functor< X, Functor >::release  )  throw ()
 

Definition at line 85 of file Auto_Functor.inl.

00087 {
00088   X * tmp = p_;
00089   p_ = 0;
00090   return tmp;
00091 }

template<typename X, typename Functor>
void ACE_Utils::Auto_Functor< X, Functor >::reset X *  p,
Functor  f
throw ()
 

Definition at line 33 of file Auto_Functor.cpp.

00035 {
00036   reset(p);
00037   f_ = f;
00038 }

template<typename X, typename Functor>
void ACE_Utils::Auto_Functor< X, Functor >::reset X *  p = 0  )  throw ()
 

Definition at line 22 of file Auto_Functor.cpp.

00024 {
00025   if(p_ != 0)
00026   {
00027     f_(p_);
00028   }
00029   p_ = p;
00030 }


Member Data Documentation

template<typename X, typename Functor>
Functor ACE_Utils::Auto_Functor< X, Functor >::f_ [private]
 

Definition at line 129 of file Auto_Functor.h.

template<typename X, typename Functor>
X* ACE_Utils::Auto_Functor< X, Functor >::p_ [private]
 

Definition at line 127 of file Auto_Functor.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 11:34:01 2006 for ACE by doxygen 1.3.6