libqi-api  2.4.3.28
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
async.hxx
Go to the documentation of this file.
1 #pragma once
2 /*
3 ** Copyright (C) 2013 Aldebaran Robotics
4 ** See COPYING for the license
5 */
6 
7 #ifndef _QI_TYPE_DETAILS_ASYNC_HXX_
8 #define _QI_TYPE_DETAILS_ASYNC_HXX_
9 
10 #include <boost/mpl/if.hpp>
11 
12 #include <qi/future.hpp>
13 
14 namespace qi {
15 
16 #ifdef DOXYGEN
17 
21  template<typename R, typename T>
22  qi::Future<R> async(T instancePointerOrSharedPointer,
23  const std::string& methodName,
32 #else
33 #define genCall(n, ATYPEDECL, ATYPES, ADECL, AUSE, comma) \
34  template<typename R,typename T> qi::Future<R> async( \
35  T* instance, \
36  const std::string& methodName comma \
37  QI_GEN_ARGSDECLSAMETYPE(n, qi::AutoAnyReference)) \
38  { \
39  AnyObject obj = AnyReference::from(instance).toObject(); \
40  qi::Future<R> res = obj.async<R>( \
41  methodName comma AUSE); \
42  res.connect(boost::bind(&detail::hold<AnyObject>, obj)); \
43  return res; \
44  }
46 #undef genCall
47 
48 #define genCall(n, ATYPEDECL, ATYPES, ADECL, AUSE, comma) \
49  template<typename R,typename T> qi::Future<R> async( \
50  boost::shared_ptr<T> instance, \
51  const std::string& methodName comma \
52  QI_GEN_ARGSDECLSAMETYPE(n, qi::AutoAnyReference)) \
53  { \
54  AnyObject obj = AnyReference::from(instance).toObject(); \
55  qi::Future<R> res = obj.async<R>( \
56  methodName comma AUSE); \
57  res.connect(boost::bind(&detail::hold<AnyObject>, obj)); \
58  return res; \
59  }
61 #undef genCall
62 
63 #define genCall(n, ATYPEDECL, ATYPES, ADECL, AUSE, comma) \
64  template<typename R,typename T> qi::Future<R> async( \
65  Object<T> instance, \
66  const std::string& methodName comma \
67  QI_GEN_ARGSDECLSAMETYPE(n, qi::AutoAnyReference)) \
68  { \
69  AnyObject obj = instance; \
70  qi::Future<R> res = obj.async<R>( \
71  methodName comma AUSE); \
72  res.connect(boost::bind(&detail::hold<AnyObject>, obj)); \
73  return res; \
74  }
76 #undef genCall
77 #endif
78 
79 }
80 
81 #endif // _QITYPE_DETAILS_ASYNC_HXX_
Future< R > async(boost::function< R()> callback, uint64_t usDelay=0)
Definition: eventloop.hpp:176
#define genCall(n, ATYPEDECL, ATYPES, ADECL, AUSE, comma)
Definition: future_fwd.hpp:337
#define QI_GEN(f)
Definition: preproc.hpp:476