libalcommon  2.0.6.8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | 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.
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.
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.
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.
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.

Public Attributes

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

Protected Member Functions

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

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


Member Typedef Documentation

Shared pointer to ALModuleCore.

Deprecated:
Use boost::shared_ptr<ALModuleCore> instead

Definition at line 66 of file almodulecore.h.

Weak pointer to ALModuleCore.

Deprecated:
Use boost::weak_ptr<ALModuleCore> instead

Definition at line 72 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 79 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) [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 348 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 400 of file almodulecore.h.

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

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 374 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 425 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

Reimplemented in AL::ALModule.

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

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

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 545 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
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]

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

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 
)

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]

Reimplemented in AL::ALModule.

Definition at line 552 of file almodulecore.h.


Member Data Documentation

qi::DynamicObjectBuilder AL::ALModuleCore::_builder [protected]

Definition at line 551 of file almodulecore.h.

qi::GenericObject AL::ALModuleCore::_go

Definition at line 554 of file almodulecore.h.

qi::MetaMethodBuilder AL::ALModuleCore::_mBuilder

Definition at line 556 of file almodulecore.h.

ALModuleCorePrivate* AL::ALModuleCore::_p

Definition at line 555 of file almodulecore.h.


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