Pothos  0.4.3-gabce2ce6
The Pothos dataflow programming software suite
CallInterfaceImpl.hpp
Go to the documentation of this file.
1 
11 #pragma once
12 #include <Pothos/Config.hpp>
16 #include <utility> //std::forward
17 #include <array>
18 
19 namespace Pothos {
20 
21 template <typename ReturnType, typename... ArgsType>
22 ReturnType CallInterface::call(ArgsType&&... args) const
23 {
24  Object r = this->callObject(std::forward<ArgsType>(args)...);
25  try
26  {
27  return r.convert<ReturnType>();
28  }
29  catch(const Exception &ex)
30  {
31  throw CallableReturnError("Pothos::Callable::call()", ex);
32  }
33 }
34 
35 template <typename... ArgsType>
36 Object CallInterface::callObject(ArgsType&&... args) const
37 {
38  const std::array<Object, sizeof...(ArgsType)> objArgs{{Object(std::forward<ArgsType>(args))...}};
39  return this->opaqueCall(objArgs.data(), sizeof...(args));
40 }
41 
42 template <typename... ArgsType>
43 void CallInterface::callVoid(ArgsType&&... args) const
44 {
45  this->callObject(std::forward<ArgsType>(args)...);
46 }
47 
48 } //namespace Pothos
virtual Object opaqueCall(const Object *inputArgs, const size_t numArgs) const =0
Definition: CallInterface.hpp:15
ReturnType call(ArgsType &&...args) const
Call a bound method/function with a return type and variable args.
Definition: CallInterfaceImpl.hpp:22
Definition: Object.hpp:55
ValueType convert(void) const
Definition: ObjectImpl.hpp:227
Object callObject(ArgsType &&...args) const
Call a bound method/function with an Object return and variable args.
Definition: CallInterfaceImpl.hpp:36
void callVoid(ArgsType &&...args) const
Call a bound method/function with a void return and variable args.
Definition: CallInterfaceImpl.hpp:43
Definition: Exception.hpp:65