Pothos  0.2.1-g9f04573d
The Pothos dataflow programming software suite
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros
CallableImpl.hpp
Go to the documentation of this file.
1 
11 #pragma once
12 #include <Pothos/Config.hpp>
16 #include <functional> //std::function
17 #include <type_traits> //std::type_info, std::is_void
18 #include <utility> //std::forward
19 
20 namespace Pothos {
21 namespace Detail {
22 
23 struct POTHOS_API CallableContainer
24 {
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;
30 };
31 
32 } //namespace Detail
33 
34 template <typename ValueType>
35 Callable &Callable::bind(ValueType &&val, const size_t argNo)
36 {
37  return this->bind(Object::make(std::forward<ValueType>(val)), argNo);
38 }
39 
40 namespace Detail {
41 /***********************************************************************
42  * Function specialization for return type with 0 args
43  **********************************************************************/
44 template <typename ReturnType>
45 struct CallableFunctionContainer0 : Detail::CallableContainer
46 {
47  template <typename FcnType>
48  CallableFunctionContainer0(const FcnType &fcn):
49  _fcn(std::bind(fcn))
50  {
51  return;
52  }
53 
54  size_t getNumArgs(void) const
55  {
56  return 0;
57  }
58 
59  const std::type_info &type(const int /*argNo*/)
60  {
61  return typeid(ReturnType);
62  }
63 
64  Object call(const Object * /*args*/)
65  {
66  return CallHelper<
67  decltype(_fcn), std::is_void<ReturnType>::value
68  >::call(_fcn);
69  }
70 
72  template <typename FcnType, bool Condition> struct CallHelper;
73  template <typename FcnType> struct CallHelper<FcnType, false>
74  {
75  static Object call(const FcnType &fcn)
76  {
77  return Object::make(fcn());
78  }
79  };
80  template <typename FcnType> struct CallHelper<FcnType, true>
81  {
82  static Object call(const FcnType &fcn)
83  {
84  fcn(); return Object();
85  }
86  };
87 
88  std::function<ReturnType()> _fcn;
89 };
90 
91 template <typename ClassType>
92 ClassType CallableFactoryWrapper()
93 {
94  return ClassType();
95 }
96 
97 template <typename ClassType>
98 ClassType *CallableFactoryNewWrapper()
99 {
100  return new ClassType();
101 }
102 
103 template <typename ClassType>
104 std::shared_ptr<ClassType> CallableFactorySharedWrapper()
105 {
106  return std::shared_ptr<ClassType>(new ClassType());
107 }
108 /***********************************************************************
109  * Function specialization for return type with 1 args
110  **********************************************************************/
111 template <typename ReturnType, typename A0>
112 struct CallableFunctionContainer1 : Detail::CallableContainer
113 {
114  template <typename FcnType>
115  CallableFunctionContainer1(const FcnType &fcn):
116  _fcn(std::bind(fcn, std::placeholders::_1))
117  {
118  return;
119  }
120 
121  size_t getNumArgs(void) const
122  {
123  return 1;
124  }
125 
126  const std::type_info &type(const int argNo)
127  {
128  if (argNo == 0) return typeid(A0);
129  return typeid(ReturnType);
130  }
131 
132  Object call(const Object * args)
133  {
134  auto &a0 = args[0].extract<A0>();
135  return CallHelper<
136  decltype(_fcn), std::is_void<ReturnType>::value
137  >::call(_fcn, a0);
138  }
139 
141  template <typename FcnType, bool Condition> struct CallHelper;
142  template <typename FcnType> struct CallHelper<FcnType, false>
143  {
144  static Object call(const FcnType &fcn, const A0 &a0)
145  {
146  return Object::make(fcn(a0));
147  }
148  };
149  template <typename FcnType> struct CallHelper<FcnType, true>
150  {
151  static Object call(const FcnType &fcn, const A0 &a0)
152  {
153  fcn(a0); return Object();
154  }
155  };
156 
157  std::function<ReturnType(A0)> _fcn;
158 };
159 
160 template <typename ClassType, typename A0>
161 ClassType CallableFactoryWrapper(const A0 &a0)
162 {
163  return ClassType(a0);
164 }
165 
166 template <typename ClassType, typename A0>
167 ClassType *CallableFactoryNewWrapper(const A0 &a0)
168 {
169  return new ClassType(a0);
170 }
171 
172 template <typename ClassType, typename A0>
173 std::shared_ptr<ClassType> CallableFactorySharedWrapper(const A0 &a0)
174 {
175  return std::shared_ptr<ClassType>(new ClassType(a0));
176 }
177 /***********************************************************************
178  * Function specialization for return type with 2 args
179  **********************************************************************/
180 template <typename ReturnType, typename A0, typename A1>
181 struct CallableFunctionContainer2 : Detail::CallableContainer
182 {
183  template <typename FcnType>
184  CallableFunctionContainer2(const FcnType &fcn):
185  _fcn(std::bind(fcn, std::placeholders::_1, std::placeholders::_2))
186  {
187  return;
188  }
189 
190  size_t getNumArgs(void) const
191  {
192  return 2;
193  }
194 
195  const std::type_info &type(const int argNo)
196  {
197  if (argNo == 0) return typeid(A0);
198  if (argNo == 1) return typeid(A1);
199  return typeid(ReturnType);
200  }
201 
202  Object call(const Object * args)
203  {
204  auto &a0 = args[0].extract<A0>();
205  auto &a1 = args[1].extract<A1>();
206  return CallHelper<
207  decltype(_fcn), std::is_void<ReturnType>::value
208  >::call(_fcn, a0, a1);
209  }
210 
212  template <typename FcnType, bool Condition> struct CallHelper;
213  template <typename FcnType> struct CallHelper<FcnType, false>
214  {
215  static Object call(const FcnType &fcn, const A0 &a0, const A1 &a1)
216  {
217  return Object::make(fcn(a0, a1));
218  }
219  };
220  template <typename FcnType> struct CallHelper<FcnType, true>
221  {
222  static Object call(const FcnType &fcn, const A0 &a0, const A1 &a1)
223  {
224  fcn(a0, a1); return Object();
225  }
226  };
227 
228  std::function<ReturnType(A0, A1)> _fcn;
229 };
230 
231 template <typename ClassType, typename A0, typename A1>
232 ClassType CallableFactoryWrapper(const A0 &a0, const A1 &a1)
233 {
234  return ClassType(a0, a1);
235 }
236 
237 template <typename ClassType, typename A0, typename A1>
238 ClassType *CallableFactoryNewWrapper(const A0 &a0, const A1 &a1)
239 {
240  return new ClassType(a0, a1);
241 }
242 
243 template <typename ClassType, typename A0, typename A1>
244 std::shared_ptr<ClassType> CallableFactorySharedWrapper(const A0 &a0, const A1 &a1)
245 {
246  return std::shared_ptr<ClassType>(new ClassType(a0, a1));
247 }
248 /***********************************************************************
249  * Function specialization for return type with 3 args
250  **********************************************************************/
251 template <typename ReturnType, typename A0, typename A1, typename A2>
252 struct CallableFunctionContainer3 : Detail::CallableContainer
253 {
254  template <typename FcnType>
255  CallableFunctionContainer3(const FcnType &fcn):
256  _fcn(std::bind(fcn, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3))
257  {
258  return;
259  }
260 
261  size_t getNumArgs(void) const
262  {
263  return 3;
264  }
265 
266  const std::type_info &type(const int argNo)
267  {
268  if (argNo == 0) return typeid(A0);
269  if (argNo == 1) return typeid(A1);
270  if (argNo == 2) return typeid(A2);
271  return typeid(ReturnType);
272  }
273 
274  Object call(const Object * args)
275  {
276  auto &a0 = args[0].extract<A0>();
277  auto &a1 = args[1].extract<A1>();
278  auto &a2 = args[2].extract<A2>();
279  return CallHelper<
280  decltype(_fcn), std::is_void<ReturnType>::value
281  >::call(_fcn, a0, a1, a2);
282  }
283 
285  template <typename FcnType, bool Condition> struct CallHelper;
286  template <typename FcnType> struct CallHelper<FcnType, false>
287  {
288  static Object call(const FcnType &fcn, const A0 &a0, const A1 &a1, const A2 &a2)
289  {
290  return Object::make(fcn(a0, a1, a2));
291  }
292  };
293  template <typename FcnType> struct CallHelper<FcnType, true>
294  {
295  static Object call(const FcnType &fcn, const A0 &a0, const A1 &a1, const A2 &a2)
296  {
297  fcn(a0, a1, a2); return Object();
298  }
299  };
300 
301  std::function<ReturnType(A0, A1, A2)> _fcn;
302 };
303 
304 template <typename ClassType, typename A0, typename A1, typename A2>
305 ClassType CallableFactoryWrapper(const A0 &a0, const A1 &a1, const A2 &a2)
306 {
307  return ClassType(a0, a1, a2);
308 }
309 
310 template <typename ClassType, typename A0, typename A1, typename A2>
311 ClassType *CallableFactoryNewWrapper(const A0 &a0, const A1 &a1, const A2 &a2)
312 {
313  return new ClassType(a0, a1, a2);
314 }
315 
316 template <typename ClassType, typename A0, typename A1, typename A2>
317 std::shared_ptr<ClassType> CallableFactorySharedWrapper(const A0 &a0, const A1 &a1, const A2 &a2)
318 {
319  return std::shared_ptr<ClassType>(new ClassType(a0, a1, a2));
320 }
321 /***********************************************************************
322  * Function specialization for return type with 4 args
323  **********************************************************************/
324 template <typename ReturnType, typename A0, typename A1, typename A2, typename A3>
325 struct CallableFunctionContainer4 : Detail::CallableContainer
326 {
327  template <typename FcnType>
328  CallableFunctionContainer4(const FcnType &fcn):
329  _fcn(std::bind(fcn, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4))
330  {
331  return;
332  }
333 
334  size_t getNumArgs(void) const
335  {
336  return 4;
337  }
338 
339  const std::type_info &type(const int argNo)
340  {
341  if (argNo == 0) return typeid(A0);
342  if (argNo == 1) return typeid(A1);
343  if (argNo == 2) return typeid(A2);
344  if (argNo == 3) return typeid(A3);
345  return typeid(ReturnType);
346  }
347 
348  Object call(const Object * args)
349  {
350  auto &a0 = args[0].extract<A0>();
351  auto &a1 = args[1].extract<A1>();
352  auto &a2 = args[2].extract<A2>();
353  auto &a3 = args[3].extract<A3>();
354  return CallHelper<
355  decltype(_fcn), std::is_void<ReturnType>::value
356  >::call(_fcn, a0, a1, a2, a3);
357  }
358 
360  template <typename FcnType, bool Condition> struct CallHelper;
361  template <typename FcnType> struct CallHelper<FcnType, false>
362  {
363  static Object call(const FcnType &fcn, const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3)
364  {
365  return Object::make(fcn(a0, a1, a2, a3));
366  }
367  };
368  template <typename FcnType> struct CallHelper<FcnType, true>
369  {
370  static Object call(const FcnType &fcn, const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3)
371  {
372  fcn(a0, a1, a2, a3); return Object();
373  }
374  };
375 
376  std::function<ReturnType(A0, A1, A2, A3)> _fcn;
377 };
378 
379 template <typename ClassType, typename A0, typename A1, typename A2, typename A3>
380 ClassType CallableFactoryWrapper(const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3)
381 {
382  return ClassType(a0, a1, a2, a3);
383 }
384 
385 template <typename ClassType, typename A0, typename A1, typename A2, typename A3>
386 ClassType *CallableFactoryNewWrapper(const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3)
387 {
388  return new ClassType(a0, a1, a2, a3);
389 }
390 
391 template <typename ClassType, typename A0, typename A1, typename A2, typename A3>
392 std::shared_ptr<ClassType> CallableFactorySharedWrapper(const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3)
393 {
394  return std::shared_ptr<ClassType>(new ClassType(a0, a1, a2, a3));
395 }
396 /***********************************************************************
397  * Function specialization for return type with 5 args
398  **********************************************************************/
399 template <typename ReturnType, typename A0, typename A1, typename A2, typename A3, typename A4>
400 struct CallableFunctionContainer5 : Detail::CallableContainer
401 {
402  template <typename FcnType>
403  CallableFunctionContainer5(const FcnType &fcn):
404  _fcn(std::bind(fcn, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5))
405  {
406  return;
407  }
408 
409  size_t getNumArgs(void) const
410  {
411  return 5;
412  }
413 
414  const std::type_info &type(const int argNo)
415  {
416  if (argNo == 0) return typeid(A0);
417  if (argNo == 1) return typeid(A1);
418  if (argNo == 2) return typeid(A2);
419  if (argNo == 3) return typeid(A3);
420  if (argNo == 4) return typeid(A4);
421  return typeid(ReturnType);
422  }
423 
424  Object call(const Object * args)
425  {
426  auto &a0 = args[0].extract<A0>();
427  auto &a1 = args[1].extract<A1>();
428  auto &a2 = args[2].extract<A2>();
429  auto &a3 = args[3].extract<A3>();
430  auto &a4 = args[4].extract<A4>();
431  return CallHelper<
432  decltype(_fcn), std::is_void<ReturnType>::value
433  >::call(_fcn, a0, a1, a2, a3, a4);
434  }
435 
437  template <typename FcnType, bool Condition> struct CallHelper;
438  template <typename FcnType> struct CallHelper<FcnType, false>
439  {
440  static Object call(const FcnType &fcn, const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4)
441  {
442  return Object::make(fcn(a0, a1, a2, a3, a4));
443  }
444  };
445  template <typename FcnType> struct CallHelper<FcnType, true>
446  {
447  static Object call(const FcnType &fcn, const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4)
448  {
449  fcn(a0, a1, a2, a3, a4); return Object();
450  }
451  };
452 
453  std::function<ReturnType(A0, A1, A2, A3, A4)> _fcn;
454 };
455 
456 template <typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4>
457 ClassType CallableFactoryWrapper(const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4)
458 {
459  return ClassType(a0, a1, a2, a3, a4);
460 }
461 
462 template <typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4>
463 ClassType *CallableFactoryNewWrapper(const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4)
464 {
465  return new ClassType(a0, a1, a2, a3, a4);
466 }
467 
468 template <typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4>
469 std::shared_ptr<ClassType> CallableFactorySharedWrapper(const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4)
470 {
471  return std::shared_ptr<ClassType>(new ClassType(a0, a1, a2, a3, a4));
472 }
473 /***********************************************************************
474  * Function specialization for return type with 6 args
475  **********************************************************************/
476 template <typename ReturnType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5>
477 struct CallableFunctionContainer6 : Detail::CallableContainer
478 {
479  template <typename FcnType>
480  CallableFunctionContainer6(const FcnType &fcn):
481  _fcn(std::bind(fcn, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6))
482  {
483  return;
484  }
485 
486  size_t getNumArgs(void) const
487  {
488  return 6;
489  }
490 
491  const std::type_info &type(const int argNo)
492  {
493  if (argNo == 0) return typeid(A0);
494  if (argNo == 1) return typeid(A1);
495  if (argNo == 2) return typeid(A2);
496  if (argNo == 3) return typeid(A3);
497  if (argNo == 4) return typeid(A4);
498  if (argNo == 5) return typeid(A5);
499  return typeid(ReturnType);
500  }
501 
502  Object call(const Object * args)
503  {
504  auto &a0 = args[0].extract<A0>();
505  auto &a1 = args[1].extract<A1>();
506  auto &a2 = args[2].extract<A2>();
507  auto &a3 = args[3].extract<A3>();
508  auto &a4 = args[4].extract<A4>();
509  auto &a5 = args[5].extract<A5>();
510  return CallHelper<
511  decltype(_fcn), std::is_void<ReturnType>::value
512  >::call(_fcn, a0, a1, a2, a3, a4, a5);
513  }
514 
516  template <typename FcnType, bool Condition> struct CallHelper;
517  template <typename FcnType> struct CallHelper<FcnType, false>
518  {
519  static Object call(const FcnType &fcn, const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5)
520  {
521  return Object::make(fcn(a0, a1, a2, a3, a4, a5));
522  }
523  };
524  template <typename FcnType> struct CallHelper<FcnType, true>
525  {
526  static Object call(const FcnType &fcn, const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5)
527  {
528  fcn(a0, a1, a2, a3, a4, a5); return Object();
529  }
530  };
531 
532  std::function<ReturnType(A0, A1, A2, A3, A4, A5)> _fcn;
533 };
534 
535 template <typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5>
536 ClassType CallableFactoryWrapper(const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5)
537 {
538  return ClassType(a0, a1, a2, a3, a4, a5);
539 }
540 
541 template <typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5>
542 ClassType *CallableFactoryNewWrapper(const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5)
543 {
544  return new ClassType(a0, a1, a2, a3, a4, a5);
545 }
546 
547 template <typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5>
548 std::shared_ptr<ClassType> CallableFactorySharedWrapper(const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5)
549 {
550  return std::shared_ptr<ClassType>(new ClassType(a0, a1, a2, a3, a4, a5));
551 }
552 /***********************************************************************
553  * Function specialization for return type with 7 args
554  **********************************************************************/
555 template <typename ReturnType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
556 struct CallableFunctionContainer7 : Detail::CallableContainer
557 {
558  template <typename FcnType>
559  CallableFunctionContainer7(const FcnType &fcn):
560  _fcn(std::bind(fcn, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6, std::placeholders::_7))
561  {
562  return;
563  }
564 
565  size_t getNumArgs(void) const
566  {
567  return 7;
568  }
569 
570  const std::type_info &type(const int argNo)
571  {
572  if (argNo == 0) return typeid(A0);
573  if (argNo == 1) return typeid(A1);
574  if (argNo == 2) return typeid(A2);
575  if (argNo == 3) return typeid(A3);
576  if (argNo == 4) return typeid(A4);
577  if (argNo == 5) return typeid(A5);
578  if (argNo == 6) return typeid(A6);
579  return typeid(ReturnType);
580  }
581 
582  Object call(const Object * args)
583  {
584  auto &a0 = args[0].extract<A0>();
585  auto &a1 = args[1].extract<A1>();
586  auto &a2 = args[2].extract<A2>();
587  auto &a3 = args[3].extract<A3>();
588  auto &a4 = args[4].extract<A4>();
589  auto &a5 = args[5].extract<A5>();
590  auto &a6 = args[6].extract<A6>();
591  return CallHelper<
592  decltype(_fcn), std::is_void<ReturnType>::value
593  >::call(_fcn, a0, a1, a2, a3, a4, a5, a6);
594  }
595 
597  template <typename FcnType, bool Condition> struct CallHelper;
598  template <typename FcnType> struct CallHelper<FcnType, false>
599  {
600  static Object call(const FcnType &fcn, const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6)
601  {
602  return Object::make(fcn(a0, a1, a2, a3, a4, a5, a6));
603  }
604  };
605  template <typename FcnType> struct CallHelper<FcnType, true>
606  {
607  static Object call(const FcnType &fcn, const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6)
608  {
609  fcn(a0, a1, a2, a3, a4, a5, a6); return Object();
610  }
611  };
612 
613  std::function<ReturnType(A0, A1, A2, A3, A4, A5, A6)> _fcn;
614 };
615 
616 template <typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
617 ClassType CallableFactoryWrapper(const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6)
618 {
619  return ClassType(a0, a1, a2, a3, a4, a5, a6);
620 }
621 
622 template <typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
623 ClassType *CallableFactoryNewWrapper(const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6)
624 {
625  return new ClassType(a0, a1, a2, a3, a4, a5, a6);
626 }
627 
628 template <typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
629 std::shared_ptr<ClassType> CallableFactorySharedWrapper(const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6)
630 {
631  return std::shared_ptr<ClassType>(new ClassType(a0, a1, a2, a3, a4, a5, a6));
632 }
633 /***********************************************************************
634  * Function specialization for return type with 8 args
635  **********************************************************************/
636 template <typename ReturnType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7>
637 struct CallableFunctionContainer8 : Detail::CallableContainer
638 {
639  template <typename FcnType>
640  CallableFunctionContainer8(const FcnType &fcn):
641  _fcn(std::bind(fcn, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6, std::placeholders::_7, std::placeholders::_8))
642  {
643  return;
644  }
645 
646  size_t getNumArgs(void) const
647  {
648  return 8;
649  }
650 
651  const std::type_info &type(const int argNo)
652  {
653  if (argNo == 0) return typeid(A0);
654  if (argNo == 1) return typeid(A1);
655  if (argNo == 2) return typeid(A2);
656  if (argNo == 3) return typeid(A3);
657  if (argNo == 4) return typeid(A4);
658  if (argNo == 5) return typeid(A5);
659  if (argNo == 6) return typeid(A6);
660  if (argNo == 7) return typeid(A7);
661  return typeid(ReturnType);
662  }
663 
664  Object call(const Object * args)
665  {
666  auto &a0 = args[0].extract<A0>();
667  auto &a1 = args[1].extract<A1>();
668  auto &a2 = args[2].extract<A2>();
669  auto &a3 = args[3].extract<A3>();
670  auto &a4 = args[4].extract<A4>();
671  auto &a5 = args[5].extract<A5>();
672  auto &a6 = args[6].extract<A6>();
673  auto &a7 = args[7].extract<A7>();
674  return CallHelper<
675  decltype(_fcn), std::is_void<ReturnType>::value
676  >::call(_fcn, a0, a1, a2, a3, a4, a5, a6, a7);
677  }
678 
680  template <typename FcnType, bool Condition> struct CallHelper;
681  template <typename FcnType> struct CallHelper<FcnType, false>
682  {
683  static Object call(const FcnType &fcn, const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7)
684  {
685  return Object::make(fcn(a0, a1, a2, a3, a4, a5, a6, a7));
686  }
687  };
688  template <typename FcnType> struct CallHelper<FcnType, true>
689  {
690  static Object call(const FcnType &fcn, const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7)
691  {
692  fcn(a0, a1, a2, a3, a4, a5, a6, a7); return Object();
693  }
694  };
695 
696  std::function<ReturnType(A0, A1, A2, A3, A4, A5, A6, A7)> _fcn;
697 };
698 
699 template <typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7>
700 ClassType CallableFactoryWrapper(const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7)
701 {
702  return ClassType(a0, a1, a2, a3, a4, a5, a6, a7);
703 }
704 
705 template <typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7>
706 ClassType *CallableFactoryNewWrapper(const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7)
707 {
708  return new ClassType(a0, a1, a2, a3, a4, a5, a6, a7);
709 }
710 
711 template <typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7>
712 std::shared_ptr<ClassType> CallableFactorySharedWrapper(const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7)
713 {
714  return std::shared_ptr<ClassType>(new ClassType(a0, a1, a2, a3, a4, a5, a6, a7));
715 }
716 /***********************************************************************
717  * Function specialization for return type with 9 args
718  **********************************************************************/
719 template <typename ReturnType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8>
720 struct CallableFunctionContainer9 : Detail::CallableContainer
721 {
722  template <typename FcnType>
723  CallableFunctionContainer9(const FcnType &fcn):
724  _fcn(std::bind(fcn, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6, std::placeholders::_7, std::placeholders::_8, std::placeholders::_9))
725  {
726  return;
727  }
728 
729  size_t getNumArgs(void) const
730  {
731  return 9;
732  }
733 
734  const std::type_info &type(const int argNo)
735  {
736  if (argNo == 0) return typeid(A0);
737  if (argNo == 1) return typeid(A1);
738  if (argNo == 2) return typeid(A2);
739  if (argNo == 3) return typeid(A3);
740  if (argNo == 4) return typeid(A4);
741  if (argNo == 5) return typeid(A5);
742  if (argNo == 6) return typeid(A6);
743  if (argNo == 7) return typeid(A7);
744  if (argNo == 8) return typeid(A8);
745  return typeid(ReturnType);
746  }
747 
748  Object call(const Object * args)
749  {
750  auto &a0 = args[0].extract<A0>();
751  auto &a1 = args[1].extract<A1>();
752  auto &a2 = args[2].extract<A2>();
753  auto &a3 = args[3].extract<A3>();
754  auto &a4 = args[4].extract<A4>();
755  auto &a5 = args[5].extract<A5>();
756  auto &a6 = args[6].extract<A6>();
757  auto &a7 = args[7].extract<A7>();
758  auto &a8 = args[8].extract<A8>();
759  return CallHelper<
760  decltype(_fcn), std::is_void<ReturnType>::value
761  >::call(_fcn, a0, a1, a2, a3, a4, a5, a6, a7, a8);
762  }
763 
765  template <typename FcnType, bool Condition> struct CallHelper;
766  template <typename FcnType> struct CallHelper<FcnType, false>
767  {
768  static Object call(const FcnType &fcn, const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8)
769  {
770  return Object::make(fcn(a0, a1, a2, a3, a4, a5, a6, a7, a8));
771  }
772  };
773  template <typename FcnType> struct CallHelper<FcnType, true>
774  {
775  static Object call(const FcnType &fcn, const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8)
776  {
777  fcn(a0, a1, a2, a3, a4, a5, a6, a7, a8); return Object();
778  }
779  };
780 
781  std::function<ReturnType(A0, A1, A2, A3, A4, A5, A6, A7, A8)> _fcn;
782 };
783 
784 template <typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8>
785 ClassType CallableFactoryWrapper(const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8)
786 {
787  return ClassType(a0, a1, a2, a3, a4, a5, a6, a7, a8);
788 }
789 
790 template <typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8>
791 ClassType *CallableFactoryNewWrapper(const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8)
792 {
793  return new ClassType(a0, a1, a2, a3, a4, a5, a6, a7, a8);
794 }
795 
796 template <typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8>
797 std::shared_ptr<ClassType> CallableFactorySharedWrapper(const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8)
798 {
799  return std::shared_ptr<ClassType>(new ClassType(a0, a1, a2, a3, a4, a5, a6, a7, a8));
800 }
801 /***********************************************************************
802  * Function specialization for return type with 10 args
803  **********************************************************************/
804 template <typename ReturnType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9>
805 struct CallableFunctionContainer10 : Detail::CallableContainer
806 {
807  template <typename FcnType>
808  CallableFunctionContainer10(const FcnType &fcn):
809  _fcn(std::bind(fcn, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6, std::placeholders::_7, std::placeholders::_8, std::placeholders::_9, std::placeholders::_10))
810  {
811  return;
812  }
813 
814  size_t getNumArgs(void) const
815  {
816  return 10;
817  }
818 
819  const std::type_info &type(const int argNo)
820  {
821  if (argNo == 0) return typeid(A0);
822  if (argNo == 1) return typeid(A1);
823  if (argNo == 2) return typeid(A2);
824  if (argNo == 3) return typeid(A3);
825  if (argNo == 4) return typeid(A4);
826  if (argNo == 5) return typeid(A5);
827  if (argNo == 6) return typeid(A6);
828  if (argNo == 7) return typeid(A7);
829  if (argNo == 8) return typeid(A8);
830  if (argNo == 9) return typeid(A9);
831  return typeid(ReturnType);
832  }
833 
834  Object call(const Object * args)
835  {
836  auto &a0 = args[0].extract<A0>();
837  auto &a1 = args[1].extract<A1>();
838  auto &a2 = args[2].extract<A2>();
839  auto &a3 = args[3].extract<A3>();
840  auto &a4 = args[4].extract<A4>();
841  auto &a5 = args[5].extract<A5>();
842  auto &a6 = args[6].extract<A6>();
843  auto &a7 = args[7].extract<A7>();
844  auto &a8 = args[8].extract<A8>();
845  auto &a9 = args[9].extract<A9>();
846  return CallHelper<
847  decltype(_fcn), std::is_void<ReturnType>::value
848  >::call(_fcn, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9);
849  }
850 
852  template <typename FcnType, bool Condition> struct CallHelper;
853  template <typename FcnType> struct CallHelper<FcnType, false>
854  {
855  static Object call(const FcnType &fcn, const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9)
856  {
857  return Object::make(fcn(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9));
858  }
859  };
860  template <typename FcnType> struct CallHelper<FcnType, true>
861  {
862  static Object call(const FcnType &fcn, const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9)
863  {
864  fcn(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); return Object();
865  }
866  };
867 
868  std::function<ReturnType(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9)> _fcn;
869 };
870 
871 template <typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9>
872 ClassType CallableFactoryWrapper(const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9)
873 {
874  return ClassType(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9);
875 }
876 
877 template <typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9>
878 ClassType *CallableFactoryNewWrapper(const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9)
879 {
880  return new ClassType(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9);
881 }
882 
883 template <typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9>
884 std::shared_ptr<ClassType> CallableFactorySharedWrapper(const A0 &a0, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9)
885 {
886  return std::shared_ptr<ClassType>(new ClassType(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9));
887 }
888 
889 } //namespace Detail
890 
891 /***********************************************************************
892  * Templated factory/constructor calls with 0 args
893  **********************************************************************/
894 template <typename ReturnType, typename ClassType>
895 Callable::Callable(ReturnType(ClassType::*fcn)()):
896  _impl(new Detail::CallableFunctionContainer1<ReturnType, ClassType &>(fcn))
897 {
898  return;
899 }
900 
901 template <typename ReturnType, typename ClassType>
902 Callable::Callable(ReturnType(ClassType::*fcn)() const):
903  _impl(new Detail::CallableFunctionContainer1<ReturnType, const ClassType &>(fcn))
904 {
905  return;
906 }
907 
908 template <typename ReturnType>
909 Callable::Callable(ReturnType(*fcn)()):
910  _impl(new Detail::CallableFunctionContainer0<ReturnType>(fcn))
911 {
912  return;
913 }
914 
915 template <typename ReturnType, typename ClassType>
916 Callable Callable::make(ReturnType(ClassType::*fcn)())
917 {
918  return Callable(fcn);
919 }
920 
921 template <typename ReturnType, typename ClassType>
922 Callable Callable::make(ReturnType(ClassType::*fcn)() const)
923 {
924  return Callable(fcn);
925 }
926 
927 template <typename ReturnType>
928 Callable Callable::make(ReturnType(*fcn)())
929 {
930  return Callable(fcn);
931 }
932 
933 template <typename ClassType>
935 {
936  return Callable(&Detail::CallableFactoryWrapper<ClassType>);
937 }
938 
939 template <typename ClassType>
941 {
942  return Callable(&Detail::CallableFactoryNewWrapper<ClassType>);
943 }
944 
945 template <typename ClassType>
947 {
948  return Callable(&Detail::CallableFactorySharedWrapper<ClassType>);
949 }
950 
951 /***********************************************************************
952  * Templated factory/constructor calls with 1 args
953  **********************************************************************/
954 template <typename ReturnType, typename ClassType, typename A0>
955 Callable::Callable(ReturnType(ClassType::*fcn)(A0)):
956  _impl(new Detail::CallableFunctionContainer2<ReturnType, ClassType &, A0>(fcn))
957 {
958  return;
959 }
960 
961 template <typename ReturnType, typename ClassType, typename A0>
962 Callable::Callable(ReturnType(ClassType::*fcn)(A0) const):
963  _impl(new Detail::CallableFunctionContainer2<ReturnType, const ClassType &, A0>(fcn))
964 {
965  return;
966 }
967 
968 template <typename ReturnType, typename A0>
969 Callable::Callable(ReturnType(*fcn)(A0)):
970  _impl(new Detail::CallableFunctionContainer1<ReturnType, A0>(fcn))
971 {
972  return;
973 }
974 
975 template <typename A0, typename ReturnType, typename ClassType>
976 Callable Callable::make(ReturnType(ClassType::*fcn)(A0))
977 {
978  return Callable(fcn);
979 }
980 
981 template <typename A0, typename ReturnType, typename ClassType>
982 Callable Callable::make(ReturnType(ClassType::*fcn)(A0) const)
983 {
984  return Callable(fcn);
985 }
986 
987 template <typename A0, typename ReturnType>
988 Callable Callable::make(ReturnType(*fcn)(A0))
989 {
990  return Callable(fcn);
991 }
992 
993 template <typename ClassType, typename A0>
995 {
996  return Callable(&Detail::CallableFactoryWrapper<ClassType, A0>);
997 }
998 
999 template <typename ClassType, typename A0>
1001 {
1002  return Callable(&Detail::CallableFactoryNewWrapper<ClassType, A0>);
1003 }
1004 
1005 template <typename ClassType, typename A0>
1007 {
1008  return Callable(&Detail::CallableFactorySharedWrapper<ClassType, A0>);
1009 }
1010 
1011 /***********************************************************************
1012  * Templated factory/constructor calls with 2 args
1013  **********************************************************************/
1014 template <typename ReturnType, typename ClassType, typename A0, typename A1>
1015 Callable::Callable(ReturnType(ClassType::*fcn)(A0, A1)):
1016  _impl(new Detail::CallableFunctionContainer3<ReturnType, ClassType &, A0, A1>(fcn))
1017 {
1018  return;
1019 }
1020 
1021 template <typename ReturnType, typename ClassType, typename A0, typename A1>
1022 Callable::Callable(ReturnType(ClassType::*fcn)(A0, A1) const):
1023  _impl(new Detail::CallableFunctionContainer3<ReturnType, const ClassType &, A0, A1>(fcn))
1024 {
1025  return;
1026 }
1027 
1028 template <typename ReturnType, typename A0, typename A1>
1029 Callable::Callable(ReturnType(*fcn)(A0, A1)):
1030  _impl(new Detail::CallableFunctionContainer2<ReturnType, A0, A1>(fcn))
1031 {
1032  return;
1033 }
1034 
1035 template <typename A0, typename A1, typename ReturnType, typename ClassType>
1036 Callable Callable::make(ReturnType(ClassType::*fcn)(A0, A1))
1037 {
1038  return Callable(fcn);
1039 }
1040 
1041 template <typename A0, typename A1, typename ReturnType, typename ClassType>
1042 Callable Callable::make(ReturnType(ClassType::*fcn)(A0, A1) const)
1043 {
1044  return Callable(fcn);
1045 }
1046 
1047 template <typename A0, typename A1, typename ReturnType>
1048 Callable Callable::make(ReturnType(*fcn)(A0, A1))
1049 {
1050  return Callable(fcn);
1051 }
1052 
1053 template <typename ClassType, typename A0, typename A1>
1055 {
1056  return Callable(&Detail::CallableFactoryWrapper<ClassType, A0, A1>);
1057 }
1058 
1059 template <typename ClassType, typename A0, typename A1>
1061 {
1062  return Callable(&Detail::CallableFactoryNewWrapper<ClassType, A0, A1>);
1063 }
1064 
1065 template <typename ClassType, typename A0, typename A1>
1067 {
1068  return Callable(&Detail::CallableFactorySharedWrapper<ClassType, A0, A1>);
1069 }
1070 
1071 /***********************************************************************
1072  * Templated factory/constructor calls with 3 args
1073  **********************************************************************/
1074 template <typename ReturnType, typename ClassType, typename A0, typename A1, typename A2>
1075 Callable::Callable(ReturnType(ClassType::*fcn)(A0, A1, A2)):
1076  _impl(new Detail::CallableFunctionContainer4<ReturnType, ClassType &, A0, A1, A2>(fcn))
1077 {
1078  return;
1079 }
1080 
1081 template <typename ReturnType, typename ClassType, typename A0, typename A1, typename A2>
1082 Callable::Callable(ReturnType(ClassType::*fcn)(A0, A1, A2) const):
1083  _impl(new Detail::CallableFunctionContainer4<ReturnType, const ClassType &, A0, A1, A2>(fcn))
1084 {
1085  return;
1086 }
1087 
1088 template <typename ReturnType, typename A0, typename A1, typename A2>
1089 Callable::Callable(ReturnType(*fcn)(A0, A1, A2)):
1090  _impl(new Detail::CallableFunctionContainer3<ReturnType, A0, A1, A2>(fcn))
1091 {
1092  return;
1093 }
1094 
1095 template <typename A0, typename A1, typename A2, typename ReturnType, typename ClassType>
1096 Callable Callable::make(ReturnType(ClassType::*fcn)(A0, A1, A2))
1097 {
1098  return Callable(fcn);
1099 }
1100 
1101 template <typename A0, typename A1, typename A2, typename ReturnType, typename ClassType>
1102 Callable Callable::make(ReturnType(ClassType::*fcn)(A0, A1, A2) const)
1103 {
1104  return Callable(fcn);
1105 }
1106 
1107 template <typename A0, typename A1, typename A2, typename ReturnType>
1108 Callable Callable::make(ReturnType(*fcn)(A0, A1, A2))
1109 {
1110  return Callable(fcn);
1111 }
1112 
1113 template <typename ClassType, typename A0, typename A1, typename A2>
1115 {
1116  return Callable(&Detail::CallableFactoryWrapper<ClassType, A0, A1, A2>);
1117 }
1118 
1119 template <typename ClassType, typename A0, typename A1, typename A2>
1121 {
1122  return Callable(&Detail::CallableFactoryNewWrapper<ClassType, A0, A1, A2>);
1123 }
1124 
1125 template <typename ClassType, typename A0, typename A1, typename A2>
1127 {
1128  return Callable(&Detail::CallableFactorySharedWrapper<ClassType, A0, A1, A2>);
1129 }
1130 
1131 /***********************************************************************
1132  * Templated factory/constructor calls with 4 args
1133  **********************************************************************/
1134 template <typename ReturnType, typename ClassType, typename A0, typename A1, typename A2, typename A3>
1135 Callable::Callable(ReturnType(ClassType::*fcn)(A0, A1, A2, A3)):
1136  _impl(new Detail::CallableFunctionContainer5<ReturnType, ClassType &, A0, A1, A2, A3>(fcn))
1137 {
1138  return;
1139 }
1140 
1141 template <typename ReturnType, typename ClassType, typename A0, typename A1, typename A2, typename A3>
1142 Callable::Callable(ReturnType(ClassType::*fcn)(A0, A1, A2, A3) const):
1143  _impl(new Detail::CallableFunctionContainer5<ReturnType, const ClassType &, A0, A1, A2, A3>(fcn))
1144 {
1145  return;
1146 }
1147 
1148 template <typename ReturnType, typename A0, typename A1, typename A2, typename A3>
1149 Callable::Callable(ReturnType(*fcn)(A0, A1, A2, A3)):
1150  _impl(new Detail::CallableFunctionContainer4<ReturnType, A0, A1, A2, A3>(fcn))
1151 {
1152  return;
1153 }
1154 
1155 template <typename A0, typename A1, typename A2, typename A3, typename ReturnType, typename ClassType>
1156 Callable Callable::make(ReturnType(ClassType::*fcn)(A0, A1, A2, A3))
1157 {
1158  return Callable(fcn);
1159 }
1160 
1161 template <typename A0, typename A1, typename A2, typename A3, typename ReturnType, typename ClassType>
1162 Callable Callable::make(ReturnType(ClassType::*fcn)(A0, A1, A2, A3) const)
1163 {
1164  return Callable(fcn);
1165 }
1166 
1167 template <typename A0, typename A1, typename A2, typename A3, typename ReturnType>
1168 Callable Callable::make(ReturnType(*fcn)(A0, A1, A2, A3))
1169 {
1170  return Callable(fcn);
1171 }
1172 
1173 template <typename ClassType, typename A0, typename A1, typename A2, typename A3>
1175 {
1176  return Callable(&Detail::CallableFactoryWrapper<ClassType, A0, A1, A2, A3>);
1177 }
1178 
1179 template <typename ClassType, typename A0, typename A1, typename A2, typename A3>
1181 {
1182  return Callable(&Detail::CallableFactoryNewWrapper<ClassType, A0, A1, A2, A3>);
1183 }
1184 
1185 template <typename ClassType, typename A0, typename A1, typename A2, typename A3>
1187 {
1188  return Callable(&Detail::CallableFactorySharedWrapper<ClassType, A0, A1, A2, A3>);
1189 }
1190 
1191 /***********************************************************************
1192  * Templated factory/constructor calls with 5 args
1193  **********************************************************************/
1194 template <typename ReturnType, typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4>
1195 Callable::Callable(ReturnType(ClassType::*fcn)(A0, A1, A2, A3, A4)):
1196  _impl(new Detail::CallableFunctionContainer6<ReturnType, ClassType &, A0, A1, A2, A3, A4>(fcn))
1197 {
1198  return;
1199 }
1200 
1201 template <typename ReturnType, typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4>
1202 Callable::Callable(ReturnType(ClassType::*fcn)(A0, A1, A2, A3, A4) const):
1203  _impl(new Detail::CallableFunctionContainer6<ReturnType, const ClassType &, A0, A1, A2, A3, A4>(fcn))
1204 {
1205  return;
1206 }
1207 
1208 template <typename ReturnType, typename A0, typename A1, typename A2, typename A3, typename A4>
1209 Callable::Callable(ReturnType(*fcn)(A0, A1, A2, A3, A4)):
1210  _impl(new Detail::CallableFunctionContainer5<ReturnType, A0, A1, A2, A3, A4>(fcn))
1211 {
1212  return;
1213 }
1214 
1215 template <typename A0, typename A1, typename A2, typename A3, typename A4, typename ReturnType, typename ClassType>
1216 Callable Callable::make(ReturnType(ClassType::*fcn)(A0, A1, A2, A3, A4))
1217 {
1218  return Callable(fcn);
1219 }
1220 
1221 template <typename A0, typename A1, typename A2, typename A3, typename A4, typename ReturnType, typename ClassType>
1222 Callable Callable::make(ReturnType(ClassType::*fcn)(A0, A1, A2, A3, A4) const)
1223 {
1224  return Callable(fcn);
1225 }
1226 
1227 template <typename A0, typename A1, typename A2, typename A3, typename A4, typename ReturnType>
1228 Callable Callable::make(ReturnType(*fcn)(A0, A1, A2, A3, A4))
1229 {
1230  return Callable(fcn);
1231 }
1232 
1233 template <typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4>
1235 {
1236  return Callable(&Detail::CallableFactoryWrapper<ClassType, A0, A1, A2, A3, A4>);
1237 }
1238 
1239 template <typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4>
1241 {
1242  return Callable(&Detail::CallableFactoryNewWrapper<ClassType, A0, A1, A2, A3, A4>);
1243 }
1244 
1245 template <typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4>
1247 {
1248  return Callable(&Detail::CallableFactorySharedWrapper<ClassType, A0, A1, A2, A3, A4>);
1249 }
1250 
1251 /***********************************************************************
1252  * Templated factory/constructor calls with 6 args
1253  **********************************************************************/
1254 template <typename ReturnType, typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5>
1255 Callable::Callable(ReturnType(ClassType::*fcn)(A0, A1, A2, A3, A4, A5)):
1256  _impl(new Detail::CallableFunctionContainer7<ReturnType, ClassType &, A0, A1, A2, A3, A4, A5>(fcn))
1257 {
1258  return;
1259 }
1260 
1261 template <typename ReturnType, typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5>
1262 Callable::Callable(ReturnType(ClassType::*fcn)(A0, A1, A2, A3, A4, A5) const):
1263  _impl(new Detail::CallableFunctionContainer7<ReturnType, const ClassType &, A0, A1, A2, A3, A4, A5>(fcn))
1264 {
1265  return;
1266 }
1267 
1268 template <typename ReturnType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5>
1269 Callable::Callable(ReturnType(*fcn)(A0, A1, A2, A3, A4, A5)):
1270  _impl(new Detail::CallableFunctionContainer6<ReturnType, A0, A1, A2, A3, A4, A5>(fcn))
1271 {
1272  return;
1273 }
1274 
1275 template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename ReturnType, typename ClassType>
1276 Callable Callable::make(ReturnType(ClassType::*fcn)(A0, A1, A2, A3, A4, A5))
1277 {
1278  return Callable(fcn);
1279 }
1280 
1281 template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename ReturnType, typename ClassType>
1282 Callable Callable::make(ReturnType(ClassType::*fcn)(A0, A1, A2, A3, A4, A5) const)
1283 {
1284  return Callable(fcn);
1285 }
1286 
1287 template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename ReturnType>
1288 Callable Callable::make(ReturnType(*fcn)(A0, A1, A2, A3, A4, A5))
1289 {
1290  return Callable(fcn);
1291 }
1292 
1293 template <typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5>
1295 {
1296  return Callable(&Detail::CallableFactoryWrapper<ClassType, A0, A1, A2, A3, A4, A5>);
1297 }
1298 
1299 template <typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5>
1301 {
1302  return Callable(&Detail::CallableFactoryNewWrapper<ClassType, A0, A1, A2, A3, A4, A5>);
1303 }
1304 
1305 template <typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5>
1307 {
1308  return Callable(&Detail::CallableFactorySharedWrapper<ClassType, A0, A1, A2, A3, A4, A5>);
1309 }
1310 
1311 /***********************************************************************
1312  * Templated factory/constructor calls with 7 args
1313  **********************************************************************/
1314 template <typename ReturnType, typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
1315 Callable::Callable(ReturnType(ClassType::*fcn)(A0, A1, A2, A3, A4, A5, A6)):
1316  _impl(new Detail::CallableFunctionContainer8<ReturnType, ClassType &, A0, A1, A2, A3, A4, A5, A6>(fcn))
1317 {
1318  return;
1319 }
1320 
1321 template <typename ReturnType, typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
1322 Callable::Callable(ReturnType(ClassType::*fcn)(A0, A1, A2, A3, A4, A5, A6) const):
1323  _impl(new Detail::CallableFunctionContainer8<ReturnType, const ClassType &, A0, A1, A2, A3, A4, A5, A6>(fcn))
1324 {
1325  return;
1326 }
1327 
1328 template <typename ReturnType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
1329 Callable::Callable(ReturnType(*fcn)(A0, A1, A2, A3, A4, A5, A6)):
1330  _impl(new Detail::CallableFunctionContainer7<ReturnType, A0, A1, A2, A3, A4, A5, A6>(fcn))
1331 {
1332  return;
1333 }
1334 
1335 template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename ReturnType, typename ClassType>
1336 Callable Callable::make(ReturnType(ClassType::*fcn)(A0, A1, A2, A3, A4, A5, A6))
1337 {
1338  return Callable(fcn);
1339 }
1340 
1341 template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename ReturnType, typename ClassType>
1342 Callable Callable::make(ReturnType(ClassType::*fcn)(A0, A1, A2, A3, A4, A5, A6) const)
1343 {
1344  return Callable(fcn);
1345 }
1346 
1347 template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename ReturnType>
1348 Callable Callable::make(ReturnType(*fcn)(A0, A1, A2, A3, A4, A5, A6))
1349 {
1350  return Callable(fcn);
1351 }
1352 
1353 template <typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
1355 {
1356  return Callable(&Detail::CallableFactoryWrapper<ClassType, A0, A1, A2, A3, A4, A5, A6>);
1357 }
1358 
1359 template <typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
1361 {
1362  return Callable(&Detail::CallableFactoryNewWrapper<ClassType, A0, A1, A2, A3, A4, A5, A6>);
1363 }
1364 
1365 template <typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
1367 {
1368  return Callable(&Detail::CallableFactorySharedWrapper<ClassType, A0, A1, A2, A3, A4, A5, A6>);
1369 }
1370 
1371 /***********************************************************************
1372  * Templated factory/constructor calls with 8 args
1373  **********************************************************************/
1374 template <typename ReturnType, typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7>
1375 Callable::Callable(ReturnType(ClassType::*fcn)(A0, A1, A2, A3, A4, A5, A6, A7)):
1376  _impl(new Detail::CallableFunctionContainer9<ReturnType, ClassType &, A0, A1, A2, A3, A4, A5, A6, A7>(fcn))
1377 {
1378  return;
1379 }
1380 
1381 template <typename ReturnType, typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7>
1382 Callable::Callable(ReturnType(ClassType::*fcn)(A0, A1, A2, A3, A4, A5, A6, A7) const):
1383  _impl(new Detail::CallableFunctionContainer9<ReturnType, const ClassType &, A0, A1, A2, A3, A4, A5, A6, A7>(fcn))
1384 {
1385  return;
1386 }
1387 
1388 template <typename ReturnType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7>
1389 Callable::Callable(ReturnType(*fcn)(A0, A1, A2, A3, A4, A5, A6, A7)):
1390  _impl(new Detail::CallableFunctionContainer8<ReturnType, A0, A1, A2, A3, A4, A5, A6, A7>(fcn))
1391 {
1392  return;
1393 }
1394 
1395 template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename ReturnType, typename ClassType>
1396 Callable Callable::make(ReturnType(ClassType::*fcn)(A0, A1, A2, A3, A4, A5, A6, A7))
1397 {
1398  return Callable(fcn);
1399 }
1400 
1401 template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename ReturnType, typename ClassType>
1402 Callable Callable::make(ReturnType(ClassType::*fcn)(A0, A1, A2, A3, A4, A5, A6, A7) const)
1403 {
1404  return Callable(fcn);
1405 }
1406 
1407 template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename ReturnType>
1408 Callable Callable::make(ReturnType(*fcn)(A0, A1, A2, A3, A4, A5, A6, A7))
1409 {
1410  return Callable(fcn);
1411 }
1412 
1413 template <typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7>
1415 {
1416  return Callable(&Detail::CallableFactoryWrapper<ClassType, A0, A1, A2, A3, A4, A5, A6, A7>);
1417 }
1418 
1419 template <typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7>
1421 {
1422  return Callable(&Detail::CallableFactoryNewWrapper<ClassType, A0, A1, A2, A3, A4, A5, A6, A7>);
1423 }
1424 
1425 template <typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7>
1427 {
1428  return Callable(&Detail::CallableFactorySharedWrapper<ClassType, A0, A1, A2, A3, A4, A5, A6, A7>);
1429 }
1430 
1431 /***********************************************************************
1432  * Templated factory/constructor calls with 9 args
1433  **********************************************************************/
1434 template <typename ReturnType, typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8>
1435 Callable::Callable(ReturnType(ClassType::*fcn)(A0, A1, A2, A3, A4, A5, A6, A7, A8)):
1436  _impl(new Detail::CallableFunctionContainer10<ReturnType, ClassType &, A0, A1, A2, A3, A4, A5, A6, A7, A8>(fcn))
1437 {
1438  return;
1439 }
1440 
1441 template <typename ReturnType, typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8>
1442 Callable::Callable(ReturnType(ClassType::*fcn)(A0, A1, A2, A3, A4, A5, A6, A7, A8) const):
1443  _impl(new Detail::CallableFunctionContainer10<ReturnType, const ClassType &, A0, A1, A2, A3, A4, A5, A6, A7, A8>(fcn))
1444 {
1445  return;
1446 }
1447 
1448 template <typename ReturnType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8>
1449 Callable::Callable(ReturnType(*fcn)(A0, A1, A2, A3, A4, A5, A6, A7, A8)):
1450  _impl(new Detail::CallableFunctionContainer9<ReturnType, A0, A1, A2, A3, A4, A5, A6, A7, A8>(fcn))
1451 {
1452  return;
1453 }
1454 
1455 template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename ReturnType, typename ClassType>
1456 Callable Callable::make(ReturnType(ClassType::*fcn)(A0, A1, A2, A3, A4, A5, A6, A7, A8))
1457 {
1458  return Callable(fcn);
1459 }
1460 
1461 template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename ReturnType, typename ClassType>
1462 Callable Callable::make(ReturnType(ClassType::*fcn)(A0, A1, A2, A3, A4, A5, A6, A7, A8) const)
1463 {
1464  return Callable(fcn);
1465 }
1466 
1467 template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename ReturnType>
1468 Callable Callable::make(ReturnType(*fcn)(A0, A1, A2, A3, A4, A5, A6, A7, A8))
1469 {
1470  return Callable(fcn);
1471 }
1472 
1473 template <typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8>
1475 {
1476  return Callable(&Detail::CallableFactoryWrapper<ClassType, A0, A1, A2, A3, A4, A5, A6, A7, A8>);
1477 }
1478 
1479 template <typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8>
1481 {
1482  return Callable(&Detail::CallableFactoryNewWrapper<ClassType, A0, A1, A2, A3, A4, A5, A6, A7, A8>);
1483 }
1484 
1485 template <typename ClassType, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8>
1487 {
1488  return Callable(&Detail::CallableFactorySharedWrapper<ClassType, A0, A1, A2, A3, A4, A5, A6, A7, A8>);
1489 }
1490 
1491 } //namespace Pothos
#define POTHOS_API
Definition: Config.hpp:41
Callable & bind(ValueType &&val, const size_t argNo)
Definition: CallableImpl.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:206
Definition: Callable.tmpl.hpp:30
static Callable factoryShared(void)
Definition: CallableImpl.hpp:1006
const ValueType & extract(void) const
Definition: ObjectImpl.hpp:221
static Callable factoryNew(void)
Definition: CallableImpl.hpp:1000
static Callable factory(void)
Definition: CallableImpl.hpp:994