libalcommon
1.14
|
ALModule can be used as a base class for user modules to help serve and advertise their methods. More...
#include <alcommon/almodule.h>
Public Member Functions | |
ALModule (boost::shared_ptr< ALBroker > pBroker, const std::string &pName) | |
Creates an ALModule. | |
virtual | ~ALModule () |
Destructor. | |
virtual std::string | httpGet () |
Called by the broker webpage to detail the module. This can be overriden to provide information specific to your module. The default is an empty page. | |
virtual void | stop (const int &id) |
Stops a module's method using the ID given returned by a 'post' call. Module authors are encouraged to implement this if they have long running methods that they wish to allow users to interrupt. | |
bool | isStopRequired (const int &id=-1) |
Check if the user call stop. | |
bool | wait (const int &id, const int &timeout) |
Waits until the end of a long running method using the ID that was returned from a method started with 'post'. | |
bool | isRunning (const int &id) |
Determines if the method created with a 'post' is still running. | |
int | getMethodID (void) |
Return unique ID if method call. | |
bool | isPCalled () |
Check if the module is pcalled. | |
virtual void | exit () |
Exit the module and unregister it. | |
QI_API_DEPRECATED void | functionStop (int pIDTask) |
deprecated | |
virtual void | init (void) |
It will be called at every module creation, user can overload it. | |
Public Member Functions inherited from AL::ALModuleCore | |
ALModuleCore (boost::shared_ptr< ALBroker > pBroker, const std::string &pName) | |
Constructor. | |
virtual | ~ALModuleCore () |
Destructor. | |
ALMethodInfo & | getCurrentMethodDescription () |
Get a reference to a temporary object used to construct method help. | |
boost::shared_ptr< ALModuleCore > | getThis () |
Getter to the class. | |
boost::shared_ptr< const ALModuleCore > | getThis () const |
Getter to class. | |
bool | isClosing () |
Check if someone want to exit the module. | |
void | initModule (void) |
Register a module to a broker. | |
boost::shared_ptr< AL::ALProxy > | getProxy (const std::string &pModuleName) |
Get access to a module. | |
std::string | getBrokerName () |
Get the name of the registered broker. | |
ModuleType | getModuleType (void) |
Get the type of the module. | |
void | setModuleType (ModuleType pType) |
Set the type of the module. | |
virtual ALMethodInfo * | execute (const std::string &pMethod, const AL::ALValue &pParams, AL::ALValue &pResult) |
Execute a method with some arguments and store the result. | |
std::vector< std::string > | getMethodList () |
Get the module method list. | |
AL::ALValue | getMethodHelp (const std::string &pMethodName) |
Get a method's description string. | |
ALMethodInfo | getMethodHelpObject (const std::string &pMethodName) |
Get a method's description string. | |
AL::ALValue | moduleHelp () |
Get the module's description. | |
bool | ping (void) |
Just a ping. Used to test connectivity to a module. | |
virtual std::string | version () |
Get module's version. | |
const std::string & | getName () const |
Get the name of the module given when constructing. | |
boost::shared_ptr< ALModuleInfo > | getModuleInfo () |
Get information about the module. | |
ALMethodInfo * | getMethodInfoByNameMember (const std::string &pName, const std::vector< std::string > ¶mType, bool softCompare=true) |
Find method information by name and argument type not only by map key. | |
ALMethodInfo * | getMethodInfo (const std::string &pName) |
Call by a proxy to check function's parameter. | |
ALMethodInfo * | getMethodInfo (const std::string &pName, std::vector< std::string > pParamsType) |
Call by a proxy to check function's parameter. | |
ALMethodInfo * | getMethodInfo (const std::string &pName, const AL::ALValue &pParams) |
Call by a proxy to check function's parameter. | |
ALMethodInfo * | getFunctionDesc (const std::string &pName) |
deprecated | |
ALMethodInfo * | getFunctionDesc (const std::string &pName, std::vector< std::string > pParamsType) |
deprecated | |
ALMethodInfo * | getFunctionDesc (const std::string &pName, const AL::ALValue &pParams) |
deprecated | |
ALMethodInfo * | getFunctionDescByNameMember (const std::string &pName, const std::vector< std::string > ¶mType, bool softCompare=true) |
deprecated | |
boost::shared_ptr< ALBroker > | getParentBroker () const |
Get a pointer to the broker context. | |
void | setModuleDescription (const std::string &pDesc) |
Set the description of the module. | |
std::string | getUsage (const std::string &methodName) |
Get the usage of a method as a string. | |
bool | isModuleStopped () |
Know if program or module termination is asked. | |
void | setModuleID (int id) |
Set the id of the module used to determine the shutdown order. | |
int | getModuleID () |
Get the module id given to it be the broker. |
Static Public Member Functions | |
template<class T > | |
static boost::shared_ptr< T > | createModule (boost::shared_ptr< ALBroker > pBroker) |
Create a module and link it to a broker. | |
template<class T , typename P1 > | |
static boost::shared_ptr< T > | createModule (boost::shared_ptr< ALBroker > pBroker, P1 p1) |
Create a module and link it to a broker. | |
Static Public Member Functions inherited from AL::ALModuleCore | |
template<class T > | |
static boost::shared_ptr< T > | createModuleCore (boost::shared_ptr< ALBroker > pBroker) |
Create a module core link to a broker. | |
template<class T > | |
static boost::shared_ptr< T > | createModuleCore (boost::shared_ptr< ALBroker > pBroker, const std::string &name) |
Create a module core link to a broker. | |
template<class T > | |
static boost::shared_ptr< T > | createUrbiModule (boost::shared_ptr< ALBroker > pBroker, const std::string &name) |
Create a URBI module core link to a broker. |
Friends | |
class | baseModule |
Additional Inherited Members | |
Public Types inherited from AL::ALModuleCore | |
enum | ModuleType { CPP = 0, PYTHON = 1, RUBY = 2, LUA = 3, MATLAB = 4, URBI } |
Module type (Ruby, lua, and matlab are not currently used) More... | |
typedef boost::shared_ptr < ALModuleCore > | Ptr |
Shared pointer to ALModuleCore. | |
typedef boost::weak_ptr < ALModuleCore > | WeakPtr |
Weak pointer to ALModuleCore. | |
Protected Member Functions inherited from AL::ALModuleCore | |
void | bindMethod (boost::shared_ptr< ALFunctorBase > pFunctor) |
Bind a method. | |
void | bindMethod (boost::shared_ptr< ALFunctorBase > pFunctor, const std::string &pName, const std::string &pClass, const std::string &pFunctionDescription, const ALMethodInfo &pMethodDescription) |
Bind a method. | |
void | bindMethodOverload (boost::shared_ptr< ALFunctorBase > pFunctor) |
Use to define a bound method. | |
void | functionName (const std::string &pName, const std::string &pClass, const std::string &pFunctionDescription, int pMask=0) |
Define the name of a bound method. | |
void | addParam (const std::string &pName, const std::string &pDesc) |
Add a documented parameter to a method. | |
void | addModuleExample (const std::string &pLanguage, const std::string &pExample) |
Add a module example. | |
void | addMethodExample (const std::string &pLanguage, const std::string &pExample) |
Add a method example. | |
void | setReturn (const std::string &pName, const std::string &pDesc) |
Sets the description of the return value. |
ALModule can be used as a base class for user modules to help serve and advertise their methods.
Each module advertises the methods that it wishes to make available to clients participating in the network to a broker within the same process.
The broker then transparently handles directory services so that clients need not know if the module that provides a service is in the same process, on the same machine, or on the same tcp network.
Within the same process, direct method calls are used to provide optimal speed without having to change your method signatures.
Clients exist in a growing number of languages including c++, Python, .Net, Java and Matlab.
Definition at line 104 of file almodule.h.
AL::ALModule::ALModule | ( | boost::shared_ptr< ALBroker > | pBroker, |
const std::string & | pName | ||
) |
Creates an ALModule.
An ALModule has a name, and is registered in a broker, so that its methods can be called by other modules, via a proxy constructed with module's name.
pBroker | Pointer to a broker |
pName | The name for the new module. This is used as the prefix for all method calls e.g. MyModule.myMethod() |
|
inlinestatic |
Create a module and link it to a broker.
pBroker | Pointer to the broker |
ALError |
Definition at line 116 of file almodule.h.
|
inlinestatic |
Create a module and link it to a broker.
pBroker | Pointer to the broker |
p1 | first parameter after pBroker for the module's constructor |
ALError |
Definition at line 142 of file almodule.h.
QI_API_DEPRECATED void AL::ALModule::functionStop | ( | int | pIDTask | ) |
deprecated
Find the the right module corresponding to the task and call the stop method. Use ProxyModule.stop(...) for remote/local compatibility
pIDTask | task's ID |
Reimplemented from AL::ALModuleCore.
int AL::ALModule::getMethodID | ( | void | ) |
Return unique ID if method call.
Useful to check for instance if user asked your method to stop. First get ID with getMethodID, then call isRequireStop
|
virtual |
Called by the broker webpage to detail the module. This can be overriden to provide information specific to your module. The default is an empty page.
Reimplemented from AL::ALModuleCore.
bool AL::ALModule::isPCalled | ( | ) |
Check if the module is pcalled.
bool AL::ALModule::isRunning | ( | const int & | id | ) |
Determines if the method created with a 'post' is still running.
id | The id of the method that was returned by 'post' |
bool AL::ALModule::isStopRequired | ( | const int & | id = -1 | ) |
Check if the user call stop.
The | id of the method that was returned by 'post' |
|
virtual |
Stops a module's method using the ID given returned by a 'post' call. Module authors are encouraged to implement this if they have long running methods that they wish to allow users to interrupt.
id | The id of the method that was returned by 'post' |
bool AL::ALModule::wait | ( | const int & | id, |
const int & | timeout | ||
) |
Waits until the end of a long running method using the ID that was returned from a method started with 'post'.
The | id of the method that was returned by 'post' |
timeout | The wait timeout period in ms. If 0 wait indefinately. |