libalcommon
1.14
|
ALModuleCore is the superclass of user modules. More...
#include <alcommon/almodulecore.h>
Public Types | |
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. |
Public Member Functions | |
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. | |
virtual void | exit () |
Exit the module and unregister it. | |
const std::string & | getName () const |
Get the name of the module given when constructing. | |
boost::shared_ptr< ALModuleInfo > | getModuleInfo () |
Get information about the module. | |
virtual std::string | httpGet () |
Called by the broker webpage to detail 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 | functionStop (int pTaskID) |
Local stop. Use stop(id) for remote/local compatibility. | |
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 > | 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. |
Protected Member Functions | |
virtual void | init (void) |
Call at every module creation. | |
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. |
Friends | |
class | baseModule |
ALModuleCore is the superclass of user modules.
It implements basic functions that enables communication with naoqi brokers, so that the distributed approach is painless for users who just want to come up with a simple module quickly, compile it and have it work, without having to deal with interprocess communication.
Definition at line 61 of file almodulecore.h.
Shared pointer to ALModuleCore.
Definition at line 74 of file almodulecore.h.
Weak pointer to ALModuleCore.
Definition at line 80 of file almodulecore.h.
Module type (Ruby, lua, and matlab are not currently used)
CPP |
C++ type |
PYTHON |
python type |
RUBY |
ruby type (unused) |
LUA |
lua type (unused) |
MATLAB |
matlab type (unused) |
URBI |
urbi type |
Definition at line 86 of file almodulecore.h.
AL::ALModuleCore::ALModuleCore | ( | boost::shared_ptr< ALBroker > | pBroker, |
const std::string & | pName | ||
) |
Constructor.
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 | a pointer to the broker |
pName | name of the module |
|
protected |
Add a method example.
pLanguage | the language of the example (c++, python, .net, etc) |
pExample | the example |
|
protected |
Add a module example.
pLanguage | the language of the example (c++, python, .net, etc) |
pExample | the example |
|
protected |
Add a documented parameter to a method.
pName | the name of the parameter |
pDesc | the description of the parmeter |
|
protected |
Bind a method.
pFunctor | pointer to a generic functor |
|
protected |
Bind a method.
pFunctor | pointer to a generic functor |
pName | the name of the method |
pClass | the name of your class |
pFunctionDescription | the description of the method |
pMethodDescription | the description method. |
|
protected |
Use to define a bound method.
pFunctor | pointer to a generic functor |
|
inlinestatic |
Create a module core link to a broker.
pBroker | to pointer the a broker |
ALError |
Definition at line 341 of file almodulecore.h.
|
inlinestatic |
Create a module core link to a broker.
pBroker | pointer to the a broker |
name | module's name |
ALError |
Definition at line 367 of file almodulecore.h.
|
inlinestatic |
Create a URBI module core link to a broker.
pBroker | pointer to the a broker |
name | module's name |
Definition at line 392 of file almodulecore.h.
|
virtual |
Execute a method with some arguments and store the result.
pMethod | method to execute |
pParams | set of arguments for the method |
pResult | result of the method execution |
|
protected |
Define the name of a bound method.
pName | the name of the method |
pClass | the name of your class |
pFunctionDescription | the description of the method |
pMask | optional Mask, default 0. see almethodinfo.h for more information |
void AL::ALModuleCore::functionStop | ( | int | pTaskID | ) |
Local stop. Use stop(id) for remote/local compatibility.
pTaskID | the ID of the task you want to stop |
Reimplemented in AL::ALModule.
std::string AL::ALModuleCore::getBrokerName | ( | ) |
Get the name of the registered broker.
ALMethodInfo& AL::ALModuleCore::getCurrentMethodDescription | ( | ) |
Get a reference to a temporary object used to construct method help.
ALMethodInfo* AL::ALModuleCore::getFunctionDesc | ( | const std::string & | pName | ) |
deprecated
ALMethodInfo* AL::ALModuleCore::getFunctionDesc | ( | const std::string & | pName, |
std::vector< std::string > | pParamsType | ||
) |
deprecated
ALMethodInfo* AL::ALModuleCore::getFunctionDesc | ( | const std::string & | pName, |
const AL::ALValue & | pParams | ||
) |
deprecated
ALMethodInfo* AL::ALModuleCore::getFunctionDescByNameMember | ( | const std::string & | pName, |
const std::vector< std::string > & | paramType, | ||
bool | softCompare = true |
||
) |
deprecated
AL::ALValue AL::ALModuleCore::getMethodHelp | ( | const std::string & | pMethodName | ) |
Get a method's description string.
pMethodName | method's name. |
ALMethodInfo AL::ALModuleCore::getMethodHelpObject | ( | const std::string & | pMethodName | ) |
Get a method's description string.
pMethodName | method's name. |
ALMethodInfo* AL::ALModuleCore::getMethodInfo | ( | const std::string & | pName | ) |
Call by a proxy to check function's parameter.
pName | function Name |
ALMethodInfo* AL::ALModuleCore::getMethodInfo | ( | const std::string & | pName, |
std::vector< std::string > | pParamsType | ||
) |
Call by a proxy to check function's parameter.
pName | function Name |
pParamsType | parameters type |
ALMethodInfo* AL::ALModuleCore::getMethodInfo | ( | const std::string & | pName, |
const AL::ALValue & | pParams | ||
) |
Call by a proxy to check function's parameter.
pName | function Name |
pParams | method parameters |
ALMethodInfo* AL::ALModuleCore::getMethodInfoByNameMember | ( | const std::string & | pName, |
const std::vector< std::string > & | paramType, | ||
bool | softCompare = true |
||
) |
Find method information by name and argument type not only by map key.
pName | method name |
paramType | list of parameters |
softCompare | true mean ALValue can be anyType (use it for all type compare except local call) |
std::vector<std::string> AL::ALModuleCore::getMethodList | ( | ) |
Get the module method list.
int AL::ALModuleCore::getModuleID | ( | ) |
Get the module id given to it be the broker.
boost::shared_ptr<ALModuleInfo> AL::ALModuleCore::getModuleInfo | ( | ) |
Get information about the module.
ModuleType AL::ALModuleCore::getModuleType | ( | void | ) |
Get the type of the module.
const std::string& AL::ALModuleCore::getName | ( | ) | const |
Get the name of the module given when constructing.
boost::shared_ptr<ALBroker> AL::ALModuleCore::getParentBroker | ( | ) | const |
Get a pointer to the broker context.
boost::shared_ptr<AL::ALProxy> AL::ALModuleCore::getProxy | ( | const std::string & | pModuleName | ) |
Get access to a module.
ex: getProxy("ALMotion")
pModuleName | module name |
boost::shared_ptr<ALModuleCore> AL::ALModuleCore::getThis | ( | ) |
Getter to the class.
boost::shared_ptr<const ALModuleCore> AL::ALModuleCore::getThis | ( | ) | const |
Getter to class.
std::string AL::ALModuleCore::getUsage | ( | const std::string & | methodName | ) |
Get the usage of a method as a string.
methodName | the name of the method |
|
virtual |
Called by the broker webpage to detail the module.
Reimplemented in AL::ALModule.
|
inlineprotectedvirtual |
Call at every module creation.
User can overload it
Reimplemented in AL::ALModule.
Definition at line 424 of file almodulecore.h.
void AL::ALModuleCore::initModule | ( | void | ) |
Register a module to a broker.
Automatically called when loading a module from autoload.ini
bool AL::ALModuleCore::isClosing | ( | ) |
Check if someone want to exit the module.
bool AL::ALModuleCore::isModuleStopped | ( | ) |
Know if program or module termination is asked.
AL::ALValue AL::ALModuleCore::moduleHelp | ( | ) |
Get the module's description.
bool AL::ALModuleCore::ping | ( | void | ) |
Just a ping. Used to test connectivity to a module.
void AL::ALModuleCore::setModuleDescription | ( | const std::string & | pDesc | ) |
Set the description of the module.
pDesc | a description of the module |
void AL::ALModuleCore::setModuleID | ( | int | id | ) |
Set the id of the module used to determine the shutdown order.
id | the id given to it by the broker |
void AL::ALModuleCore::setModuleType | ( | ModuleType | pType | ) |
Set the type of the module.
pType | type of the module |
|
protected |
Sets the description of the return value.
pName | the name of the return item (used in autogeneration) |
pDesc | the description of the return item |
|
virtual |
Get module's version.