libalcommon  2.1.0.18
/home/opennao/work/master/sdk/libnaoqi/libalcommon/alcommon/alproxy.h
Go to the documentation of this file.
00001 
00010 #pragma once
00011 #ifndef _LIBALCOMMON_ALCOMMON_ALPROXY_H_
00012 #define _LIBALCOMMON_ALCOMMON_ALPROXY_H_
00013 
00014 # include <alcommon/api.h>
00015 # include <alcommon/almoduleinfo.h>
00016 # include <alcommon/almodule.h>
00017 # include <alvalue/alvalue.h>
00018 # include <alerror/alerror.h>
00019 
00020 # include <boost/shared_ptr.hpp>
00021 # include <boost/smart_ptr/enable_shared_from_this.hpp>
00022 # include <qitype/anyobject.hpp>
00023 
00024 #ifdef _WIN32
00025 # pragma warning(disable:4996)
00026 # pragma warning(disable:4800)
00027 #endif
00028 
00029 namespace AL
00030 {
00031 
00032 
00033 
00034   class ALProxyPrivate;
00035 
00070   class ALProxy : public ::boost::enable_shared_from_this<ALProxy>
00071   {
00072   public:
00078     typedef boost::shared_ptr<ALProxy> Ptr;
00084     typedef boost::weak_ptr<ALProxy>   WeakPtr;
00085 
00086     typedef int (*onFinishedCallback)(const char*, int, const AL::ALValue &);
00087 
00092     boost::shared_ptr<ALProxy>       getThis();
00097     boost::shared_ptr<const ALProxy> getThis() const;
00098 
00103     enum pProxyOption
00104       {
00105         NO_OPTION       = 0, 
00106         FORCED_LOCAL    = 1, 
00107         NO_LOAD_DEPENDS = 2, 
00108         MAIN_PROXY      = 4  
00109       };
00110 
00111     ALProxy(const ALProxy &rhs);
00112   private:
00113     const ALProxy &operator=(const ALProxy &rhs);
00114 
00115   public:
00123     ALProxy(boost::shared_ptr<ALBroker> pBroker,
00124             const std::string &pModuleName,
00125             int pProxyMask = 0,
00126             int timeout = 0);
00127 
00128 
00134     ALProxy(qi::AnyObject pObject, const std::string &pModuleName);
00135 
00144     ALProxy(const std::string &pModuleName,
00145             const std::string &pIp,
00146             int pPort,
00147             int pProxyMask = 0,
00148             int timeout = 0);
00158     ALProxy(const std::string &pModuleName,
00159             const std::string &pIp,
00160             int pPort,
00161             boost::shared_ptr<ALBroker> pBroker,
00162             int pProxyMask = 0,
00163             int timeout = 0);
00170     ALProxy(const std::string &pModuleName,
00171             int pProxyOption,
00172             int pTimeout);
00173 
00174   public:
00176     virtual ~ALProxy(void);
00177 
00178 
00182     std::string remoteBrokerName();
00183 
00195     AL::ALValue genericCall(const std::string &strMethodName,
00196                             const AL::ALValue &listParams);
00197 
00198 
00216     int genericPCall(const std::string  &strMethodName,
00217                      const AL::ALValue  &listParams,
00218                      onFinishedCallback pCallbackToCallOnFinished = NULL,
00219                      const char         *pszCallerName = NULL);
00220 
00225     std::string version();
00226 
00231     boost::shared_ptr<ALModule>     getModule() const;
00236     boost::shared_ptr<ALModuleCore> getModuleCore() const;
00237 
00243     int getInfo(ALModuleInfo &pModuleInfo);
00244 
00249     bool isLocal();
00250 
00257     bool isValid();
00258 
00265     boost::shared_ptr<ALFunctorBase> getFunctor(const std::string &pName,
00266                                                 const std::vector<std::string> &pParamTypes);
00267 
00272     boost::shared_ptr<ALBroker> getParentBroker(void) const;
00273 
00277     void destroyConnection(void);
00278 
00279     template <typename R>
00280     R call(const std::string &pName);
00281 
00282     template <typename R, typename P1>
00283     R call(const std::string &pName, const P1 &p1);
00284 
00285     template <typename R, typename P1, typename P2>
00286     R call(const std::string &pName, const P1 &p1, const P2 &p2);
00287 
00288     template <typename R, typename P1, typename P2, typename P3>
00289     R call(const std::string &pName, const P1 &p1, const P2 &p2, const P3 &p3);
00290 
00291     template <typename R, typename P1, typename P2, typename P3, typename P4>
00292     R call(const std::string &pName, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4);
00293 
00294     template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5>
00295     R call(const std::string &pName, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5);
00296 
00297     template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6>
00298     R call(const std::string &pName, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5, const P6 &p6);
00299 
00300     inline void callVoid(const std::string &pName);
00301 
00302     template <typename P1>
00303     void callVoid(const std::string &pName, const P1 &p1);
00304 
00305     template <typename P1, typename P2>
00306     void callVoid(const std::string &pName, const P1 &p1, const P2 &p2);
00307 
00308     template <typename P1, typename P2, typename P3>
00309     void callVoid(const std::string &pName, const P1 &p1, const P2 &p2, const P3 &p3);
00310 
00311     template <typename P1, typename P2, typename P3, typename P4>
00312     void callVoid(const std::string &pName, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4);
00313 
00314     template <typename P1, typename P2, typename P3, typename P4, typename P5>
00315     void callVoid(const std::string &pName, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5);
00316 
00317     template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6>
00318     void callVoid(const std::string &pName, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5, const P6 &p6);
00319 
00320     inline int pCall(const std::string &pName);
00321 
00322     template <typename P1>
00323     int pCall(const std::string &pName, const P1 &p1);
00324 
00325     template <typename P1, typename P2>
00326     int pCall(const std::string &pName, const P1 &p1, const P2 &p2);
00327 
00328     template <typename P1, typename P2, typename P3>
00329     int pCall(const std::string &pName, const P1 &p1, const P2 &p2, const P3 &p3);
00330 
00331     template <typename P1, typename P2, typename P3, typename P4>
00332     int pCall(const std::string &pName, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4);
00333 
00334     template <typename P1, typename P2, typename P3, typename P4, typename P5>
00335     int pCall(const std::string &pName, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5);
00336 
00337     template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6>
00338     int pCall(const std::string &pName, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5, const P6 &p6);
00339 
00350     bool wait(const int &id, const int &timeoutPeriod);
00351 
00357     void stop(const int &id);
00358 
00365     bool isRunning(const int &id);
00366 
00373     int pCallNotify(const std::string &name,
00374                     const std::string &key,
00375                     const ALValue &value,
00376                     const ALValue &message = std::string(),
00377                     std::pair<int, int>* cache = 0);
00378 
00379     std::string moduleName() const;
00380 
00384     qi::AnyObject asObject();
00385 
00386     ALProxyPrivate    *_p;
00387     qi::AnyWeakObject _object;
00388   protected:
00389     int xMetaPCall(const std::string &signature, const qi::GenericFunctionParameters &in);
00390 
00391     friend class AL::ALModuleCore;
00393   };  // ALProxy
00394 
00395   typedef boost::shared_ptr<ALProxy> ALProxyPtr;
00396 }   // namespace AL
00397 
00398 #include <alcommon/alproxy.hxx>
00399 
00400 #endif  // _LIBALCOMMON_ALCOMMON_ALPROXY_H_
00401 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines