11 #ifndef _LIBALCOMMON_ALCOMMON_ALPROXY_H_
12 #define _LIBALCOMMON_ALCOMMON_ALPROXY_H_
18 # include <alerror/alerror.h>
20 # include <boost/shared_ptr.hpp>
21 # include <boost/smart_ptr/enable_shared_from_this.hpp>
22 # include <qitype/anyobject.hpp>
25 # pragma warning(disable:4996)
26 # pragma warning(disable:4800)
70 class ALProxy :
public ::boost::enable_shared_from_this<ALProxy>
78 typedef boost::shared_ptr<ALProxy>
Ptr;
92 boost::shared_ptr<ALProxy>
getThis();
97 boost::shared_ptr<const ALProxy>
getThis()
const;
123 ALProxy(boost::shared_ptr<ALBroker> pBroker,
124 const std::string &pModuleName,
134 ALProxy(qi::AnyObject pObject,
const std::string &pModuleName);
144 ALProxy(
const std::string &pModuleName,
145 const std::string &pIp,
158 ALProxy(
const std::string &pModuleName,
159 const std::string &pIp,
161 boost::shared_ptr<ALBroker> pBroker,
170 ALProxy(
const std::string &pModuleName,
219 const char *pszCallerName = NULL);
231 boost::shared_ptr<ALModule>
getModule()
const;
265 boost::shared_ptr<ALFunctorBase>
getFunctor(
const std::string &pName,
266 const std::vector<std::string> &pParamTypes);
279 template <
typename R>
280 R
call(
const std::string &pName);
282 template <
typename R,
typename P1>
283 R
call(
const std::string &pName,
const P1 &p1);
285 template <
typename R,
typename P1,
typename P2>
286 R
call(
const std::string &pName,
const P1 &p1,
const P2 &p2);
288 template <
typename R,
typename P1,
typename P2,
typename P3>
289 R
call(
const std::string &pName,
const P1 &p1,
const P2 &p2,
const P3 &p3);
291 template <
typename R,
typename P1,
typename P2,
typename P3,
typename P4>
292 R
call(
const std::string &pName,
const P1 &p1,
const P2 &p2,
const P3 &p3,
const P4 &p4);
294 template <
typename R,
typename P1,
typename P2,
typename P3,
typename P4,
typename P5>
295 R
call(
const std::string &pName,
const P1 &p1,
const P2 &p2,
const P3 &p3,
const P4 &p4,
const P5 &p5);
297 template <
typename R,
typename P1,
typename P2,
typename P3,
typename P4,
typename P5,
typename P6>
298 R
call(
const std::string &pName,
const P1 &p1,
const P2 &p2,
const P3 &p3,
const P4 &p4,
const P5 &p5,
const P6 &p6);
300 inline void callVoid(
const std::string &pName);
302 template <
typename P1>
303 void callVoid(
const std::string &pName,
const P1 &p1);
305 template <
typename P1,
typename P2>
306 void callVoid(
const std::string &pName,
const P1 &p1,
const P2 &p2);
308 template <
typename P1,
typename P2,
typename P3>
309 void callVoid(
const std::string &pName,
const P1 &p1,
const P2 &p2,
const P3 &p3);
311 template <
typename P1,
typename P2,
typename P3,
typename P4>
312 void callVoid(
const std::string &pName,
const P1 &p1,
const P2 &p2,
const P3 &p3,
const P4 &p4);
314 template <
typename P1,
typename P2,
typename P3,
typename P4,
typename P5>
315 void callVoid(
const std::string &pName,
const P1 &p1,
const P2 &p2,
const P3 &p3,
const P4 &p4,
const P5 &p5);
317 template <
typename P1,
typename P2,
typename P3,
typename P4,
typename P5,
typename P6>
318 void callVoid(
const std::string &pName,
const P1 &p1,
const P2 &p2,
const P3 &p3,
const P4 &p4,
const P5 &p5,
const P6 &p6);
320 inline int pCall(
const std::string &pName);
322 template <
typename P1>
323 int pCall(
const std::string &pName,
const P1 &p1);
325 template <
typename P1,
typename P2>
326 int pCall(
const std::string &pName,
const P1 &p1,
const P2 &p2);
328 template <
typename P1,
typename P2,
typename P3>
329 int pCall(
const std::string &pName,
const P1 &p1,
const P2 &p2,
const P3 &p3);
331 template <
typename P1,
typename P2,
typename P3,
typename P4>
332 int pCall(
const std::string &pName,
const P1 &p1,
const P2 &p2,
const P3 &p3,
const P4 &p4);
334 template <
typename P1,
typename P2,
typename P3,
typename P4,
typename P5>
335 int pCall(
const std::string &pName,
const P1 &p1,
const P2 &p2,
const P3 &p3,
const P4 &p4,
const P5 &p5);
337 template <
typename P1,
typename P2,
typename P3,
typename P4,
typename P5,
typename P6>
338 int pCall(
const std::string &pName,
const P1 &p1,
const P2 &p2,
const P3 &p3,
const P4 &p4,
const P5 &p5,
const P6 &p6);
350 bool wait(
const int &
id,
const int &timeoutPeriod);
357 void stop(
const int &
id);
373 int pCallNotify(
const std::string &name,
374 const std::string &key,
376 const ALValue &message = std::string(),
377 std::pair<int, int>* cache = 0);
379 std::string moduleName()
const;
384 qi::AnyObject asObject();
387 qi::AnyWeakObject _object;
389 int xMetaPCall(
const std::string &signature,
const qi::GenericFunctionParameters &in);
400 #endif // _LIBALCOMMON_ALCOMMON_ALPROXY_H_
ALModuleInfo is the class of information about user modules.
std::string remoteBrokerName()
return the name of the remote broker
boost::shared_ptr< ALFunctorBase > getFunctor(const std::string &pName, const std::vector< std::string > &pParamTypes)
Get a pointer to a method form its name and its parameters.
boost::weak_ptr< ALProxy > WeakPtr
Weak pointer to ALProxy.
bool isLocal()
Check if the module is in the same process than the proxy.
R call(const std::string &pName)
std::string version()
Get the version.
int(* onFinishedCallback)(const char *, int, const AL::ALValue &)
void stop(const int &id)
Stop a long running method that was called using 'post'.
int pCall(const std::string &pName)
void destroyConnection(void)
Destroy a proxy to clean each shared_ptr of the class.
ALModuleCore is the superclass of user modules.
boost::shared_ptr< ALProxy > Ptr
Shared pointer to ALProxy.
virtual ~ALProxy(void)
Destructor.
bool wait(const int &id, const int &timeoutPeriod)
Wait for the end of a long running method that was called using 'post'.
bool isValid()
Make sure that we notice that someone has invalidated our module.
boost::shared_ptr< ALModuleCore > getModuleCore() const
Get the moduleCore.
int genericPCall(const std::string &strMethodName, const AL::ALValue &listParams, onFinishedCallback pCallbackToCallOnFinished=NULL, const char *pszCallerName=NULL)
A generic post-call, without type optimisation, using AL::ALValue for each call... (local or not).
void callVoid(const std::string &pName)
AL::ALValue genericCall(const std::string &strMethodName, const AL::ALValue &listParams)
A generic call, without type optimisation, using AL::ALValue for each call... (local or not)...
bool isRunning(const int &id)
Check if the method is running.
int getInfo(ALModuleInfo &pModuleInfo)
Get information about the module stored into pModuleInfo.
boost::shared_ptr< ALBroker > getParentBroker(void) const
Get the parent broker.
ALProxy is a client to the served methods of a module.
boost::shared_ptr< ALProxy > ALProxyPtr
boost::shared_ptr< ALModule > getModule() const
Get the module.
boost::shared_ptr< ALProxy > getThis()
Get a pointer to this ALProxy.
ALProxy(const ALProxy &rhs)
pProxyOption
Different options for the ALProxy.