libalcommon  1.14
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions
AL::ALProxy Class Reference

ALProxy is a client to the served methods of a module. More...

#include <alcommon/alproxy.h>

List of all members.

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< ALProxyWeakPtr
 Weak pointer to ALProxy.
typedef int(* onFinishedCallback )(const char *, int, const AL::ALValue &)

Public Member Functions

boost::shared_ptr< ALProxygetThis ()
 Get a pointer to this ALProxy.
boost::shared_ptr< const ALProxygetThis () const
 Get a pointer to this ALProxy.
 ALProxy (const ALProxy &rhs)
const ALProxyoperator= (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< ALModulegetModule () const
 Get the module.
boost::shared_ptr< ALModuleCoregetModuleCore () 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< ALFunctorBasegetFunctor (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< ALBrokergetParentBroker (void) const
 Get the parent broker.
void destroyConnection (void)
 Destroy a proxy to clean each shared_ptr of the class.
template<typename R >
call (const std::string &pName)
template<typename R , typename P1 >
call (const std::string &pName, const P1 &p1)
template<typename R , typename P1 , typename P2 >
call (const std::string &pName, const P1 &p1, const P2 &p2)
template<typename R , typename P1 , typename P2 , typename P3 >
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 >
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 >
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 >
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.

Detailed Description

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");

Definition at line 65 of file alproxy.h.


Member Typedef Documentation

Shared pointer to ALProxy.

Deprecated:
Use boost::shared_ptr<ALProxy> instead.

Definition at line 73 of file alproxy.h.

Weak pointer to ALProxy.

Deprecated:
Use boost::weak_ptr<ALProxy> instead.

Definition at line 79 of file alproxy.h.


Member Enumeration Documentation

Different options for the ALProxy.

Enumerator:
NO_OPTION 

no options

FORCED_LOCAL 

only local proxy

NO_LOAD_DEPENDS 

don't load dependency

MAIN_PROXY 

only main broker proxy

Definition at line 98 of file alproxy.h.


Constructor & Destructor Documentation

AL::ALProxy::ALProxy ( boost::shared_ptr< ALBroker pBroker,
const std::string &  pModuleName,
int  pProxyMask = 0,
int  timeout = 0 
)

Constructor.

Parameters:
pBrokerpointer to a broker
pModuleNamemodule'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.

Parameters:
pModuleNamemodule'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.

Parameters:
pModuleNamemodule's name
pIp
pPort
pBroker
pProxyMask
timeout
AL::ALProxy::ALProxy ( const std::string &  pModuleName,
int  pProxyOption,
int  pTimeout 
)

Constructor.

Parameters:
pModuleNamemodule's name
pProxyOption
pTimeout

Member Function Documentation

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

Parameters:
strMethodNamethe name of the method to call
listParamsthe list of parameters (possibly no params)
Returns:
an alvalue, possibly invalid if function returns nothing
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

Warning:
the callback will still be called if the proxy is destroyed.
Parameters:
strMethodNamethe name of the method to call
listParamsthe list of parameters (possibly no params)
pCallbackToCallOnFinisheda callback to call when task is finished (NULL if no callback) DEPRECATED
pszCallerNamethe name of the caller (proxy name or module name, dependings on langage, script, caller...) DEPRECATED
Returns:
nID: ID of the new created task (0 if error)
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.

Parameters:
pNamename of the method
pParamTypesparameters' list
Returns:
a pointer to the method
int AL::ALProxy::getInfo ( ALModuleInfo pModuleInfo)

Get information about the module stored into pModuleInfo.

Parameters:
pModuleInforeference to the module information found
Returns:
0 if module info find, -1 otherwise
boost::shared_ptr<ALModule> AL::ALProxy::getModule ( ) const

Get the module.

Returns:
a pointer to the module
boost::shared_ptr<ALModuleCore> AL::ALProxy::getModuleCore ( ) const

Get the moduleCore.

Returns:
a pointer to the moduleCore
boost::shared_ptr<ALBroker> AL::ALProxy::getParentBroker ( void  ) const

Get the parent broker.

Returns:
a pointer to the parent broker
boost::shared_ptr<ALProxy> AL::ALProxy::getThis ( )

Get a pointer to this ALProxy.

Returns:
A pointer to this
boost::shared_ptr<const ALProxy> AL::ALProxy::getThis ( ) const

Get a pointer to this ALProxy.

Returns:
A const pointer to this
bool AL::ALProxy::isLocal ( )

Check if the module is in the same process than the proxy.

Returns:
true if the module is in the same process, false otherwise
bool AL::ALProxy::isRunning ( const int &  id)

Check if the method is running.

Parameters:
idthe ID of the method that was returned when calling the method using 'post'
Returns:
true if the method is currently running.
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.

Returns:
true if the module is valide, false otherwise
std::string AL::ALProxy::remoteBrokerName ( )

return the name of the remote broker

Returns:
name of the remote broker, "" is it's a local broker
void AL::ALProxy::stop ( const int &  id)

Stop a long running method that was called using 'post'.

Parameters:
idthe ID of the method that was returned when calling the method using 'post'
std::string AL::ALProxy::version ( )

Get the version.

Returns:
the revision number as a string
bool AL::ALProxy::wait ( const int &  id,
const int &  timeoutPeriod 
)

Wait for the end of a long running method that was called using 'post'.

Parameters:
idthe ID of the method that was returned when calling the method using 'post'
timeoutPeriodthe timeout period in ms. To wait indefinately, use a timeoutPeriod of zero
Returns:
true if the timeout period terminated. false if the method returned.

The documentation for this class was generated from the following files: