Orocos Real-Time Toolkit  2.8.3
InvokerSignature.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: FMTC do nov 2 13:05:58 CET 2006 Invoker.hpp
3 
4  Invoker.hpp - description
5  -------------------
6  begin : do november 02 2006
7  copyright : (C) 2006 FMTC
8  email : peter.soetens@fmtc.be
9 
10  ***************************************************************************
11  * This library is free software; you can redistribute it and/or *
12  * modify it under the terms of the GNU General Public *
13  * License as published by the Free Software Foundation; *
14  * version 2 of the License. *
15  * *
16  * As a special exception, you may use this file as part of a free *
17  * software library without restriction. Specifically, if other files *
18  * instantiate templates or use macros or inline functions from this *
19  * file, or you compile this file and link it with other files to *
20  * produce an executable, this file does not by itself cause the *
21  * resulting executable to be covered by the GNU General Public *
22  * License. This exception does not however invalidate any other *
23  * reasons why the executable file might be covered by the GNU General *
24  * Public License. *
25  * *
26  * This library is distributed in the hope that it will be useful, *
27  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
28  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
29  * Lesser General Public License for more details. *
30  * *
31  * You should have received a copy of the GNU General Public *
32  * License along with this library; if not, write to the Free Software *
33  * Foundation, Inc., 59 Temple Place, *
34  * Suite 330, Boston, MA 02111-1307 USA *
35  * *
36  ***************************************************************************/
37 
38 
39 #ifndef ORO_INVOKER_SIGNATURE_HPP
40 #define ORO_INVOKER_SIGNATURE_HPP
41 
42 #include <boost/type_traits.hpp>
43 #include "NA.hpp"
44 #include "../rtt-fwd.hpp"
45 
46 namespace RTT
47 {
48  namespace internal
49  {
57  template<int, class Signature, class ToInvoke>
59 
60  template<class F, class ToInvoke>
61  struct InvokerSignature<0,F,ToInvoke>
62  {
63  typedef typename boost::function_traits<F>::result_type result_type;
64 
65  InvokerSignature() : impl() {}
66  InvokerSignature(ToInvoke implementation) : impl(implementation) {}
68 
72  result_type operator()()
73  {
74  if (impl)
75  return impl->call();
76  return NA<result_type>::na();
77  }
78 
79  result_type call() {
80  return operator()();
81  }
82 
84  {
85  if (impl)
86  return impl->send();
87  return SendHandle<F>();
88  }
89 
90  protected:
91  ToInvoke impl;
92  };
93 
94  template<class F, class ToInvoke>
95  struct InvokerSignature<1,F,ToInvoke>
96  {
97  typedef typename boost::function_traits<F>::result_type result_type;
98  typedef typename boost::function_traits<F>::arg1_type arg1_type;
99 
100  InvokerSignature() : impl() {}
101  InvokerSignature(ToInvoke implementation) : impl(implementation) {}
103 
107  result_type operator()(arg1_type a1)
108  {
109  if (impl)
110  return impl->call( a1 );
111  return NA<result_type>::na();
112  }
113  result_type call(arg1_type a1) {
114  return operator()(a1);
115  }
116 
117  SendHandle<F> send(arg1_type a1)
118  {
119  if (impl)
120  return impl->send(a1);
121  return SendHandle<F>();
122  }
123 
124  protected:
125  ToInvoke impl;
126  };
127 
128  template<class F, class ToInvoke>
129  struct InvokerSignature<2,F,ToInvoke>
130  {
131  typedef typename boost::function_traits<F>::result_type result_type;
132  typedef typename boost::function_traits<F>::arg1_type arg1_type;
133  typedef typename boost::function_traits<F>::arg2_type arg2_type;
134 
135  InvokerSignature() : impl() {}
136  InvokerSignature(ToInvoke implementation) : impl(implementation) {}
138 
142  result_type operator()(arg1_type t1, arg2_type t2)
143  {
144  if (impl)
145  return impl->call(t1, t2);
146  return NA<result_type>::na();
147  }
148 
149  result_type call(arg1_type a1, arg2_type a2) {
150  return operator()(a1,a2);
151  }
152 
153  SendHandle<F> send(arg1_type a1, arg2_type a2)
154  {
155  if (impl)
156  return impl->send(a1,a2);
157  return SendHandle<F>();
158  }
159  protected:
160  ToInvoke impl;
161  };
162 
163  template<class F, class ToInvoke>
164  struct InvokerSignature<3,F,ToInvoke>
165  {
166  typedef typename boost::function_traits<F>::result_type result_type;
167  typedef typename boost::function_traits<F>::arg1_type arg1_type;
168  typedef typename boost::function_traits<F>::arg2_type arg2_type;
169  typedef typename boost::function_traits<F>::arg3_type arg3_type;
170 
171  InvokerSignature() : impl() {}
172  InvokerSignature(ToInvoke implementation) : impl(implementation) {}
174 
178  result_type operator()(arg1_type t1, arg2_type t2, arg3_type t3)
179  {
180  if (impl)
181  return impl->call(t1, t2, t3);
182  return NA<result_type>::na();
183  }
184 
185  result_type call(arg1_type a1, arg2_type a2, arg3_type a3) {
186  return operator()(a1,a2,a3);
187  }
188 
189  SendHandle<F> send(arg1_type a1, arg2_type a2, arg3_type a3)
190  {
191  if (impl)
192  return impl->send(a1,a2,a3);
193  return SendHandle<F>();
194  }
195  protected:
196  ToInvoke impl;
197  };
198 
199  template<class F, class ToInvoke>
200  struct InvokerSignature<4,F,ToInvoke>
201  {
202  typedef typename boost::function_traits<F>::result_type result_type;
203  typedef typename boost::function_traits<F>::arg1_type arg1_type;
204  typedef typename boost::function_traits<F>::arg2_type arg2_type;
205  typedef typename boost::function_traits<F>::arg3_type arg3_type;
206  typedef typename boost::function_traits<F>::arg4_type arg4_type;
207 
208  InvokerSignature() : impl() {}
209  InvokerSignature(ToInvoke implementation) : impl(implementation) {}
211 
215  result_type operator()(arg1_type t1, arg2_type t2, arg3_type t3, arg4_type t4)
216  {
217  if (impl)
218  return impl->call(t1, t2, t3, t4);
219  return NA<result_type>::na();
220  }
221 
222  result_type call(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4) {
223  return operator()(a1,a2,a3,a4);
224  }
225 
226  SendHandle<F> send(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4)
227  {
228  if (impl)
229  return impl->send(a1,a2,a3,a4);
230  return SendHandle<F>();
231  }
232 
233  protected:
234  ToInvoke impl;
235  };
236 
237  template<class F, class ToInvoke>
238  struct InvokerSignature<5,F,ToInvoke>
239  {
240  typedef typename boost::function_traits<F>::result_type result_type;
241  typedef typename boost::function_traits<F>::arg1_type arg1_type;
242  typedef typename boost::function_traits<F>::arg2_type arg2_type;
243  typedef typename boost::function_traits<F>::arg3_type arg3_type;
244  typedef typename boost::function_traits<F>::arg4_type arg4_type;
245  typedef typename boost::function_traits<F>::arg5_type arg5_type;
246 
247  InvokerSignature() : impl() {}
248  InvokerSignature(ToInvoke implementation) : impl(implementation) {}
250 
254  result_type operator()(arg1_type t1, arg2_type t2, arg3_type t3, arg4_type t4, arg5_type t5)
255  {
256  if (impl)
257  return impl->call(t1, t2, t3, t4, t5);
258  return NA<result_type>::na();
259  }
260 
261  result_type call(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5) {
262  return operator()(a1,a2,a3,a4,a5);
263  }
264 
265  SendHandle<F> send(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5)
266  {
267  if (impl)
268  return impl->send(a1,a2,a3,a4,a5);
269  return SendHandle<F>();
270  }
271 
272  protected:
273  ToInvoke impl;
274  };
275 
276  template<class F, class ToInvoke>
277  struct InvokerSignature<6,F,ToInvoke>
278  {
279  typedef typename boost::function_traits<F>::result_type result_type;
280  typedef typename boost::function_traits<F>::arg1_type arg1_type;
281  typedef typename boost::function_traits<F>::arg2_type arg2_type;
282  typedef typename boost::function_traits<F>::arg3_type arg3_type;
283  typedef typename boost::function_traits<F>::arg4_type arg4_type;
284  typedef typename boost::function_traits<F>::arg5_type arg5_type;
285  typedef typename boost::function_traits<F>::arg6_type arg6_type;
286 
287  InvokerSignature() : impl() {}
288  InvokerSignature(ToInvoke implementation) : impl(implementation) {}
290 
294  result_type operator()(arg1_type t1, arg2_type t2, arg3_type t3, arg4_type t4, arg5_type t5, arg6_type t6)
295  {
296  if (impl)
297  return impl->call(t1, t2, t3, t4, t5, t6);
298  return NA<result_type>::na();
299  }
300 
301  result_type call(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5, arg6_type a6) {
302  return operator()(a1,a2,a3,a4,a5,a6);
303  }
304 
305  SendHandle<F> send(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5, arg6_type a6)
306  {
307  if (impl)
308  return impl->send(a1,a2,a3,a4,a5,a6);
309  return SendHandle<F>();
310  }
311 
312  protected:
313  ToInvoke impl;
314  };
315 
316  template<class F, class ToInvoke>
317  struct InvokerSignature<7,F,ToInvoke>
318  {
319  typedef typename boost::function_traits<F>::result_type result_type;
320  typedef typename boost::function_traits<F>::arg1_type arg1_type;
321  typedef typename boost::function_traits<F>::arg2_type arg2_type;
322  typedef typename boost::function_traits<F>::arg3_type arg3_type;
323  typedef typename boost::function_traits<F>::arg4_type arg4_type;
324  typedef typename boost::function_traits<F>::arg5_type arg5_type;
325  typedef typename boost::function_traits<F>::arg6_type arg6_type;
326  typedef typename boost::function_traits<F>::arg7_type arg7_type;
327 
328  InvokerSignature() : impl() {}
329  InvokerSignature(ToInvoke implementation) : impl(implementation) {}
331 
335  result_type operator()(arg1_type t1, arg2_type t2, arg3_type t3, arg4_type t4, arg5_type t5, arg6_type t6, arg7_type t7)
336  {
337  if (impl)
338  return impl->call(t1, t2, t3, t4, t5, t6, t7);
339  return NA<result_type>::na();
340  }
341 
342  result_type call(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5, arg6_type a6, arg7_type a7) {
343  return operator()(a1,a2,a3,a4,a5,a6,a7);
344  }
345 
346  SendHandle<F> send(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5, arg6_type a6, arg7_type a7)
347  {
348  if (impl)
349  return impl->send(a1,a2,a3,a4,a5,a6,a7);
350  return SendHandle<F>();
351  }
352 
353  protected:
354  ToInvoke impl;
355  };
356 
357  }
358 }
359 #endif
result_type operator()(arg1_type t1, arg2_type t2, arg3_type t3)
Invoke this operator if the method has three arguments.
result_type operator()(arg1_type t1, arg2_type t2, arg3_type t3, arg4_type t4, arg5_type t5, arg6_type t6)
Invoke this operator if the method has four arguments.
boost::function_traits< F >::arg5_type arg5_type
boost::function_traits< F >::arg6_type arg6_type
result_type operator()(arg1_type t1, arg2_type t2, arg3_type t3, arg4_type t4)
Invoke this operator if the method has four arguments.
boost::function_traits< F >::arg4_type arg4_type
boost::function_traits< F >::arg2_type arg2_type
boost::function_traits< F >::arg2_type arg2_type
result_type operator()()
Invoke this operator if the method has no arguments.
SendHandle< F > send(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5)
boost::function_traits< F >::arg1_type arg1_type
result_type operator()(arg1_type a1)
Invoke this operator if the method has one argument.
SendHandle< F > send(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4)
result_type call(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4)
static T na()
Definition: NA.hpp:57
boost::function_traits< F >::arg4_type arg4_type
boost::function_traits< F >::arg2_type arg2_type
SendHandle< F > send(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5, arg6_type a6, arg7_type a7)
boost::function_traits< F >::arg5_type arg5_type
boost::function_traits< F >::arg2_type arg2_type
boost::function_traits< F >::result_type result_type
boost::function_traits< F >::arg2_type arg2_type
boost::function_traits< F >::arg2_type arg2_type
boost::function_traits< F >::arg1_type arg1_type
boost::function_traits< F >::arg1_type arg1_type
boost::function_traits< F >::arg1_type arg1_type
result_type operator()(arg1_type t1, arg2_type t2, arg3_type t3, arg4_type t4, arg5_type t5, arg6_type t6, arg7_type t7)
Invoke this operator if the method has four arguments.
The SendHandle is used to collect the result values of an asynchronous invocation.
Definition: rtt-fwd.hpp:79
result_type call(arg1_type a1, arg2_type a2, arg3_type a3)
boost::function_traits< F >::arg7_type arg7_type
boost::function_traits< F >::arg6_type arg6_type
boost::function_traits< F >::result_type result_type
result_type call(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5, arg6_type a6)
Used by various classes to define operator(), given a Signature.
result_type call(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5, arg6_type a6, arg7_type a7)
boost::function_traits< F >::arg3_type arg3_type
result_type call(arg1_type a1, arg2_type a2)
SendHandle< F > send(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5, arg6_type a6)
boost::function_traits< F >::arg1_type arg1_type
boost::function_traits< F >::result_type result_type
boost::function_traits< F >::result_type result_type
boost::function_traits< F >::arg3_type arg3_type
boost::function_traits< F >::arg3_type arg3_type
boost::function_traits< F >::arg3_type arg3_type
boost::function_traits< F >::arg4_type arg4_type
SendHandle< F > send(arg1_type a1, arg2_type a2, arg3_type a3)
result_type call(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5)
boost::function_traits< F >::result_type result_type
boost::function_traits< F >::result_type result_type
boost::function_traits< F >::arg3_type arg3_type
boost::function_traits< F >::result_type result_type
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:51
result_type operator()(arg1_type t1, arg2_type t2, arg3_type t3, arg4_type t4, arg5_type t5)
Invoke this operator if the method has four arguments.
boost::function_traits< F >::result_type result_type
boost::function_traits< F >::arg1_type arg1_type
boost::function_traits< F >::arg1_type arg1_type
boost::function_traits< F >::arg4_type arg4_type
boost::function_traits< F >::arg5_type arg5_type
SendHandle< F > send(arg1_type a1, arg2_type a2)
result_type operator()(arg1_type t1, arg2_type t2)
Invoke this operator if the method has two arguments.