libalcommon  2.4.3.28-r2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
alproxy.h
Go to the documentation of this file.
1 
10 #pragma once
11 #ifndef _LIBALCOMMON_ALCOMMON_ALPROXY_H_
12 #define _LIBALCOMMON_ALCOMMON_ALPROXY_H_
13 
14 # include <alcommon/api.h>
15 # include <alcommon/almoduleinfo.h>
16 # include <alcommon/almodule.h>
17 # include <alvalue/alvalue.h>
18 # include <alerror/alerror.h>
19 
20 # include <boost/shared_ptr.hpp>
21 # include <boost/smart_ptr/enable_shared_from_this.hpp>
22 # include <qi/anyobject.hpp>
23 
24 #ifdef _WIN32
25 # pragma warning(disable:4996)
26 # pragma warning(disable:4800)
27 #endif
28 
29 namespace AL
30 {
31 
32 
33 
34  class ALProxyPrivate;
35 
70  class ALProxy : public ::boost::enable_shared_from_this<ALProxy>
71  {
72  public:
78  typedef boost::shared_ptr<ALProxy> Ptr;
84  typedef boost::weak_ptr<ALProxy> WeakPtr;
85 
86  typedef int (*onFinishedCallback)(const char*, int, const AL::ALValue &);
87 
92  boost::shared_ptr<ALProxy> getThis();
97  boost::shared_ptr<const ALProxy> getThis() const;
98 
104  {
105  NO_OPTION = 0,
109  };
110 
111  ALProxy(const ALProxy &rhs);
112  private:
113  const ALProxy &operator=(const ALProxy &rhs);
114 
115  public:
123  ALProxy(boost::shared_ptr<ALBroker> pBroker,
124  const std::string &pModuleName,
125  int pProxyMask = 0,
126  int timeout = 0);
127 
128 
134  ALProxy(qi::AnyObject pObject, const std::string &pModuleName);
135 
144  ALProxy(const std::string &pModuleName,
145  const std::string &pIp,
146  int pPort,
147  int pProxyMask = 0,
148  int timeout = 0);
149 
159  ALProxy(const std::string &pModuleName,
160  const std::string &pIp,
161  int pPort,
162  boost::shared_ptr<ALBroker> pBroker,
163  int pProxyMask = 0,
164  int timeout = 0);
165 
166  public:
168  virtual ~ALProxy(void);
169 
170 
174  std::string remoteBrokerName();
175 
187  AL::ALValue genericCall(const std::string &strMethodName,
188  const AL::ALValue &listParams);
189 
190 
208  int genericPCall(const std::string &strMethodName,
209  const AL::ALValue &listParams,
210  onFinishedCallback pCallbackToCallOnFinished = NULL,
211  const char *pszCallerName = NULL);
212 
217  std::string version();
218 
223  boost::shared_ptr<ALModule> getModule() const;
228  boost::shared_ptr<ALModuleCore> getModuleCore() const;
229 
235  int getInfo(ALModuleInfo &pModuleInfo);
236 
241  bool isLocal();
242 
249  bool isValid();
250 
257  boost::shared_ptr<ALFunctorBase> getFunctor(const std::string &pName,
258  const std::vector<std::string> &pParamTypes);
259 
264  boost::shared_ptr<ALBroker> getParentBroker(void) const;
265 
269  void destroyConnection(void);
270 
271  template <typename R>
272  R call(const std::string &pName);
273 
274  template <typename R, typename P1>
275  R call(const std::string &pName, const P1 &p1);
276 
277  template <typename R, typename P1, typename P2>
278  R call(const std::string &pName, const P1 &p1, const P2 &p2);
279 
280  template <typename R, typename P1, typename P2, typename P3>
281  R call(const std::string &pName, const P1 &p1, const P2 &p2, const P3 &p3);
282 
283  template <typename R, typename P1, typename P2, typename P3, typename P4>
284  R call(const std::string &pName, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4);
285 
286  template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5>
287  R call(const std::string &pName, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5);
288 
289  template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6>
290  R call(const std::string &pName, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5, const P6 &p6);
291 
292  inline void callVoid(const std::string &pName);
293 
294  template <typename P1>
295  void callVoid(const std::string &pName, const P1 &p1);
296 
297  template <typename P1, typename P2>
298  void callVoid(const std::string &pName, const P1 &p1, const P2 &p2);
299 
300  template <typename P1, typename P2, typename P3>
301  void callVoid(const std::string &pName, const P1 &p1, const P2 &p2, const P3 &p3);
302 
303  template <typename P1, typename P2, typename P3, typename P4>
304  void callVoid(const std::string &pName, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4);
305 
306  template <typename P1, typename P2, typename P3, typename P4, typename P5>
307  void callVoid(const std::string &pName, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5);
308 
309  template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6>
310  void callVoid(const std::string &pName, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5, const P6 &p6);
311 
312  inline int pCall(const std::string &pName);
313 
314  template <typename P1>
315  int pCall(const std::string &pName, const P1 &p1);
316 
317  template <typename P1, typename P2>
318  int pCall(const std::string &pName, const P1 &p1, const P2 &p2);
319 
320  template <typename P1, typename P2, typename P3>
321  int pCall(const std::string &pName, const P1 &p1, const P2 &p2, const P3 &p3);
322 
323  template <typename P1, typename P2, typename P3, typename P4>
324  int pCall(const std::string &pName, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4);
325 
326  template <typename P1, typename P2, typename P3, typename P4, typename P5>
327  int pCall(const std::string &pName, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5);
328 
329  template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6>
330  int pCall(const std::string &pName, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5, const P6 &p6);
331 
342  bool wait(const int &id, const int &timeoutPeriod);
343 
350  qi::FutureSync<void> wait(const int &id);
351 
357  void stop(const int &id);
358 
365  bool isRunning(const int &id);
366 
373  int pCallNotify(const std::string &name,
374  const std::string &key,
375  const ALValue &value,
376  const ALValue &message = std::string(),
377  std::pair<int, int>* cache = 0);
378 
379  std::string moduleName() const;
380 
384  qi::AnyObject asObject();
385 
386  ALProxyPrivate *_p;
387  qi::AnyWeakObject _object;
388  protected:
389  int xMetaPCall(const std::string &signature, const qi::GenericFunctionParameters &in);
390 
391  friend class AL::ALModuleCore;
393  }; // ALProxy
394 
395  typedef boost::shared_ptr<ALProxy> ALProxyPtr;
396 } // namespace AL
397 
398 #include <alcommon/alproxy.hxx>
399 
400 #endif // _LIBALCOMMON_ALCOMMON_ALPROXY_H_
401 
std::string version()
Get the version.
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).
boost::shared_ptr< ALProxy > Ptr
Shared pointer to ALProxy.
Definition: alproxy.h:78
ALProxy is a client to the served methods of a module.
Definition: alproxy.h:70
void callVoid(const std::string &pName)
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.
ALProxy(const ALProxy &rhs)
void destroyConnection(void)
Destroy a proxy to clean each shared_ptr of the class.
ALModuleInfo is the class of information about user modules.
Definition: almoduleinfo.h:27
ALModuleCore is the superclass of user modules.
Definition: almodulecore.h:57
R call(const std::string &pName)
virtual ~ALProxy(void)
Destructor.
bool isRunning(const int &id)
Check if the method is running.
bool isValid()
Make sure that we notice that someone has invalidated our module.
int pCall(const std::string &pName)
Definition: alproxy.hxx:64
boost::shared_ptr< ALProxy > getThis()
Get a pointer to this ALProxy.
bool wait(const int &id, const int &timeoutPeriod)
Wait for the end of a long running method that was called using 'post'.
int(* onFinishedCallback)(const char *, int, const AL::ALValue &)
Definition: alproxy.h:86
void stop(const int &id)
Stop a long running method that was called using 'post'.
boost::shared_ptr< ALModule > getModule() const
Get the module.
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)...
std::string remoteBrokerName()
return the name of the remote broker
bool isLocal()
Check if the module is in the same process than the proxy.
int getInfo(ALModuleInfo &pModuleInfo)
Get information about the module stored into pModuleInfo.
boost::weak_ptr< ALProxy > WeakPtr
Weak pointer to ALProxy.
Definition: alproxy.h:84
boost::shared_ptr< ALModuleCore > getModuleCore() const
Get the moduleCore.
pProxyOption
Different options for the ALProxy.
Definition: alproxy.h:103
boost::shared_ptr< ALBroker > getParentBroker(void) const
Get the parent broker.
boost::shared_ptr< ALProxy > ALProxyPtr
Definition: alproxy.h:395