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_INVOKER_BASE_HPP
00040 #define ORO_INVOKER_BASE_HPP
00041 
00042 #include <boost/function.hpp>
00043 #include <boost/function_types/function_type.hpp>
00044 #include <boost/type_traits.hpp>
00045 #include "NA.hpp"
00046 #include "../SendHandle.hpp"
00047 #include "../rtt-fwd.hpp"
00048 
00049 namespace RTT
00050 {
00051     namespace internal
00052     {
00058         template<int, class F>
00059         struct InvokerBaseImpl;
00060 
00068         template<class F>
00069         struct InvokerBase
00070             : public InvokerBaseImpl<boost::function_traits<F>::arity, F>
00071         {};
00072 
00073         template<class F>
00074         struct InvokerBaseImpl<0,F>
00075         {
00076             typedef typename boost::function_traits<F>::result_type result_type;
00077             typedef typename boost::function_traits<F>::result_type result_reference;
00078             virtual ~InvokerBaseImpl() {}
00079             virtual SendHandle<F> send() = 0;
00080             virtual result_type call() = 0;
00081         };
00082 
00083         template<class F>
00084         struct InvokerBaseImpl<1,F>
00085         {
00086             typedef typename boost::function_traits<F>::result_type result_type;
00087             typedef typename boost::function<F>::arg1_type arg1_type;
00088             virtual ~InvokerBaseImpl() {}
00089             virtual result_type call(arg1_type a1) = 0;
00090             virtual SendHandle<F> send(arg1_type a1) = 0;
00091         };
00092 
00093         template<class F>
00094         struct InvokerBaseImpl<2,F>
00095         {
00096             typedef typename boost::function_traits<F>::result_type result_type;
00097             typedef typename boost::function<F>::arg1_type arg1_type;
00098             typedef typename boost::function<F>::arg2_type arg2_type;
00099             virtual ~InvokerBaseImpl() {}
00100             virtual result_type call(arg1_type a1, arg2_type a2) = 0;
00101             virtual SendHandle<F> send(arg1_type a1, arg2_type a2) = 0;
00102         };
00103 
00104         template<class F>
00105         struct InvokerBaseImpl<3,F>
00106         {
00107             typedef typename boost::function_traits<F>::result_type result_type;
00108             typedef typename boost::function<F>::arg1_type arg1_type;
00109             typedef typename boost::function<F>::arg2_type arg2_type;
00110             typedef typename boost::function<F>::arg3_type arg3_type;
00111             virtual ~InvokerBaseImpl() {}
00112             virtual result_type call(arg1_type a1, arg2_type a2, arg3_type a3) = 0;
00113             virtual SendHandle<F> send(arg1_type a1, arg2_type a2, arg3_type a3) = 0;
00114         };
00115 
00116         template<class F>
00117         struct InvokerBaseImpl<4,F>
00118         {
00119             typedef typename boost::function_traits<F>::result_type result_type;
00120             typedef typename boost::function<F>::arg1_type arg1_type;
00121             typedef typename boost::function<F>::arg2_type arg2_type;
00122             typedef typename boost::function<F>::arg3_type arg3_type;
00123             typedef typename boost::function<F>::arg4_type arg4_type;
00124             virtual ~InvokerBaseImpl() {}
00125             virtual result_type call(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4) = 0;
00126             virtual SendHandle<F> send(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4) = 0;
00127         };
00128 
00129         template<class F>
00130         struct InvokerBaseImpl<5,F>
00131         {
00132             typedef typename boost::function_traits<F>::result_type result_type;
00133             typedef typename boost::function<F>::arg1_type arg1_type;
00134             typedef typename boost::function<F>::arg2_type arg2_type;
00135             typedef typename boost::function<F>::arg3_type arg3_type;
00136             typedef typename boost::function<F>::arg4_type arg4_type;
00137             typedef typename boost::function<F>::arg5_type arg5_type;
00138             virtual ~InvokerBaseImpl() {}
00139             virtual result_type call(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5) = 0;
00140             virtual SendHandle<F> send(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5) = 0;
00141         };
00142 
00143         template<class F>
00144         struct InvokerBaseImpl<6,F>
00145         {
00146             typedef typename boost::function_traits<F>::result_type result_type;
00147             typedef typename boost::function<F>::arg1_type arg1_type;
00148             typedef typename boost::function<F>::arg2_type arg2_type;
00149             typedef typename boost::function<F>::arg3_type arg3_type;
00150             typedef typename boost::function<F>::arg4_type arg4_type;
00151             typedef typename boost::function<F>::arg5_type arg5_type;
00152             typedef typename boost::function<F>::arg6_type arg6_type;
00153             virtual ~InvokerBaseImpl() {}
00154             virtual result_type call(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5, arg6_type a6) = 0;
00155             virtual SendHandle<F> send(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5, arg6_type a6) = 0;
00156         };
00157 
00158         template<class F>
00159         struct InvokerBaseImpl<7,F>
00160         {
00161             typedef typename boost::function_traits<F>::result_type result_type;
00162             typedef typename boost::function<F>::arg1_type arg1_type;
00163             typedef typename boost::function<F>::arg2_type arg2_type;
00164             typedef typename boost::function<F>::arg3_type arg3_type;
00165             typedef typename boost::function<F>::arg4_type arg4_type;
00166             typedef typename boost::function<F>::arg5_type arg5_type;
00167             typedef typename boost::function<F>::arg6_type arg6_type;
00168             typedef typename boost::function<F>::arg7_type arg7_type;
00169             virtual ~InvokerBaseImpl() {}
00170             virtual result_type call(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5, arg6_type a6, arg7_type a7) = 0;
00171             virtual SendHandle<F> send(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5, arg6_type a6, arg7_type a7) = 0;
00172         };
00173    }
00174 }
00175 #endif