libalcommon  2.8.7.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
AL::ALModuleCore Class Reference

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. More...
 
typedef boost::weak_ptr
< ALModuleCore
WeakPtr
 Weak pointer to ALModuleCore. More...
 

Public Member Functions

 ALModuleCore (boost::shared_ptr< ALBroker > pBroker, const std::string &pName)
 Constructor. More...
 
virtual ~ALModuleCore ()
 Destructor. More...
 
ALMethodInfogetCurrentMethodDescription ()
 Get a reference to a temporary object used to construct method help. More...
 
boost::shared_ptr< ALModuleCoregetThis ()
 Getter to the class. More...
 
boost::shared_ptr< const
ALModuleCore
getThis () const
 Getter to class. More...
 
bool isClosing ()
 Check if someone want to exit the module. More...
 
void initModule (void)
 Register a module to a broker. More...
 
boost::shared_ptr< AL::ALProxygetProxy (const std::string &pModuleName)
 Get access to a module. More...
 
std::string getBrokerName ()
 Get the name of the registered broker. More...
 
ModuleType getModuleType (void)
 Get the type of the module. More...
 
void setModuleType (ModuleType pType)
 Set the type of the module. More...
 
virtual ALMethodInfoexecute (const std::string &pMethod, const AL::ALValue &pParams, AL::ALValue &pResult)
 Execute a method with some arguments and store the result. More...
 
std::vector< std::string > getMethodList ()
 Get the module method list. More...
 
AL::ALValue getMethodHelp (const std::string &pMethodName)
 Get a method's description string. More...
 
ALMethodInfo getMethodHelpObject (const std::string &pMethodName)
 Get a method's description string. More...
 
AL::ALValue moduleHelp ()
 Get the module's description. More...
 
bool ping (void)
 Just a ping. Used to test connectivity to a module. More...
 
virtual std::string version ()
 Get module's version. More...
 
virtual void exit ()
 Exit the module and unregister it. More...
 
const std::string & getName () const
 Get the name of the module given when constructing. More...
 
boost::shared_ptr< ALModuleInfogetModuleInfo ()
 Get information about the module. More...
 
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. More...
 
ALMethodInfogetMethodInfo (const std::string &pName)
 Call by a proxy to check function's parameter. More...
 
ALMethodInfogetMethodInfo (const std::string &pName, std::vector< std::string > pParamsType)
 Call by a proxy to check function's parameter. More...
 
ALMethodInfogetMethodInfo (const std::string &pName, const AL::ALValue &pParams)
 Call by a proxy to check function's parameter. More...
 
ALMethodInfogetFunctionDesc (const std::string &pName)
 deprecated More...
 
ALMethodInfogetFunctionDesc (const std::string &pName, std::vector< std::string > pParamsType)
 deprecated More...
 
ALMethodInfogetFunctionDesc (const std::string &pName, const AL::ALValue &pParams)
 deprecated More...
 
ALMethodInfogetFunctionDescByNameMember (const std::string &pName, const std::vector< std::string > &paramType, bool softCompare=true)
 deprecated More...
 
boost::shared_ptr< ALBrokergetParentBroker () const
 Get a pointer to the broker context. More...
 
void functionStop (int pTaskID)
 Local stop. Use stop(id) for remote/local compatibility. More...
 
void setModuleDescription (const std::string &pDesc)
 Set the description of the module. More...
 
std::string getUsage (const std::string &methodName)
 Get the usage of a method as a string. More...
 
bool isModuleStopped ()
 Know if program or module termination is asked. More...
 
void setModuleID (int id)
 Set the id of the module used to determine the shutdown order. More...
 
int getModuleID ()
 Get the module id given to it be the broker. More...
 
void bindMethod (boost::shared_ptr< ALFunctorBase > pFunctor)
 Bind a method. More...
 
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. More...
 
void bindMethodOverload (boost::shared_ptr< ALFunctorBase > pFunctor)
 Use to define a bound method. More...
 
void functionName (const std::string &pName, const std::string &pClass, const std::string &pFunctionDescription, int pMask=0)
 Define the name of a bound method. More...
 
void addParam (const std::string &pName, const std::string &pDesc)
 Add a documented parameter to a method. More...
 
void addModuleExample (const std::string &pLanguage, const std::string &pExample)
 Add a module example. More...
 
void addMethodExample (const std::string &pLanguage, const std::string &pExample)
 Add a method example. More...
 
void setReturn (const std::string &pName, const std::string &pDesc)
 Sets the description of the return value. More...
 
virtual qi::Future
< qi::AnyReference > 
metaCall (qi::AnyObject context, unsigned int method, const qi::GenericFunctionParameters &in, qi::MetaCallType callType, qi::Signature returnSignature)
 
qi::AnyObject asObject ()
 
qi::DynamicObjectBuilder & getBuilder ()
 
int pCall (const qi::AnyArguments &args)
 

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. More...
 
