00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef ACE_AUTO_FUNCTOR_H
00012 #define ACE_AUTO_FUNCTOR_H
00013 #include "ace/pre.h"
00014
00015 #include "ace/config-all.h"
00016
00017 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00018 # pragma once
00019 #endif
00020
00021 #include "ace/Global_Macros.h"
00022
00023 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00024
00025 namespace ACE_Utils
00026 {
00027
00028
00029
00030
00031
00032
00033 template<typename X, typename Functor>
00034 struct Auto_Functor_Ref
00035 {
00036 X * p_;
00037 Functor f_;
00038
00039 Auto_Functor_Ref(X * p, Functor f);
00040 };
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 template<typename X, typename Functor>
00058 class Auto_Functor
00059 {
00060 public:
00061 typedef X element_type;
00062 typedef Functor functor_type;
00063
00064
00065 explicit Auto_Functor (X * p = 0,
00066 Functor functor = Functor())
00067 ACE_THROW_SPEC (());
00068
00069 Auto_Functor (Auto_Functor & rhs)
00070 ACE_THROW_SPEC (());
00071
00072 Auto_Functor<X,Functor>& operator= (Auto_Functor & rhs)
00073 ACE_THROW_SPEC (());
00074
00075 #if !defined(ACE_LACKS_MEMBER_TEMPLATES)
00076 template<typename Y>
00077 Auto_Functor(Auto_Functor<Y,Functor>& rhs)
00078 ACE_THROW_SPEC (());
00079
00080 template<typename Y>
00081 Auto_Functor<X,Functor>& operator= (Auto_Functor<Y,Functor>& rhs)
00082 ACE_THROW_SPEC (());
00083 #endif
00084
00085 ~Auto_Functor()
00086 ACE_THROW_SPEC (());
00087
00088 X & operator*() const
00089 ACE_THROW_SPEC (());
00090
00091 X * operator->() const
00092 ACE_THROW_SPEC (());
00093
00094 X * get()
00095 ACE_THROW_SPEC (());
00096
00097 X * release()
00098 ACE_THROW_SPEC (());
00099
00100 void reset (X * p = 0)
00101 ACE_THROW_SPEC (());
00102
00103 void reset (X * p, Functor f)
00104 ACE_THROW_SPEC (());
00105
00106 Functor const & functor() const
00107 ACE_THROW_SPEC (());
00108
00109 Auto_Functor(Auto_Functor_Ref<X,Functor> rhs)
00110 ACE_THROW_SPEC (());
00111
00112 Auto_Functor<X,Functor> & operator=(Auto_Functor_Ref<X,Functor> rhs)
00113 ACE_THROW_SPEC (());
00114
00115 #if !defined(ACE_LACKS_MEMBER_TEMPLATES)
00116 template<typename Y> operator Auto_Functor_Ref<Y,Functor>()
00117 ACE_THROW_SPEC (());
00118
00119 template<typename Y> operator Auto_Functor<Y,Functor>()
00120 ACE_THROW_SPEC (());
00121 #else
00122 operator Auto_Functor_Ref<X,Functor>()
00123 ACE_THROW_SPEC (());
00124 #endif
00125
00126 private:
00127 X * p_;
00128
00129 Functor f_;
00130 };
00131
00132 }
00133
00134 ACE_END_VERSIONED_NAMESPACE_DECL
00135
00136 #if defined(__ACE_INLINE__)
00137 # include "ace/Auto_Functor.inl"
00138 #endif
00139
00140 #if defined(ACE_TEMPLATES_REQUIRE_SOURCE)
00141 # include "ace/Auto_Functor.cpp"
00142 #endif
00143
00144 #include "ace/post.h"
00145 #endif