libalcommon  2.4.3.28-r2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | List of all members
AL::ALProxy Class Reference

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

Public Member Functions

boost::shared_ptr< ALProxygetThis ()
 Get a pointer to this ALProxy. More...
 
boost::shared_ptr< const ALProxygetThis () const
 Get a pointer to this ALProxy. More...
 
 ALProxy (const ALProxy &rhs)
 
 ALProxy (boost::shared_ptr< ALBroker > pBroker, const std::string &pModuleName, int pProxyMask=0, int timeout=0)
 Constructor. More...
 
 ALProxy (qi::AnyObject pObject, const std::string &pModuleName)
 Constructor. More...
 
 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. More...
 
 ALProxy (const std::string &pModuleName, const std::string &pIp, int pPort, boost::shared_ptr< ALBroker > pBroker, int pProxyMask=0, int timeout=0)
 Constructor. More...
 
virtual ~ALProxy (void)
 Destructor. More...
 
std::string remoteBrokerName ()
 return the name of the remote broker More...
 
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). More...
 
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). More...
 
std::string version ()
 Get the version. More...
 
boost::shared_ptr< ALModulegetModule () const
 Get the module. More...
 
boost::shared_ptr< ALModuleCoregetModuleCore () const
 Get the moduleCore. More...
 
int getInfo (ALModuleInfo &pModuleInfo)
 Get information about the module stored into pModuleInfo. More...
 
bool isLocal ()
 Check if the module is in the same process than the proxy. More...
 
bool isValid ()
 Make sure that we notice that someone has invalidated our module. More...
 
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. More...
 
boost::shared_ptr< ALBrokergetParentBroker (void) const
 Get the parent broker. More...
 
void destroyConnection (void)
 Destroy a proxy to clean each shared_ptr of the class. More...
 
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'. More...
 
qi::FutureSync< void > wait (const int &id)
 Waits until the end of a long running method using the ID that was returned from a method started with 'post'. More...
 
void stop (const int &id)
 Stop a long running method that was called using 'post'. More...
 
bool isRunning (const int &id)
 Check if the method is running. More...
 
template<typename P0 >
int pCall (const std::string &pName, const P0 &p0)
 
template<typename P0 , typename P1 >
int pCall (const std::string &pName, const P0 &p0, const P1 &p1)
 
template<typename P0 , typename P1 , typename P2 >
int pCall (const std::string &pName, const P0 &p0, const P1 &p1, const P2 &p2)
 
template<typename P0 , typename P1 , typename P2 , typename P3 >
int pCall (const std::string &pName, const P0 &p0, const P1 &p1, const P2 &p2, const P3 &p3)
 
template<typename P0 , typename P1 , typename P2 , typename P3 , typename P4 >
int pCall (const std::string &pName, const P0 &p0, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4)
 
template<typename P0 , typename P1 , typename P2 , typename P3 , typename P4 , typename P5 >
int pCall (const std::string &pName, const P0 &p0, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5)
 

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

Lifetime: The broker own a private qi::object, proxies own a weak pointer on the object. If the object is destroyed (because the module do not exist anymore, the weak_ptr wont work anymore). once there is no weak_ptr on the object the object could be deleted from broker.

Definition at line 70 of file alproxy.h.

Member Typedef Documentation

typedef int(* AL::ALProxy::onFinishedCallback)(const char *, int, const AL::ALValue &)

Definition at line 86 of file alproxy.h.

Shared pointer to ALProxy.

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

Definition at line 78 of file alproxy.h.

Weak pointer to ALProxy.

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

Definition at line 84 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 103 of file alproxy.h.

Constructor & Destructor Documentation

AL::ALProxy::ALProxy ( const ALProxy rhs)
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 ( qi::AnyObject  pObject,
const std::string &  pModuleName 
)

Constructor.

Parameters
pObjectpointer to a service object be careful this pointer wont be owned by ALProxy
pModuleNamemodule's name
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
virtual AL::ALProxy::~ALProxy ( void  )
virtual

Destructor.

Member Function Documentation

template<typename R >
R AL::ALProxy::call ( const std::string &  pName)
template<typename R , typename P1 >
R AL::ALProxy::call ( const std::string &  pName,
const P1 &  p1 
)
template<typename R , typename P1 , typename P2 >
R AL::ALProxy::call ( const std::string &  pName,
const P1 &  p1,
const P2 &  p2 
)
template<typename R , typename P1 , typename P2 , typename P3 >
R AL::ALProxy::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 AL::ALProxy::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 AL::ALProxy::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 AL::ALProxy::call ( const std::string &  pName,
const P1 &  p1,
const P2 &  p2,
const P3 &  p3,
const P4 &  p4,
const P5 &  p5,
const P6 &  p6 
)
void AL::ALProxy::callVoid ( const std::string &  pName)
inline
template<typename P1 >
void AL::ALProxy::callVoid ( const std::string &  pName,
const P1 &  p1 
)
template<typename P1 , typename P2 >
void AL::ALProxy::callVoid ( const std::string &  pName,
const P1 &  p1,
const P2 &  p2 
)
template<typename P1 , typename P2 , typename P3 >
void AL::ALProxy::callVoid ( const std::string &  pName,
const P1 &  p1,
const P2 &  p2,
const P3 &  p3 
)
template<typename P1 , typename P2 , typename P3 , typename P4 >
void AL::ALProxy::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 AL::ALProxy::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 AL::ALProxy::callVoid ( const std::string &  pName,
const P1 &  p1,
const P2 &  p2,
const P3 &  p3,
const P4 &  p4,
const P5 &  p5,
const P6 &  p6 
)
void AL::ALProxy::destroyConnection ( void  )

Destroy a proxy to clean each shared_ptr of the class.

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
template<typename P0 >
int AL::ALProxy::pCall ( const std::string &  pName,
const P0 &  p0 
)

Definition at line 74 of file alproxy.hxx.

template<typename P0 , typename P1 >
int AL::ALProxy::pCall ( const std::string &  pName,
const P0 &  p0,
const P1 &  p1 
)

Definition at line 85 of file alproxy.hxx.

template<typename P0 , typename P1 , typename P2 >
int AL::ALProxy::pCall ( const std::string &  pName,
const P0 &  p0,
const P1 &  p1,
const P2 &  p2 
)

Definition at line 97 of file alproxy.hxx.

template<typename P0 , typename P1 , typename P2 , typename P3 >
int AL::ALProxy::pCall ( const std::string &  pName,
const P0 &  p0,
const P1 &  p1,
const P2 &  p2,
const P3 &  p3 
)

Definition at line 110 of file alproxy.hxx.

template<typename P0 , typename P1 , typename P2 , typename P3 , typename P4 >
int AL::ALProxy::pCall ( const std::string &  pName,
const P0 &  p0,
const P1 &  p1,
const P2 &  p2,
const P3 &  p3,
const P4 &  p4 
)

Definition at line 124 of file alproxy.hxx.

template<typename P0 , typename P1 , typename P2 , typename P3 , typename P4 , typename P5 >
int AL::ALProxy::pCall ( const std::string &  pName,
const P0 &  p0,
const P1 &  p1,
const P2 &  p2,
const P3 &  p3,
const P4 &  p4,
const P5 &  p5 
)

Definition at line 139 of file alproxy.hxx.

int AL::ALProxy::pCall ( const std::string &  pName)
inline

Definition at line 64 of file alproxy.hxx.

template<typename P1 >
int AL::ALProxy::pCall ( const std::string &  pName,
const P1 &  p1 
)
template<typename P1 , typename P2 >
int AL::ALProxy::pCall ( const std::string &  pName,
const P1 &  p1,
const P2 &  p2 
)
template<typename P1 , typename P2 , typename P3 >
int AL::ALProxy::pCall ( const std::string &  pName,
const P1 &  p1,
const P2 &  p2,
const P3 &  p3 
)
template<typename P1 , typename P2 , typename P3 , typename P4 >
int AL::ALProxy::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 AL::ALProxy::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 AL::ALProxy::pCall ( const std::string &  pName,
const P1 &  p1,
const P2 &  p2,
const P3 &  p3,
const P4 &  p4,
const P5 &  p5,
const P6 &  p6 
)
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.
qi::FutureSync<void> AL::ALProxy::wait ( const int &  id)

Waits until the end of a long running method using the ID that was returned from a method started with 'post'.

Parameters
taskIdthe ID of the method that was returned by 'post'
Returns
a cancelable future that will call stop(id) upon cancel

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