8 #ifndef _LIBALCOMMON_ALCOMMON_ALPROXY_HXX_
9 #define _LIBALCOMMON_ALCOMMON_ALPROXY_HXX_
11 #include <qi/type/objecttypebuilder.hpp>
16 #define pushi(z, n,_) args.push_back(::qi::AnyReference::from(p ## n));
17 #define consti(z, n,_) , const P ## n & p ## n
18 #define genCall(n, ATYPEDECL, ATYPES, ADECL, AUSE, comma) \
19 template<typename R comma ATYPEDECL> \
20 R ALProxy::call(const std::string& pName BOOST_PP_REPEAT(n, consti, _) ) \
22 qi::AnyObject object = _object.lock(); \
24 throw ALERROR(moduleName(), pName, "module destroyed"); \
25 ::qi::GenericFunctionParameters args; \
27 BOOST_PP_REPEAT(n, pushi, _) \
30 qi::AnyValue res(object.metaCall(pName, args).value(), false, true); \
31 qi::Promise<R> prom(qi::PromiseNoop<R>, qi::FutureCallbackType_Sync); \
32 if (qi::detail::handleFuture(res.asReference(), prom)) \
35 prom.future().wait(); \
36 qiLogDebug("alproxy.call") << prom.future().hasError(); \
37 return (R)prom.future().value(); \
43 catch(const std::exception& e) \
45 throw ALERROR(moduleName(), pName, e.what()); \
52 #define genCall(n, ATYPEDECL, ATYPES, ADECL, AUSE, comma) \
53 QI_GEN_MAYBE_TEMPLATE_OPEN(comma) ATYPEDECL QI_GEN_MAYBE_TEMPLATE_CLOSE(comma) \
54 inline void ALProxy::callVoid(const std::string& pName BOOST_PP_REPEAT(n, consti, _)) \
56 call<void>(pName comma AUSE); \
66 qi::AnyObject
object = _object.lock();
68 throw ALERROR(moduleName(), pName,
"module destroyed");
69 qi::GenericFunctionParameters params;
70 return xMetaPCall(pName, params);
76 qi::AnyObject
object = _object.lock();
78 throw ALERROR(moduleName(), pName,
"module destroyed");
79 qi::GenericFunctionParameters params;
80 params.push_back(qi::AnyReference::from(p0));
81 return xMetaPCall(pName, params);
84 template<
typename P0,
typename P1>
87 qi::AnyObject
object = _object.lock();
89 throw ALERROR(moduleName(), pName,
"module destroyed");
90 qi::GenericFunctionParameters params;
91 params.push_back(qi::AnyReference::from(p0));
92 params.push_back(qi::AnyReference::from(p1));
93 return xMetaPCall(pName, params);
96 template<
typename P0,
typename P1,
typename P2>
97 int ALProxy::pCall(
const std::string& pName,
const P0 &p0,
const P1 &p1,
const P2 &p2)
99 qi::AnyObject
object = _object.lock();
101 throw ALERROR(moduleName(), pName,
"module destroyed");
102 qi::GenericFunctionParameters params;
103 params.push_back(qi::AnyReference::from(p0));
104 params.push_back(qi::AnyReference::from(p1));
105 params.push_back(qi::AnyReference::from(p2));
106 return xMetaPCall(pName, params);
109 template<
typename P0,
typename P1,
typename P2,
typename P3>
110 int ALProxy::pCall(
const std::string& pName,
const P0 &p0,
const P1 &p1,
const P2 &p2,
const P3 &p3)
112 qi::AnyObject
object = _object.lock();
114 throw ALERROR(moduleName(), pName,
"module destroyed");
115 qi::GenericFunctionParameters params;
116 params.push_back(qi::AnyReference::from(p0));
117 params.push_back(qi::AnyReference::from(p1));
118 params.push_back(qi::AnyReference::from(p2));
119 params.push_back(qi::AnyReference::from(p3));
120 return xMetaPCall(pName, params);
123 template<
typename P0,
typename P1,
typename P2,
typename P3,
typename P4>
124 int ALProxy::pCall(
const std::string& pName,
const P0 &p0,
const P1 &p1,
const P2 &p2,
const P3 &p3,
const P4 &p4)
126 qi::AnyObject
object = _object.lock();
128 throw ALERROR(moduleName(), pName,
"module destroyed");
129 qi::GenericFunctionParameters params;
130 params.push_back(qi::AnyReference::from(p0));
131 params.push_back(qi::AnyReference::from(p1));
132 params.push_back(qi::AnyReference::from(p2));
133 params.push_back(qi::AnyReference::from(p3));
134 params.push_back(qi::AnyReference::from(p4));
135 return xMetaPCall(pName, params);
138 template<
typename P0,
typename P1,
typename P2,
typename P3,
typename P4,
typename P5>
139 int ALProxy::pCall(
const std::string& pName,
const P0 &p0,
const P1 &p1,
const P2 &p2,
const P3 &p3,
const P4 &p4,
const P5 &p5)
141 qi::AnyObject
object = _object.lock();
143 throw ALERROR(moduleName(), pName,
"module destroyed");
144 qi::GenericFunctionParameters params;
145 params.push_back(qi::AnyReference::from(p0));
146 params.push_back(qi::AnyReference::from(p1));
147 params.push_back(qi::AnyReference::from(p2));
148 params.push_back(qi::AnyReference::from(p3));
149 params.push_back(qi::AnyReference::from(p4));
150 params.push_back(qi::AnyReference::from(p5));
151 return xMetaPCall(pName, params);
155 #endif // _LIBALCOMMON_ALCOMMON_ALPROXY_HXX_
#define genCall(n, ATYPEDECL, ATYPES, ADECL, AUSE, comma)
int pCall(const std::string &pName)