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

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. More...
 
virtual ~ALModule ()
 Destructor. More...
 
virtual void stop (const int &taskId)
 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. More...
 
bool isStopRequired (const int &taskId=-1)
 Check if the user call stop. More...
 
bool wait (const int &taskId, const int &timeout)
 Waits until the end of a long running method using the ID that was returned from a method started with 'post'. More...
 
qi::FutureSync< void > wait (const int &taskId)
 Waits until the end of a long running method using the ID that was returned from a method started with 'post'. More...
 
bool isRunning (const int &taskId)
 Determines if the method created with a 'post' is still running. More...
 
int getMethodID (void)
 Return unique ID if method call. More...
 
bool isPCalled ()
 Check if the module is pcalled. More...
 
virtual void exit ()
 Exit the module and unregister it. More...
 
QI_API_DEPRECATED void functionStop (int pIDTask)
 deprecated More...
 
virtual void init (void)
 It will be called at every module creation, user can overload it. More...
 
- Public Member Functions inherited from AL::ALModuleCore
 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...
 
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)
 
- Public Member Functions inherited from AL::detail::ALProcessSignals
 ALProcessSignals ()
 
virtual ~ALProcessSignals ()
 
ProcessSignalConnection atPreProcess (ProcessSignalSlot subscriber, ProcessSignalPosition pos=boost::signals2::at_back)
 
ProcessSignalConnection atPostProcess (ProcessSignalSlot subscriber, ProcessSignalPosition pos=boost::signals2::at_back)
 Connect to the postProcess signal. More...
 
void removeAllPreProcess (void)
 
void removeAllPostProcess (void)
 
void preProcess (void)
 Trigger methods attached to preProcess. More...
 
void postProcess (void)
 Trigger methods attached to postProcess. More...
 

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. More...
 
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. More...
 
- 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. 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...
 

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. More...
 
typedef boost::weak_ptr
< ALModuleCore
WeakPtr
 Weak pointer to ALModuleCore. More...
 
- Public Types inherited from AL::detail::ALProcessSignals
typedef
boost::signals2::signal< void()> 
ProcessSignal
 
typedef
boost::signals2::signal< void()>
::slot_function_type 
ProcessSignalSlot
 
typedef
boost::signals2::connect_position 
ProcessSignalPosition
 
typedef boost::signals2::connection ProcessSignalConnection
 
- Public Attributes inherited from AL::ALModuleCore
qi::GenericObject _go
 
ALModuleCorePrivate * _p
 
qi::MetaMethodBuilder _mBuilder
 
- Protected Attributes inherited from AL::ALModuleCore
qi::DynamicObjectBuilder _builder
 
- Protected Attributes inherited from AL::detail::ALProcessSignals
ProcessSignal fPreProcess
 
ProcessSignal fPostProcess
 

Detailed Description

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 105 of file almodule.h.

Constructor & Destructor Documentation

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.

Parameters
pBrokerPointer to a broker
pNameThe name for the new module. This is used as the prefix for all method calls e.g. MyModule.myMethod()
virtual AL::ALModule::~ALModule ( )
virtual

Destructor.

Member Function Documentation

template<class T >
static boost::shared_ptr<T> AL::ALModule::createModule ( boost::shared_ptr< ALBroker pBroker)
inlinestatic

Create a module and link it to a broker.

Parameters
pBrokerPointer to the broker
Returns
A pointer to the module
Exceptions
ALError

Definition at line 117 of file almodule.h.

template<class T , typename P1 >
static boost::shared_ptr<T> AL::ALModule::createModule ( boost::shared_ptr< ALBroker pBroker,
P1  p1 
)
inlinestatic

Create a module and link it to a broker.

Parameters
pBrokerPointer to the broker
p1first parameter after pBroker for the module's constructor
Returns
A pointer to the module
Exceptions
ALError

Definition at line 143 of file almodule.h.

virtual void AL::ALModule::exit ( )
virtual

Exit the module and unregister it.

Reimplemented from AL::ALModuleCore.

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

Parameters
pIDTasktask's ID
Deprecated:
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

Returns
Method's ID
virtual void AL::ALModule::init ( void  )
inlinevirtual

It will be called at every module creation, user can overload it.

Reimplemented from AL::ALModuleCore.

Definition at line 254 of file almodule.h.

bool AL::ALModule::isPCalled ( )

Check if the module is pcalled.

Returns
true if pcalled, false otherwise
bool AL::ALModule::isRunning ( const int &  taskId)

Determines if the method created with a 'post' is still running.

Parameters
taskIdThe id of the method that was returned by 'post'
Returns
true if the method is still running, false otherwise
bool AL::ALModule::isStopRequired ( const int &  taskId = -1)

Check if the user call stop.

Parameters
taskIdThe id of the method that was returned by 'post'
Returns
true if used call stop, false otherwise
virtual void AL::ALModule::stop ( const int &  taskId)
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.

Warning
Module has to overload stop method or an exception will be raised.
Parameters
taskIdThe id of the method that was returned by 'post'
bool AL::ALModule::wait ( const int &  taskId,
const int &  timeout 
)

Waits until the end of a long running method using the ID that was returned from a method started with 'post'.

Parameters
taskIdThe id of the method that was returned by 'post'
timeoutThe wait timeout period in ms. If 0 wait indefinately.
Returns
true if the timeout period expired, false otherwise
qi::FutureSync<void> AL::ALModule::wait ( const int &  taskId)

Waits until the end of a long running method using the ID that was returned from a method started with 'post'.

Parameters
taskIdThe id of the method that was returned by 'post'
Returns
a cancelable future

Friends And Related Function Documentation

friend class baseModule
friend

Definition at line 107 of file almodule.h.


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