Pothos  0.7.0-gf7fbae99
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->call(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::call(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 Object CallInterface::callObject(ArgsType&&... args) const
44 {
45  return this->call(std::forward<ArgsType>(args)...);
46 }
47 
48 template <typename... ArgsType>
49 void CallInterface::callVoid(ArgsType&&... args) const
50 {
51  this->call(std::forward<ArgsType>(args)...);
52 }
53 
54 } //namespace Pothos
virtual Object opaqueCall(const Object *inputArgs, const size_t numArgs) const =0
Object callObject(ArgsType &&... args) const
Definition: CallInterfaceImpl.hpp:43
Definition: ArchiveEntry.hpp:20
Definition: Object.hpp:47
ValueType convert(void) const
Definition: ObjectImpl.hpp:165
ReturnType call(ArgsType &&... args) const
Call a bound method/function with a return type and variable args.
Definition: CallInterfaceImpl.hpp:22
Definition: Exception.hpp:65
void callVoid(ArgsType &&... args) const
Definition: CallInterfaceImpl.hpp:49