00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef ORO_COLLECT_SIGNATURE_HPP
00040 #define ORO_COLLECT_SIGNATURE_HPP
00041
00042 #include <boost/function_types/function_type.hpp>
00043 #include <boost/function_types/function_arity.hpp>
00044 #include <boost/function_types/result_type.hpp>
00045 #include <boost/function_types/parameter_types.hpp>
00046 #include <boost/mpl/vector.hpp>
00047 #include <boost/mpl/remove_if.hpp>
00048 #include <boost/mpl/push_front.hpp>
00049 #include <boost/mpl/not.hpp>
00050 #include <boost/mpl/logical.hpp>
00051 #include <boost/mpl/if.hpp>
00052 #include <boost/type_traits.hpp>
00053 #include "../SendStatus.hpp"
00054
00055 namespace RTT
00056 {
00057 namespace internal
00058 {
00059 namespace ft=boost::function_types;
00060 namespace mpl=boost::mpl;
00061 namespace tt=boost;
00062
00074 template<class F>
00075 struct CollectType
00076 {
00077 private:
00078
00079
00080 typedef typename ft::result_type<F>::type ret_type;
00081 typedef typename ft::parameter_types<F>::type arg_type;
00082 typedef typename tt::remove_const< typename tt::remove_reference<ret_type>::type >::type bare_ret_type;
00083 typedef typename mpl::if_<
00084 typename mpl::not_< typename tt::is_void<ret_type>::type >::type,
00085 typename mpl::push_front< arg_type, typename tt::add_reference< bare_ret_type >::type >::type,
00086 arg_type
00087 >::type basic_sig;
00088
00089
00090
00091 typedef typename mpl::remove_if< basic_sig, tt::is_const< tt::remove_reference<mpl::_1> > >::type no_const_sig;
00092
00093 typedef typename mpl::remove_if< no_const_sig, mpl::not_<tt::is_reference<mpl::_1> > >::type no_value_sig;
00094
00095 typedef typename mpl::push_front< no_value_sig, ret_type>::type fttype;
00096 public:
00097
00098 typedef typename ft::function_type<fttype>::type Ft;
00099
00100 typedef Ft type;
00101
00102 typedef fttype mpl_type;
00103 };
00104
00111 template<int, class Signature, class ToCollect>
00112 struct CollectSignature;
00113
00114
00115
00116 template<class F, class ToCollect>
00117 struct CollectSignature<0,F,ToCollect>
00118 {
00119 typedef void result_type;
00120 CollectSignature() : cimpl() {}
00121 CollectSignature(ToCollect implementation) : cimpl(implementation) {}
00122 ~CollectSignature() {}
00123
00124 SendStatus collect()
00125 {
00126 if (this->cimpl)
00127 return this->cimpl->collect();
00128 return SendFailure;
00129 }
00130
00131 SendStatus collectIfDone()
00132 {
00133 if (this->cimpl)
00134 return this->cimpl->collectIfDone();
00135 return SendFailure;
00136 }
00137
00138 protected:
00139 ToCollect cimpl;
00140 };
00141
00142
00143
00144 template<class F, class ToCollect>
00145 struct CollectSignature<1,F,ToCollect>
00146 {
00147 typedef typename boost::function_traits<F>::result_type result_type;
00148 typedef typename boost::function_traits<F>::arg1_type arg1_type;
00149
00150 CollectSignature() : cimpl() {}
00151 CollectSignature(ToCollect implementation) : cimpl(implementation) {}
00152 ~CollectSignature() {}
00153
00157 SendStatus collect(arg1_type a1)
00158 {
00159 if (cimpl)
00160 return cimpl->collect( a1 );
00161 return SendFailure;
00162 }
00163
00164 SendStatus collectIfDone(arg1_type a1)
00165 {
00166 if (cimpl)
00167 return cimpl->collectIfDone( a1 );
00168 return SendFailure;
00169 }
00170 protected:
00171 ToCollect cimpl;
00172 };
00173
00174 template<class F, class ToCollect>
00175 struct CollectSignature<2,F,ToCollect>
00176 {
00177 typedef typename boost::function_traits<F>::arg1_type arg1_type;
00178 typedef typename boost::function_traits<F>::arg2_type arg2_type;
00179
00180 CollectSignature() : cimpl() {}
00181 CollectSignature(ToCollect implementation) : cimpl(implementation) {}
00182 ~CollectSignature() {}
00183
00187 SendStatus collect(arg1_type t1, arg2_type t2)
00188 {
00189 if (cimpl)
00190 return cimpl->collect(t1, t2);
00191 return SendFailure;
00192 }
00193
00194 SendStatus collectIfDone(arg1_type t1, arg2_type t2)
00195 {
00196 if (cimpl)
00197 return cimpl->collectIfDone(t1, t2);
00198 return SendFailure;
00199 }
00200 protected:
00201 ToCollect cimpl;
00202 };
00203
00204 template<class F, class ToCollect>
00205 struct CollectSignature<3,F,ToCollect>
00206 {
00207 typedef typename boost::function_traits<F>::arg1_type arg1_type;
00208 typedef typename boost::function_traits<F>::arg2_type arg2_type;
00209 typedef typename boost::function_traits<F>::arg3_type arg3_type;
00210
00211 CollectSignature() : cimpl() {}
00212 CollectSignature(ToCollect implementation) : cimpl(implementation) {}
00213 ~CollectSignature() { }
00214
00218 SendStatus collect(arg1_type t1, arg2_type t2, arg3_type t3)
00219 {
00220 if (cimpl)
00221 return cimpl->collect(t1, t2, t3);
00222 return SendFailure;
00223 }
00224
00225 SendStatus collectIfDone(arg1_type t1, arg2_type t2, arg3_type t3)
00226 {
00227 if (cimpl)
00228 return cimpl->collectIfDone(t1, t2, t3);
00229 return SendFailure;
00230 }
00231 protected:
00232 ToCollect cimpl;
00233 };
00234
00235 template<class F, class ToCollect>
00236 struct CollectSignature<4,F,ToCollect>
00237 {
00238 typedef typename boost::function_traits<F>::arg1_type arg1_type;
00239 typedef typename boost::function_traits<F>::arg2_type arg2_type;
00240 typedef typename boost::function_traits<F>::arg3_type arg3_type;
00241 typedef typename boost::function_traits<F>::arg4_type arg4_type;
00242
00243 CollectSignature() : cimpl() {}
00244 CollectSignature(ToCollect implementation) : cimpl(implementation) {}
00245 ~CollectSignature() { }
00246
00250 SendStatus collect(arg1_type t1, arg2_type t2, arg3_type t3, arg4_type t4)
00251 {
00252 if (cimpl)
00253 return cimpl->collect(t1, t2, t3, t4);
00254 return SendFailure;
00255 }
00256
00257 SendStatus collectIfDone(arg1_type t1, arg2_type t2, arg3_type t3, arg4_type t4)
00258 {
00259 if (cimpl)
00260 return cimpl->collect(t1, t2, t3, t4);
00261 return SendFailure;
00262 }
00263 protected:
00264 ToCollect cimpl;
00265 };
00266
00267 template<class F, class ToCollect>
00268 struct CollectSignature<5,F,ToCollect>
00269 {
00270 typedef typename boost::function_traits<F>::arg1_type arg1_type;
00271 typedef typename boost::function_traits<F>::arg2_type arg2_type;
00272 typedef typename boost::function_traits<F>::arg3_type arg3_type;
00273 typedef typename boost::function_traits<F>::arg4_type arg4_type;
00274 typedef typename boost::function_traits<F>::arg5_type arg5_type;
00275
00276 CollectSignature() : cimpl() {}
00277 CollectSignature(ToCollect implementation) : cimpl(implementation) {}
00278 ~CollectSignature() { }
00279
00283 SendStatus collect(arg1_type t1, arg2_type t2, arg3_type t3, arg4_type t4, arg5_type t5)
00284 {
00285 if (cimpl)
00286 return cimpl->collect(t1, t2, t3, t4, t5);
00287 return SendFailure;
00288 }
00289
00290 SendStatus collectIfDone(arg1_type t1, arg2_type t2, arg3_type t3, arg4_type t4, arg5_type t5)
00291 {
00292 if (cimpl)
00293 return cimpl->collect(t1, t2, t3, t4, t5);
00294 return SendFailure;
00295 }
00296 protected:
00297 ToCollect cimpl;
00298 };
00299
00300 template<class F, class ToCollect>
00301 struct CollectSignature<6,F,ToCollect>
00302 {
00303 typedef typename boost::function_traits<F>::arg1_type arg1_type;
00304 typedef typename boost::function_traits<F>::arg2_type arg2_type;
00305 typedef typename boost::function_traits<F>::arg3_type arg3_type;
00306 typedef typename boost::function_traits<F>::arg4_type arg4_type;
00307 typedef typename boost::function_traits<F>::arg5_type arg5_type;
00308 typedef typename boost::function_traits<F>::arg6_type arg6_type;
00309
00310 CollectSignature() : cimpl() {}
00311 CollectSignature(ToCollect implementation) : cimpl(implementation) {}
00312 ~CollectSignature() { }
00313
00317 SendStatus collect(arg1_type t1, arg2_type t2, arg3_type t3, arg4_type t4, arg5_type t5, arg6_type t6)
00318 {
00319 if (cimpl)
00320 return cimpl->collect(t1, t2, t3, t4, t5, t6);
00321 return SendFailure;
00322 }
00323
00324 SendStatus collectIfDone(arg1_type t1, arg2_type t2, arg3_type t3, arg4_type t4, arg5_type t5, arg6_type t6)
00325 {
00326 if (cimpl)
00327 return cimpl->collect(t1, t2, t3, t4, t5, t6);
00328 return SendFailure;
00329 }
00330 protected:
00331 ToCollect cimpl;
00332 };
00333
00334 }
00335 }
00336 #endif