Pothos  0.2.1-g9f04573d
The Pothos dataflow programming software suite
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros
CallInterfaceImpl.tmpl.hpp
Go to the documentation of this file.
1 
11 #pragma once
12 #include <Pothos/Config.hpp>
16 #include <utility> //std::forward
17 
18 namespace Pothos {
19 
20 #for $NARGS in range($MAX_ARGS)
21 /***********************************************************************
22  * Templated call gateways with $(NARGS) args
23  **********************************************************************/
24 template <typename ReturnType, $expand('typename A%d', $NARGS)>
25 ReturnType CallInterface::call($expand('A%d &&a%d', $NARGS)) const
26 {
27  Object r = this->callObject($expand('std::forward<A%d>(a%d)', $NARGS));
28  try
29  {
30  return r.convert<ReturnType>();
31  }
32  catch(const Exception &ex)
33  {
34  throw CallableReturnError("Pothos::Callable::call()", ex);
35  }
36 }
37 
38 #cond $NARGS > 0
39 template <$expand('typename A%d', $NARGS)>
40 Object CallInterface::callObject($expand('A%d &&a%d', $NARGS)) const
41 {
42  Object args[$(max(1, $NARGS))];
43  #for $i in range($NARGS):
44  args[$i] = Object(std::forward<A$i>(a$i));
45  #end for
46  return this->opaqueCall(args, $NARGS);
47 }
48 
49 template <$expand('typename A%d', $NARGS)>
50 void CallInterface::callVoid($expand('A%d &&a%d', $NARGS)) const
51 {
52  this->callObject($expand('std::forward<A%d>(a%d)', $NARGS));
53 }
54 #end if
55 
56 #end for
57 } //namespace Pothos
virtual Object opaqueCall(const Object *inputArgs, const size_t numArgs) const =0
ReturnType call() const
Call a bound method/function with a return type and 0 args.
Definition: CallInterfaceImpl.hpp:24
Object callObject() const
Call a bound method/function with an Object return and 0 args.
Definition: CallInterface.tmpl.hpp:57
void callVoid() const
Call a bound method/function with a void return and 0 args.
Definition: CallInterface.tmpl.hpp:62
Definition: Object.hpp:55
ValueType convert(void) const
Definition: ObjectImpl.hpp:227
Definition: Exception.hpp:65