template<class T >
static boost::shared_ptr< T > createModuleCoreNoRegister (boost::shared_ptr< ALBroker > pBroker, const std::string &name)
 Create a module core, do not register on the broker. More...
 
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. More...
 
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. More...
 

Public Attributes

qi::GenericObject _go
 
ALModuleCorePrivate * _p
 
qi::MetaMethodBuilder _mBuilder
 

Protected Member Functions

virtual void init (void)
 Call at every module creation. More...
 

Protected Attributes

qi::DynamicObjectBuilder _builder
 

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 57 of file almodulecore.h.

Member Typedef Documentation

Shared pointer to ALModuleCore.

Deprecated:
Use boost::shared_ptr<ALModuleCore> instead

Definition at line 65 of file almodulecore.h.

Weak pointer to ALModuleCore.

Deprecated:
Use boost::weak_ptr<ALModuleCore> instead

Definition at line 71 of file almodulecore.h.

Member Enumeration Documentation

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

Deprecated:
not used anywhere
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 78 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
virtual AL::ALModuleCore::~ALModuleCore ( )
virtual

Destructor.

Member Function Documentation

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

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 
)

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 
)

Add a documented parameter to a method.

Parameters
pNamethe name of the parameter
pDescthe description of the parmeter
qi::AnyObject AL::ALModuleCore::asObject ( )
void AL::ALModuleCore::bindMethod ( boost::shared_ptr< ALFunctorBase pFunctor)

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 
)

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)

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)
inlinestatic

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 
)
inlinestatic

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 393 of file almodulecore.h.

template<class T >
static boost::shared_ptr<T> AL::ALModuleCore::createModuleCoreNoRegister ( boost::shared_ptr< ALBroker pBroker,
const std::string &  name 
)
inlinestatic

Create a module core, do not register on the broker.

Parameters
pBrokerto pointer the a broker
[in]nameName of the module core.
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 
)
inlinestatic

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 418 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
virtual void AL::ALModuleCore::exit ( )
virtual

Exit the module and unregister it.

Reimplemented in AL::ALModule.

void AL::ALModuleCore::functionName ( const std::string &  pName,
const std::string &  pClass,
const std::string &  pFunctionDescription,
int  pMask = 0 
)

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
std::string AL::ALModuleCore::getBrokerName ( )

Get the name of the registered broker.

Returns
name of the broker
qi::DynamicObjectBuilder& AL::ALModuleCore::getBuilder ( )
inline

Used only for naoqi1/naoqi2 compatibility layers. Do not use unless you know what you are doing

Definition at line 524 of file almodulecore.h.

ALMethodInfo& AL::ALModuleCore::getCurrentMethodDescription ( )

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 following the format : [ std::string methodName, std::string methodDescription, [parameter, ...], std::string returnName, std::string returnDescription ] Where parameter is : [ std::string parameterName, std::string parameterDescription ]
Warning
Will return only one version of a method, therefore the method doesn't handle overloading.
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
int AL::ALModuleCore::getModuleID ( )

Get the module id given to it be the broker.

Returns
an int module id
boost::shared_ptr<ALModuleInfo> AL::ALModuleCore::getModuleInfo ( )

Get information about the module.

Returns
a pointer to ALModuleInfo
ModuleType AL::ALModuleCore::getModuleType ( void  )

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 void AL::ALModuleCore::init ( void  )
inlineprotectedvirtual

Call at every module creation.

User can overload it

Reimplemented in AL::ALModule.

Definition at line 538 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.

Returns
true if someone ask to exit the module, false othewise
bool AL::ALModuleCore::isModuleStopped ( )

Know if program or module termination is asked.

Returns
true if module termination is asked, false otherwise
virtual qi::Future<qi::AnyReference> AL::ALModuleCore::metaCall ( qi::AnyObject  context,
unsigned int  method,
const qi::GenericFunctionParameters &  in,
qi::MetaCallType  callType,
qi::Signature  returnSignature 
)
virtual
AL::ALValue AL::ALModuleCore::moduleHelp ( )

Get the module's description.

Returns
a string describing the module
int AL::ALModuleCore::pCall ( const qi::AnyArguments &  args)

Used for simulating old naoqi1 post behavior that return an id

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
void AL::ALModuleCore::setModuleID ( int  id)

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

Parameters
idthe id given to it by the broker
void AL::ALModuleCore::setModuleType ( ModuleType  pType)

Set the type of the module.

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

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

Friends And Related Function Documentation

friend class baseModule
friend

Definition at line 545 of file almodulecore.h.

Member Data Documentation

qi::DynamicObjectBuilder AL::ALModuleCore::_builder
protected

Definition at line 544 of file almodulecore.h.

qi::GenericObject AL::ALModuleCore::_go

Definition at line 547 of file almodulecore.h.

qi::MetaMethodBuilder AL::ALModuleCore::_mBuilder

Definition at line 549 of file almodulecore.h.

ALModuleCorePrivate* AL::ALModuleCore::_p

Definition at line 548 of file almodulecore.h.


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