InvokerSignature.hpp
Go to the documentation of this file.
00001 /***************************************************************************
00002   tag: FMTC  do nov 2 13:05:58 CET 2006  Invoker.hpp
00003 
00004                         Invoker.hpp -  description
00005                            -------------------
00006     begin                : do november 02 2006
00007     copyright            : (C) 2006 FMTC
00008     email                : peter.soetens@fmtc.be
00009 
00010  ***************************************************************************
00011  *   This library is free software; you can redistribute it and/or         *
00012  *   modify it under the terms of the GNU General Public                   *
00013  *   License as published by the Free Software Foundation;                 *
00014  *   version 2 of the License.                                             *
00015  *                                                                         *
00016  *   As a special exception, you may use this file as part of a free       *
00017  *   software library without restriction.  Specifically, if other files   *
00018  *   instantiate templates or use macros or inline functions from this     *
00019  *   file, or you compile this file and link it with other files to        *
00020  *   produce an executable, this file does not by itself cause the         *
00021  *   resulting executable to be covered by the GNU General Public          *
00022  *   License.  This exception does not however invalidate any other        *
00023  *   reasons why the executable file might be covered by the GNU General   *
00024  *   Public License.                                                       *
00025  *                                                                         *
00026  *   This library is distributed in the hope that it will be useful,       *
00027  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00028  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00029  *   Lesser General Public License for more details.                       *
00030  *                                                                         *
00031  *   You should have received a copy of the GNU General Public             *
00032  *   License along with this library; if not, write to the Free Software   *
00033  *   Foundation, Inc., 59 Temple Place,                                    *
00034  *   Suite 330, Boston, MA  02111-1307  USA                                *
00035  *                                                                         *
00036  ***************************************************************************/
00037 
00038 
00039 #ifndef ORO_INVOKER_SIGNATURE_HPP
00040 #define ORO_INVOKER_SIGNATURE_HPP
00041 
00042 #include <boost/type_traits.hpp>
00043 #include "NA.hpp"
00044 #include "../rtt-fwd.hpp"
00045 
00046 namespace RTT
00047 {
00048     namespace internal
00049     {
00057         template<int, class Signature, class ToInvoke>
00058         struct InvokerSignature;
00059 
00060         template<class F, class ToInvoke>
00061         struct InvokerSignature<0,F,ToInvoke>
00062         {
00063             typedef typename boost::function_traits<F>::result_type result_type;
00064 
00065             InvokerSignature() : impl() {}
00066             InvokerSignature(ToInvoke implementation) : impl(implementation) {}
00067             ~InvokerSignature() {}
00068 
00072             result_type operator()()
00073             {
00074                 if (impl)
00075                     return impl->call();
00076                 return NA<result_type>::na();
00077             }
00078 
00079             result_type call() {
00080                 return operator()();
00081             }
00082 
00083             SendHandle<F> send()
00084             {
00085                 if (impl)
00086                     return impl->send();
00087                 return SendHandle<F>();
00088             }
00089 
00090         protected:
00091             ToInvoke impl;
00092         };
00093 
00094         template<class F, class ToInvoke>
00095         struct InvokerSignature<1,F,ToInvoke>
00096         {
00097             typedef typename boost::function_traits<F>::result_type result_type;
00098             typedef typename boost::function_traits<F>::arg1_type arg1_type;
00099 
00100             InvokerSignature() : impl() {}
00101             InvokerSignature(ToInvoke implementation) : impl(implementation) {}
00102             ~InvokerSignature() {}
00103 
00107             result_type operator()(arg1_type a1)
00108             {
00109                 if (impl)
00110                     return impl->call( a1 );
00111                 return NA<result_type>::na();
00112             }
00113             result_type call(arg1_type a1) {
00114                 return operator()(a1);
00115             }
00116 
00117             SendHandle<F> send(arg1_type a1)
00118             {
00119                 if (impl)
00120                     return impl->send(a1);
00121                 return SendHandle<F>();
00122             }
00123 
00124         protected:
00125             ToInvoke impl;
00126         };
00127 
00128         template<class F, class ToInvoke>
00129         struct InvokerSignature<2,F,ToInvoke>
00130         {
00131             typedef typename boost::function_traits<F>::result_type result_type;
00132             typedef typename boost::function_traits<F>::arg1_type arg1_type;
00133             typedef typename boost::function_traits<F>::arg2_type arg2_type;
00134 
00135             InvokerSignature() : impl() {}
00136             InvokerSignature(ToInvoke implementation) : impl(implementation) {}
00137             ~InvokerSignature() {}
00138 
00142             result_type operator()(arg1_type t1, arg2_type t2)
00143             {
00144                 if (impl)
00145                     return impl->call(t1, t2);
00146                 return NA<result_type>::na();
00147             }
00148 
00149             result_type call(arg1_type a1, arg2_type a2) {
00150                 return operator()(a1,a2);
00151             }
00152 
00153             SendHandle<F> send(arg1_type a1, arg2_type a2)
00154             {
00155                 if (impl)
00156                     return impl->send(a1,a2);
00157                 return SendHandle<F>();
00158             }
00159         protected:
00160             ToInvoke impl;
00161         };
00162 
00163         template<class F, class ToInvoke>
00164         struct InvokerSignature<3,F,ToInvoke>
00165         {
00166             typedef typename boost::function_traits<F>::result_type result_type;
00167             typedef typename boost::function_traits<F>::arg1_type arg1_type;
00168             typedef typename boost::function_traits<F>::arg2_type arg2_type;
00169             typedef typename boost::function_traits<F>::arg3_type arg3_type;
00170 
00171             InvokerSignature() : impl() {}
00172             InvokerSignature(ToInvoke implementation) : impl(implementation) {}
00173             ~InvokerSignature() { }
00174 
00178             result_type operator()(arg1_type t1, arg2_type t2, arg3_type t3)
00179             {
00180                 if (impl)
00181                     return impl->call(t1, t2, t3);
00182                 return NA<result_type>::na();
00183             }
00184 
00185             result_type call(arg1_type a1, arg2_type a2, arg3_type a3) {
00186                 return operator()(a1,a2,a3);
00187             }
00188 
00189             SendHandle<F> send(arg1_type a1, arg2_type a2, arg3_type a3)
00190             {
00191                 if (impl)
00192                     return impl->send(a1,a2,a3);
00193                 return SendHandle<F>();
00194             }
00195         protected:
00196             ToInvoke impl;
00197         };
00198 
00199         template<class F, class ToInvoke>
00200         struct InvokerSignature<4,F,ToInvoke>
00201         {
00202             typedef typename boost::function_traits<F>::result_type result_type;
00203             typedef typename boost::function_traits<F>::arg1_type arg1_type;
00204             typedef typename boost::function_traits<F>::arg2_type arg2_type;
00205             typedef typename boost::function_traits<F>::arg3_type arg3_type;
00206             typedef typename boost::function_traits<F>::arg4_type arg4_type;
00207 
00208             InvokerSignature() : impl() {}
00209             InvokerSignature(ToInvoke implementation) : impl(implementation) {}
00210             ~InvokerSignature() { }
00211 
00215             result_type operator()(arg1_type t1, arg2_type t2, arg3_type t3, arg4_type t4)
00216             {
00217                 if (impl)
00218                     return impl->call(t1, t2, t3, t4);
00219                 return NA<result_type>::na();
00220             }
00221 
00222             result_type call(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4) {
00223                 return operator()(a1,a2,a3,a4);
00224             }
00225 
00226             SendHandle<F> send(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4)
00227             {
00228                 if (impl)
00229                     return impl->send(a1,a2,a3,a4);
00230                 return SendHandle<F>();
00231             }
00232 
00233         protected:
00234             ToInvoke impl;
00235         };
00236 
00237         template<class F, class ToInvoke>
00238         struct InvokerSignature<5,F,ToInvoke>
00239         {
00240             typedef typename boost::function_traits<F>::result_type result_type;
00241             typedef typename boost::function_traits<F>::arg1_type arg1_type;
00242             typedef typename boost::function_traits<F>::arg2_type arg2_type;
00243             typedef typename boost::function_traits<F>::arg3_type arg3_type;
00244             typedef typename boost::function_traits<F>::arg4_type arg4_type;
00245             typedef typename boost::function_traits<F>::arg5_type arg5_type;
00246 
00247             InvokerSignature() : impl() {}
00248             InvokerSignature(ToInvoke implementation) : impl(implementation) {}
00249             ~InvokerSignature() { }
00250 
00254             result_type operator()(arg1_type t1, arg2_type t2, arg3_type t3, arg4_type t4, arg5_type t5)
00255             {
00256                 if (impl)
00257                     return impl->call(t1, t2, t3, t4, t5);
00258                 return NA<result_type>::na();
00259             }
00260 
00261             result_type call(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5) {
00262                 return operator()(a1,a2,a3,a4,a5);
00263             }
00264 
00265             SendHandle<F> send(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5)
00266             {
00267                 if (impl)
00268                     return impl->send(a1,a2,a3,a4,a5);
00269                 return SendHandle<F>();
00270             }
00271 
00272         protected:
00273             ToInvoke impl;
00274         };
00275 
00276         template<class F, class ToInvoke>
00277         struct InvokerSignature<6,F,ToInvoke>
00278         {
00279             typedef typename boost::function_traits<F>::result_type result_type;
00280             typedef typename boost::function_traits<F>::arg1_type arg1_type;
00281             typedef typename boost::function_traits<F>::arg2_type arg2_type;
00282             typedef typename boost::function_traits<F>::arg3_type arg3_type;
00283             typedef typename boost::function_traits<F>::arg4_type arg4_type;
00284             typedef typename boost::function_traits<F>::arg5_type arg5_type;
00285             typedef typename boost::function_traits<F>::arg6_type arg6_type;
00286 
00287             InvokerSignature() : impl() {}
00288             InvokerSignature(ToInvoke implementation) : impl(implementation) {}
00289             ~InvokerSignature() { }
00290 
00294             result_type operator()(arg1_type t1, arg2_type t2, arg3_type t3, arg4_type t4, arg5_type t5, arg6_type t6)
00295             {
00296                 if (impl)
00297                     return impl->call(t1, t2, t3, t4, t5, t6);
00298                 return NA<result_type>::na();
00299             }
00300 
00301             result_type call(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5, arg6_type a6) {
00302                 return operator()(a1,a2,a3,a4,a5,a6);
00303             }
00304 
00305             SendHandle<F> send(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5, arg6_type a6)
00306             {
00307                 if (impl)
00308                     return impl->send(a1,a2,a3,a4,a5,a6);
00309                 return SendHandle<F>();
00310             }
00311 
00312         protected:
00313             ToInvoke impl;
00314         };
00315 
00316         template<class F, class ToInvoke>
00317         struct InvokerSignature<7,F,ToInvoke>
00318         {
00319             typedef typename boost::function_traits<F>::result_type result_type;
00320             typedef typename boost::function_traits<F>::arg1_type arg1_type;
00321             typedef typename boost::function_traits<F>::arg2_type arg2_type;
00322             typedef typename boost::function_traits<F>::arg3_type arg3_type;
00323             typedef typename boost::function_traits<F>::arg4_type arg4_type;
00324             typedef typename boost::function_traits<F>::arg5_type arg5_type;
00325             typedef typename boost::function_traits<F>::arg6_type arg6_type;
00326             typedef typename boost::function_traits<F>::arg7_type arg7_type;
00327 
00328             InvokerSignature() : impl() {}
00329             InvokerSignature(ToInvoke implementation) : impl(implementation) {}
00330             ~InvokerSignature() { }
00331 
00335             result_type operator()(arg1_type t1, arg2_type t2, arg3_type t3, arg4_type t4, arg5_type t5, arg6_type t6, arg7_type t7)
00336             {
00337                 if (impl)
00338                     return impl->call(t1, t2, t3, t4, t5, t6, t7);
00339                 return NA<result_type>::na();
00340             }
00341 
00342             result_type call(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5, arg6_type a6, arg7_type a7) {
00343                 return operator()(a1,a2,a3,a4,a5,a6,a7);
00344             }
00345 
00346             SendHandle<F> send(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5, arg6_type a6, arg7_type a7)
00347             {
00348                 if (impl)
00349                     return impl->send(a1,a2,a3,a4,a5,a6,a7);
00350                 return SendHandle<F>();
00351             }
00352 
00353         protected:
00354             ToInvoke impl;
00355         };
00356 
00357     }
00358 }
00359 #endif


rtt
Author(s): RTT Developers
autogenerated on Mon Oct 6 2014 03:13:36