libalcommon  1.14.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Static Public Member Functions | Friends
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>

List of all members.

Public Member Functions

 ALModule (boost::shared_ptr< ALBroker > pBroker, const std::string &pName)
 Creates an ALModule.
virtual ~ALModule ()
 Destructor.
virtual std::string httpGet ()
 Called by the broker webpage to detail the module. This can be overriden to provide information specific to your module. The default is an empty page.
virtual void stop (const int &id)
 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.
bool isStopRequired (const int &id=-1)
 Check if the user call stop.
bool wait (const int &id, const int &timeout)
 Waits until the end of a long running method using the ID that was returned from a method started with 'post'.
bool isRunning (const int &id)
 Determines if the method created with a 'post' is still running.
int getMethodID (void)
 Return unique ID if method call.
bool isPCalled ()
 Check if the module is pcalled.
virtual void exit ()
 Exit the module and unregister it.
QI_API_DEPRECATED void functionStop (int pIDTask)
 deprecated
virtual void init (void)
 It will be called at every module creation, user can overload it.

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

Friends

class baseModule

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 104 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()

Member Function Documentation

template<class T >
static boost::shared_ptr<T> AL::ALModule::createModule ( boost::shared_ptr< ALBroker pBroker) [inline, static]

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

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

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

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:

Reimplemented from AL::ALModuleCore.

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 std::string AL::ALModule::httpGet ( ) [virtual]

Called by the broker webpage to detail the module. This can be overriden to provide information specific to your module. The default is an empty page.

Returns:
"<html><body></body></html>"

Reimplemented from AL::ALModuleCore.

Check if the module is pcalled.

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

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

Parameters:
idThe 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 &  id = -1)

Check if the user call stop.

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

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