libalcommon  2.1.4.13
 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 <qitype/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);
158  ALProxy(const std::string &pModuleName,
159  const std::string &pIp,
160  int pPort,
161  boost::shared_ptr<ALBroker> pBroker,
162  int pProxyMask = 0,
163  int timeout = 0);
170  ALProxy(const std::string &pModuleName,
171  int pProxyOption,
172  int pTimeout);
173 
174  public:
176  virtual ~ALProxy(void);
177 
178 
182  std::string remoteBrokerName();
183 
195  AL::ALValue genericCall(const std::string &strMethodName,
196  const AL::ALValue &listParams);
197 
198 
216  int genericPCall(const std::string &strMethodName,
217  const AL::ALValue &listParams,
218  onFinishedCallback pCallbackToCallOnFinished = NULL,
219  const char *pszCallerName = NULL);
220 
225  std::string version();
226 
231  boost::shared_ptr<ALModule> getModule() const;
236  boost::shared_ptr<ALModuleCore> getModuleCore() const;
237 
243  int getInfo(ALModuleInfo &pModuleInfo);
244 
249  bool isLocal();
250 
257  bool isValid();
258 
265  boost::shared_ptr<ALFunctorBase> getFunctor(const std::string &pName,
266  const std::vector<std::string> &pParamTypes);
267 
272  boost::shared_ptr<ALBroker> getParentBroker(void) const;
273 
277  void destroyConnection(void);
278 
279  template <typename R>
280  R call(const std::string &pName);
281 
282  template <typename R, typename P1>
283  R call(const std::string &pName, const P1 &p1);
284 
285  template <typename R, typename P1, typename P2>
286  R call(const std::string &pName, const P1 &p1, const P2 &p2);
287 
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);
290 
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);
293 
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);
296 
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);
299 
300  inline void callVoid(const std::string &pName);
301 
302  template <typename P1>
303  void callVoid(const std::string &pName, const P1 &p1);
304 
305  template <typename P1, typename P2>
306  void callVoid(const std::string &pName, const P1 &p1, const P2 &p2);
307 
308  template <typename P1, typename P2, typename P3>
309  void callVoid(const std::string &pName, const P1 &p1, const P2 &p2, const P3 &p3);
310 
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);
313 
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);
316 
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);
319 
320  inline int pCall(const std::string &pName);
321 
322  template <typename P1>
323  int pCall(const std::string &pName, const P1 &p1);
324 
325  template <typename P1, typename P2>
326  int pCall(const std::string &pName, const P1 &p1, const P2 &p2);
327 
328  template <typename P1, typename P2, typename P3>
329  int pCall(const std::string &pName, const P1 &p1, const P2 &p2, const P3 &p3);
330 
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);
333 
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);
336 
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);
339 
350  bool wait(const int &id, const int &timeoutPeriod);
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 
ALModuleInfo is the class of information about user modules.
Definition: almoduleinfo.h:27
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.
Definition: alproxy.h:84
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 &)
Definition: alproxy.h:86
void stop(const int &id)
Stop a long running method that was called using 'post'.
int pCall(const std::string &pName)
Definition: alproxy.hxx:64
void destroyConnection(void)
Destroy a proxy to clean each shared_ptr of the class.
ALModuleCore is the superclass of user modules.
Definition: almodulecore.h:58
boost::shared_ptr< ALProxy > Ptr
Shared pointer to ALProxy.
Definition: alproxy.h:78
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.
Definition: alproxy.h:70
boost::shared_ptr< ALProxy > ALProxyPtr
Definition: alproxy.h:395
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.
Definition: alproxy.h:103