libalcommon  1.14.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends
AL::ALModuleCore Class Reference

ALModuleCore is the superclass of user modules. More...

#include <alcommon/almodulecore.h>

List of all members.

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.
ALMethodInfogetCurrentMethodDescription ()
 Get a reference to a temporary object used to construct method help.
boost::shared_ptr< ALModuleCoregetThis ()
 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::ALProxygetProxy (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 ALMethodInfoexecute (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< ALModuleInfogetModuleInfo ()
 Get information about the module.
virtual std::string httpGet ()
 Called by the broker webpage to detail the module.
ALMethodInfogetMethodInfoByNameMember (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.
ALMethodInfogetMethodInfo (const std::string &pName)
 Call by a proxy to check function's parameter.
ALMethodInfogetMethodInfo (const std::string &pName, std::vector< std::string > pParamsType)
 Call by a proxy to check function's parameter.
ALMethodInfogetMethodInfo (const std::string &pName, const AL::ALValue &pParams)
 Call by a proxy to check function's parameter.
ALMethodInfogetFunctionDesc (const std::string &pName)
 deprecated
ALMethodInfogetFunctionDesc (const std::string &pName, std::vector< std::string > pParamsType)
 deprecated
ALMethodInfogetFunctionDesc (const std::string &pName, const AL::ALValue &pParams)
 deprecated
ALMethodInfogetFunctionDescByNameMember (const std::string &pName, const std::vector< std::string > &paramType, bool softCompare=true)
 deprecated
boost::shared_ptr< ALBrokergetParentBroker () 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

Detailed Description

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.


Member Typedef Documentation

Shared pointer to ALModuleCore.

Deprecated:
Use boost::shared_ptr<ALModuleCore> instead

Definition at line 74 of file almodulecore.h.

Weak pointer to ALModuleCore.

Deprecated:
Use boost::weak_ptr<ALModuleCore> instead

Definition at line 80 of file almodulecore.h.


Member Enumeration Documentation

Module type (Ruby, lua, and matlab are not currently used)

Enumerator:
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.


Constructor & Destructor Documentation

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

Parameters:
pBrokera pointer to the broker
pNamename of the module

Member Function Documentation

void AL::ALModuleCore::addMethodExample ( const std::string &  pLanguage,
const std::string &  pExample 
) [protected]

Add a method example.

Parameters:
pLanguagethe language of the example (c++, python, .net, etc)
pExamplethe example
void AL::ALModuleCore::addModuleExample ( const std::string &  pLanguage,
const std::string &  pExample 
) [protected]

Add a module example.

Parameters:
pLanguagethe language of the example (c++, python, .net, etc)
pExamplethe example
void AL::ALModuleCore::addParam ( const std::string &  pName,
const std::string &  pDesc 
) [protected]

Add a documented parameter to a method.

Parameters:
pNamethe name of the parameter
pDescthe description of the parmeter
void AL::ALModuleCore::bindMethod ( boost::shared_ptr< ALFunctorBase pFunctor) [protected]

Bind a method.

Parameters:
pFunctorpointer to a generic functor
void AL::ALModuleCore::bindMethod ( boost::shared_ptr< ALFunctorBase pFunctor,
const std::string &  pName,
const std::string &  pClass,
const std::string &  pFunctionDescription,
const ALMethodInfo pMethodDescription 
) [protected]

Bind a method.

Parameters:
pFunctorpointer to a generic functor
pNamethe name of the method
pClassthe name of your class
pFunctionDescriptionthe description of the method
pMethodDescriptionthe description method.
void AL::ALModuleCore::bindMethodOverload ( boost::shared_ptr< ALFunctorBase pFunctor) [protected]

Use to define a bound method.

Parameters:
pFunctorpointer to a generic functor
template<class T >
static boost::shared_ptr<T> AL::ALModuleCore::createModuleCore ( boost::shared_ptr< ALBroker pBroker) [inline, static]

Create a module core link to a broker.

Parameters:
pBrokerto pointer the a broker
Returns:
a pointer to the module
Exceptions:
ALError

Definition at line 341 of file almodulecore.h.

template<class T >
static boost::shared_ptr<T> AL::ALModuleCore::createModuleCore ( boost::shared_ptr< ALBroker pBroker,
const std::string &  name 
) [inline, static]

Create a module core link to a broker.

Parameters:
pBrokerpointer to the a broker
namemodule's name
Returns:
a pointer to the module
Exceptions:
ALError

Definition at line 367 of file almodulecore.h.

template<class T >
static boost::shared_ptr<T> AL::ALModuleCore::createUrbiModule ( boost::shared_ptr< ALBroker pBroker,
const std::string &  name 
) [inline, static]

Create a URBI module core link to a broker.

Parameters:
pBrokerpointer to the a broker
namemodule's name
Returns:
a pointer to the module

Definition at line 392 of file almodulecore.h.

virtual ALMethodInfo* AL::ALModuleCore::execute ( const std::string &  pMethod,
const AL::ALValue pParams,
AL::ALValue pResult 
) [virtual]

Execute a method with some arguments and store the result.

Parameters:
pMethodmethod to execute
pParamsset of arguments for the method
pResultresult of the method execution
Returns:
a pointer to the method executed, so it can be used to get information about the method
void AL::ALModuleCore::functionName ( const std::string &  pName,
const std::string &  pClass,
const std::string &  pFunctionDescription,
int  pMask = 0 
) [protected]

Define the name of a bound method.

Parameters:
pNamethe name of the method
pClassthe name of your class
pFunctionDescriptionthe description of the method
pMaskoptional Mask, default 0. see almethodinfo.h for more information
void AL::ALModuleCore::functionStop ( int  pTaskID)

Local stop. Use stop(id) for remote/local compatibility.

Parameters:
pTaskIDthe ID of the task you want to stop

Reimplemented in AL::ALModule.

Get the name of the registered broker.

Returns:
name of the broker

Get a reference to a temporary object used to construct method help.

Returns:
a reference to a temporary ALMethodInfo
ALMethodInfo* AL::ALModuleCore::getFunctionDesc ( const std::string &  pName)

deprecated

Deprecated:
ALMethodInfo* AL::ALModuleCore::getFunctionDesc ( const std::string &  pName,
std::vector< std::string >  pParamsType 
)

deprecated

Deprecated:
ALMethodInfo* AL::ALModuleCore::getFunctionDesc ( const std::string &  pName,
const AL::ALValue pParams 
)

deprecated

Deprecated:
ALMethodInfo* AL::ALModuleCore::getFunctionDescByNameMember ( const std::string &  pName,
const std::vector< std::string > &  paramType,
bool  softCompare = true 
)

deprecated

Deprecated:
AL::ALValue AL::ALModuleCore::getMethodHelp ( const std::string &  pMethodName)

Get a method's description string.

Parameters:
pMethodNamemethod's name.
Returns:
a structured method's description
ALMethodInfo AL::ALModuleCore::getMethodHelpObject ( const std::string &  pMethodName)

Get a method's description string.

Parameters:
pMethodNamemethod's name.
Returns:
a structured method's description
ALMethodInfo* AL::ALModuleCore::getMethodInfo ( const std::string &  pName)

Call by a proxy to check function's parameter.

Parameters:
pNamefunction Name
Returns:
a poitner to methodInfo
ALMethodInfo* AL::ALModuleCore::getMethodInfo ( const std::string &  pName,
std::vector< std::string >  pParamsType 
)

Call by a proxy to check function's parameter.

Parameters:
pNamefunction Name
pParamsTypeparameters type
Returns:
a poitner to methodInfo
ALMethodInfo* AL::ALModuleCore::getMethodInfo ( const std::string &  pName,
const AL::ALValue pParams 
)

Call by a proxy to check function's parameter.

Parameters:
pNamefunction Name
pParamsmethod parameters
Returns:
a poitner to methodInfo
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.

Parameters:
pNamemethod name
paramTypelist of parameters
softComparetrue mean ALValue can be anyType (use it for all type compare except local call)
Returns:
a poitner to methodInfo
std::vector<std::string> AL::ALModuleCore::getMethodList ( )

Get the module method list.

Returns:
vector of string module name

Get the module id given to it be the broker.

Returns:
an int module id

Get information about the module.

Returns:
a pointer to ALModuleInfo

Get the type of the module.

Returns:
type of the module
const std::string& AL::ALModuleCore::getName ( ) const

Get the name of the module given when constructing.

Returns:
The name of the module
boost::shared_ptr<ALBroker> AL::ALModuleCore::getParentBroker ( ) const

Get a pointer to the broker context.

Returns:
a shared 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")

Parameters:
pModuleNamemodule name
Returns:
a pointer to ALProxy
boost::shared_ptr<ALModuleCore> AL::ALModuleCore::getThis ( )

Getter to the class.

Returns:
a pointer to this
boost::shared_ptr<const ALModuleCore> AL::ALModuleCore::getThis ( ) const

Getter to class.

Returns:
a const pointer to this
std::string AL::ALModuleCore::getUsage ( const std::string &  methodName)

Get the usage of a method as a string.

Parameters:
methodNamethe name of the method
Returns:
the usage as a string
virtual std::string AL::ALModuleCore::httpGet ( ) [virtual]

Called by the broker webpage to detail the module.

Returns:
an optional extra description of the module

Reimplemented in AL::ALModule.

virtual void AL::ALModuleCore::init ( void  ) [inline, protected, virtual]

Call at every module creation.

User can overload it

Reimplemented in AL::ALModule.

Definition at line 424 of file almodulecore.h.

Register a module to a broker.

Automatically called when loading a module from autoload.ini

Check if someone want to exit the module.

Returns:
true if someone ask to exit the module, false othewise

Know if program or module termination is asked.

Returns:
true if module termination is asked, false otherwise

Get the module's description.

Returns:
a string describing the module
bool AL::ALModuleCore::ping ( void  )

Just a ping. Used to test connectivity to a module.

Returns:
always returns true
void AL::ALModuleCore::setModuleDescription ( const std::string &  pDesc)

Set the description of the module.

Parameters:
pDesca description of the module

Set the id of the module used to determine the shutdown order.

Parameters:
idthe id given to it by the broker

Set the type of the module.

Parameters:
pTypetype of the module
void AL::ALModuleCore::setReturn ( const std::string &  pName,
const std::string &  pDesc 
) [protected]

Sets the description of the return value.

Parameters:
pNamethe name of the return item (used in autogeneration)
pDescthe description of the return item
virtual std::string AL::ALModuleCore::version ( ) [virtual]

Get module's version.

Returns:
The version as a string

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines