libalcommon
1.14.5
|
ALProxy is a client to the served methods of a module. More...
#include <alcommon/alproxy.h>
Public Types | |
enum | pProxyOption { NO_OPTION = 0, FORCED_LOCAL = 1, NO_LOAD_DEPENDS = 2, MAIN_PROXY = 4 } |
Different options for the ALProxy. More... | |
typedef boost::shared_ptr < ALProxy > | Ptr |
Shared pointer to ALProxy. | |
typedef boost::weak_ptr< ALProxy > | WeakPtr |
Weak pointer to ALProxy. | |
typedef int(* | onFinishedCallback )(const char *, int, const AL::ALValue &) |
Public Member Functions | |
boost::shared_ptr< ALProxy > | getThis () |
Get a pointer to this ALProxy. | |
boost::shared_ptr< const ALProxy > | getThis () const |
Get a pointer to this ALProxy. | |
ALProxy (const ALProxy &rhs) | |
const ALProxy & | operator= (const ALProxy &rhs) |
ALProxy (boost::shared_ptr< ALBroker > pBroker, const std::string &pModuleName, int pProxyMask=0, int timeout=0) | |
Constructor. | |
ALProxy (const std::string &pModuleName, const std::string &pIp, int pPort, int pProxyMask=0, int timeout=0) | |
Constructor allowing to use proxy without instancing a broker. | |
ALProxy (const std::string &pModuleName, const std::string &pIp, int pPort, boost::shared_ptr< ALBroker > pBroker, int pProxyMask=0, int timeout=0) | |
Constructor. | |
ALProxy (const std::string &pModuleName, int pProxyOption, int pTimeout) | |
Constructor. | |
virtual | ~ALProxy (void) |
Destructor. | |
std::string | remoteBrokerName () |
return the name of the remote broker | |
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). | |
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). | |
std::string | version () |
Get the version. | |
boost::shared_ptr< ALModule > | getModule () const |
Get the module. | |
boost::shared_ptr< ALModuleCore > | getModuleCore () const |
Get the moduleCore. | |
int | getInfo (ALModuleInfo &pModuleInfo) |
Get information about the module stored into pModuleInfo. | |
bool | isLocal () |
Check if the module is in the same process than the proxy. | |
bool | isValid () |
Make sure that we notice that someone has invalidated our module. | |
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::shared_ptr< ALBroker > | getParentBroker (void) const |
Get the parent broker. | |
void | destroyConnection (void) |
Destroy a proxy to clean each shared_ptr of the class. | |
template<typename R > | |
R | call (const std::string &pName) |
template<typename R , typename P1 > | |
R | call (const std::string &pName, const P1 &p1) |
template<typename R , typename P1 , typename P2 > | |
R | call (const std::string &pName, const P1 &p1, const P2 &p2) |
template<typename R , typename P1 , typename P2 , typename P3 > | |
R | call (const std::string &pName, const P1 &p1, const P2 &p2, const P3 &p3) |
template<typename R , typename P1 , typename P2 , typename P3 , typename P4 > | |
R | call (const std::string &pName, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4) |
template<typename R , typename P1 , typename P2 , typename P3 , typename P4 , typename P5 > | |
R | call (const std::string &pName, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5) |
template<typename R , typename P1 , typename P2 , typename P3 , typename P4 , typename P5 , typename P6 > | |
R | call (const std::string &pName, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5, const P6 &p6) |
void | callVoid (const std::string &pName) |
template<typename P1 > | |
void | callVoid (const std::string &pName, const P1 &p1) |
template<typename P1 , typename P2 > | |
void | callVoid (const std::string &pName, const P1 &p1, const P2 &p2) |
template<typename P1 , typename P2 , typename P3 > | |
void | callVoid (const std::string &pName, const P1 &p1, const P2 &p2, const P3 &p3) |
template<typename P1 , typename P2 , typename P3 , typename P4 > | |
void | callVoid (const std::string &pName, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4) |
template<typename P1 , typename P2 , typename P3 , typename P4 , typename P5 > | |
void | callVoid (const std::string &pName, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5) |
template<typename P1 , typename P2 , typename P3 , typename P4 , typename P5 , typename P6 > | |
void | callVoid (const std::string &pName, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5, const P6 &p6) |
int | pCall (const std::string &pName) |
template<typename P1 > | |
int | pCall (const std::string &pName, const P1 &p1) |
template<typename P1 , typename P2 > | |
int | pCall (const std::string &pName, const P1 &p1, const P2 &p2) |
template<typename P1 , typename P2 , typename P3 > | |
int | pCall (const std::string &pName, const P1 &p1, const P2 &p2, const P3 &p3) |
template<typename P1 , typename P2 , typename P3 , typename P4 > | |
int | pCall (const std::string &pName, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4) |
template<typename P1 , typename P2 , typename P3 , typename P4 , typename P5 > | |
int | pCall (const std::string &pName, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5) |
template<typename P1 , typename P2 , typename P3 , typename P4 , typename P5 , typename P6 > | |
int | pCall (const std::string &pName, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5, const P6 &p6) |
bool | wait (const int &id, const int &timeoutPeriod) |
Wait for the end of a long running method that was called using 'post'. | |
void | stop (const int &id) |
Stop a long running method that was called using 'post'. | |
bool | isRunning (const int &id) |
Check if the method is running. |
ALProxy is a client to the served methods of a module.
It gives access to the methods of a module without needing to know if the module that provides a service is in the same process, on the same machine, or on the same tcp network.
ALProxy is a generic client in that it can be constructed using just the name of the module that you wish to connect to. Once connected, methods are availble via templated calls. While generic and flexible, these provide no checking on the availabilty or signature of a method until runtime.
All Aldebaran provided modules have classes called 'specific' proxies built around this generic proxy. When using a specific proxy, explicit method signatures are provided which allows correctness to be validated at runtime. In addition, specific proxies include optimisations for local calls that are easily available in the generic proxy. e.g. #include <alproxies/altexttospeechproxy> ... AL::ALTextToSpeechProxy tts; tts.say("hello world");
Shared pointer to ALProxy.
Weak pointer to ALProxy.
AL::ALProxy::ALProxy | ( | boost::shared_ptr< ALBroker > | pBroker, |
const std::string & | pModuleName, | ||
int | pProxyMask = 0 , |
||
int | timeout = 0 |
||
) |
Constructor.
pBroker | pointer to a broker |
pModuleName | module's name |
pProxyMask | |
timeout |
AL::ALProxy::ALProxy | ( | const std::string & | pModuleName, |
const std::string & | pIp, | ||
int | pPort, | ||
int | pProxyMask = 0 , |
||
int | timeout = 0 |
||
) |
Constructor allowing to use proxy without instancing a broker.
pModuleName | module's name |
pIp | |
pPort | |
pProxyMask | |
timeout |
AL::ALProxy::ALProxy | ( | const std::string & | pModuleName, |
const std::string & | pIp, | ||
int | pPort, | ||
boost::shared_ptr< ALBroker > | pBroker, | ||
int | pProxyMask = 0 , |
||
int | timeout = 0 |
||
) |
Constructor.
pModuleName | module's name |
pIp | |
pPort | |
pBroker | |
pProxyMask | |
timeout |
AL::ALProxy::ALProxy | ( | const std::string & | pModuleName, |
int | pProxyOption, | ||
int | pTimeout | ||
) |
Constructor.
pModuleName | module's name |
pProxyOption | |
pTimeout |
AL::ALValue AL::ALProxy::genericCall | ( | const std::string & | strMethodName, |
const AL::ALValue & | listParams | ||
) |
A generic call, without type optimisation, using AL::ALValue for each call... (local or not).
Used from a C++ code not knowing the signature of the called method
strMethodName | the name of the method to call |
listParams | the list of parameters (possibly no params) |
int AL::ALProxy::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).
Used from a C++ code not knowing the signature of the called method
strMethodName | the name of the method to call |
listParams | the list of parameters (possibly no params) |
pCallbackToCallOnFinished | a callback to call when task is finished (NULL if no callback) DEPRECATED |
pszCallerName | the name of the caller (proxy name or module name, dependings on langage, script, caller...) DEPRECATED |
boost::shared_ptr<ALFunctorBase> AL::ALProxy::getFunctor | ( | const std::string & | pName, |
const std::vector< std::string > & | pParamTypes | ||
) |
Get a pointer to a method form its name and its parameters.
pName | name of the method |
pParamTypes | parameters' list |
int AL::ALProxy::getInfo | ( | ALModuleInfo & | pModuleInfo | ) |
Get information about the module stored into pModuleInfo.
pModuleInfo | reference to the module information found |
boost::shared_ptr<ALModule> AL::ALProxy::getModule | ( | ) | const |
Get the module.
boost::shared_ptr<ALModuleCore> AL::ALProxy::getModuleCore | ( | ) | const |
Get the moduleCore.
boost::shared_ptr<ALBroker> AL::ALProxy::getParentBroker | ( | void | ) | const |
Get the parent broker.
boost::shared_ptr<ALProxy> AL::ALProxy::getThis | ( | ) |
Get a pointer to this ALProxy.
boost::shared_ptr<const ALProxy> AL::ALProxy::getThis | ( | ) | const |
Get a pointer to this ALProxy.
bool AL::ALProxy::isLocal | ( | ) |
Check if the module is in the same process than the proxy.
bool AL::ALProxy::isRunning | ( | const int & | id | ) |
Check if the method is running.
id | the ID of the method that was returned when calling the method using 'post' |
bool AL::ALProxy::isValid | ( | ) |
Make sure that we notice that someone has invalidated our module.
This check is done before each specialized proxy's use of a method ptr.
std::string AL::ALProxy::remoteBrokerName | ( | ) |
return the name of the remote broker
void AL::ALProxy::stop | ( | const int & | id | ) |
Stop a long running method that was called using 'post'.
id | the ID of the method that was returned when calling the method using 'post' |
std::string AL::ALProxy::version | ( | ) |
Get the version.
bool AL::ALProxy::wait | ( | const int & | id, |
const int & | timeoutPeriod | ||
) |
Wait for the end of a long running method that was called using 'post'.
id | the ID of the method that was returned when calling the method using 'post' |
timeoutPeriod | the timeout period in ms. To wait indefinately, use a timeoutPeriod of zero |