17 #include <type_traits>  
   25     CallableContainer(
void);
 
   26     virtual ~CallableContainer(
void);
 
   27     virtual size_t getNumArgs(
void) 
const = 0;
 
   28     virtual const std::type_info &type(
const int argNo) = 0;
 
   29     virtual Object call(
const Object *args) = 0;
 
   34 template <
typename ValueType>
 
   41 #for $NARGS in range($MAX_ARGS+1) 
   45 template <
typename ReturnType, $expand('
typename A%d', $NARGS)>
 
   46 struct CallableFunctionContainer$(NARGS) : Detail::CallableContainer
 
   48     template <
typename FcnType>
 
   49     CallableFunctionContainer$(NARGS)(
const FcnType &fcn):
 
   50         _fcn(std::bind(fcn, $expand(
'std::placeholders::_$(%d+1)', $NARGS)))
 
   55     size_t getNumArgs(
void)
 const 
   60     const std::type_info &type(
const int $optarg(
'argNo', $NARGS))
 
   62         #for $i in range($NARGS): 
   63         if (argNo == $i) 
return typeid(A$i);
 
   65         return typeid(ReturnType);
 
   68     Object call(
const Object * $optarg(
'args', $NARGS))
 
   70         #for $i in range($NARGS): 
   71         auto &a$i = args[$i].
extract<A$i>();
 
   74             decltype(_fcn), std::is_void<ReturnType>::value
 
   75         >::call(_fcn, $expand(
'a%d', $NARGS));
 
   79     template <
typename FcnType, 
bool Condition> 
struct CallHelper;
 
   80     template <
typename FcnType> 
struct CallHelper<FcnType, false>
 
   82         static Object call(
const FcnType &fcn, $expand(
'const A%d &a%d', $NARGS))
 
   87     template <
typename FcnType> 
struct CallHelper<FcnType, true>
 
   89         static Object call(
const FcnType &fcn, $expand(
'const A%d &a%d', $NARGS))
 
   91             fcn($expand(
'a%d', $NARGS)); 
return Object();
 
   95     std::function<ReturnType($expand('A%d', $NARGS))> _fcn;
 
   98 template <
typename ClassType, $expand('
typename A%d', $NARGS)>
 
   99 ClassType CallableFactoryWrapper($expand(
'const A%d &a%d', $NARGS))
 
  101     return ClassType($expand(
'a%d', $NARGS));
 
  104 template <
typename ClassType, $expand('
typename A%d', $NARGS)>
 
  105 ClassType *CallableFactoryNewWrapper($expand(
'const A%d &a%d', $NARGS))
 
  107     return new ClassType($expand(
'a%d', $NARGS));
 
  110 template <
typename ClassType, $expand('
typename A%d', $NARGS)>
 
  111 std::shared_ptr<ClassType> CallableFactorySharedWrapper($expand(
'const A%d &a%d', $NARGS))
 
  113     return std::shared_ptr<ClassType>(
new ClassType($expand(
'a%d', $NARGS)));
 
  119 #for $NARGS in range($MAX_ARGS) 
  123 template <
typename ReturnType, 
typename ClassType, $expand('
typename A%d', $NARGS)>
 
  125     _impl(new Detail::CallableFunctionContainer$(NARGS+1)<ReturnType, ClassType &, $expand(
'A%d', $NARGS)>(fcn))
 
  130 template <
typename ReturnType, 
typename ClassType, $expand('
typename A%d', $NARGS)>
 
  132     _impl(new Detail::CallableFunctionContainer$(NARGS+1)<ReturnType, const ClassType &, $expand(
'A%d', $NARGS)>(fcn))
 
  137 template <
typename ReturnType, $expand('
typename A%d', $NARGS)>
 
  139     _impl(new Detail::CallableFunctionContainer$(NARGS)<ReturnType, $expand(
'A%d', $NARGS)>(fcn))
 
  144 template <$expand('
typename A%d', $NARGS), 
typename ReturnType, 
typename ClassType>
 
  150 template <$expand('
typename A%d', $NARGS), 
typename ReturnType, 
typename ClassType>
 
  156 template <$expand('
typename A%d', $NARGS), 
typename ReturnType>
 
  162 template <
typename ClassType, $expand('
typename A%d', $NARGS)>
 
  165     return Callable(&Detail::CallableFactoryWrapper<ClassType, $expand(
'A%d', $NARGS)>);
 
  168 template <
typename ClassType, $expand('
typename A%d', $NARGS)>
 
  171     return Callable(&Detail::CallableFactoryNewWrapper<ClassType, $expand(
'A%d', $NARGS)>);
 
  174 template <
typename ClassType, $expand('
typename A%d', $NARGS)>
 
  177     return Callable(&Detail::CallableFactorySharedWrapper<ClassType, $expand(
'A%d', $NARGS)>);
 
#define POTHOS_API
Definition: Config.hpp:41
 
Callable & bind(ValueType &&val, const size_t argNo)
Definition: CallableImpl.tmpl.hpp:35
 
static Callable make(ReturnType(ClassType::*fcn)($expand('A%d', $NARGS)))
Definition: CallableImpl.tmpl.hpp:145
 
static Object make(ValueType &&value)
Definition: ObjectImpl.hpp:210
 
Definition: Callable.tmpl.hpp:30
 
static Callable factoryShared(void)
Definition: CallableImpl.tmpl.hpp:175
 
const ValueType & extract(void) const 
Definition: ObjectImpl.hpp:225
 
static Callable factoryNew(void)
Definition: CallableImpl.tmpl.hpp:169
 
static Callable factory(void)
Definition: CallableImpl.tmpl.hpp:163