11 #ifndef _LIBALCOMMON_ALCOMMON_ALMODULE_H_
12 #define _LIBALCOMMON_ALCOMMON_ALMODULE_H_
15 # include <qi/macro.hpp>
17 # include <boost/signal.hpp>
29 class ALProcessSignals
33 virtual ~ALProcessSignals() {}
35 typedef boost::signal<void ()> ProcessSignal;
36 typedef boost::signal<void ()>::slot_function_type ProcessSignalSlot;
37 typedef boost::signals::connect_position ProcessSignalPosition;
38 typedef boost::signals::connection ProcessSignalConnection;
43 inline ProcessSignalConnection atPreProcess(
44 ProcessSignalSlot subscriber,
45 ProcessSignalPosition pos = boost::signals::at_back)
47 return fPreProcess.connect(subscriber, pos);
51 inline ProcessSignalConnection atPostProcess(
52 ProcessSignalSlot subscriber,
53 ProcessSignalPosition pos = boost::signals::at_back)
55 return fPostProcess.connect(subscriber, pos);
58 inline void removeAllPreProcess(
void) {
59 fPreProcess.disconnect_all_slots();
62 inline void removeAllPostProcess(
void) {
63 fPostProcess.disconnect_all_slots();
67 inline void preProcess(
void) {
72 inline void postProcess(
void) {
77 ProcessSignal fPreProcess;
78 ProcessSignal fPostProcess;
117 static boost::shared_ptr<T>
createModule(boost::shared_ptr<ALBroker> pBroker)
119 boost::shared_ptr<T> module(
new T(pBroker));
120 module->initModule();
125 (boost::static_pointer_cast<
ALModule>(module))->init();
127 catch(
const ALError& e)
142 template <
class T,
typename P1>
143 static boost::shared_ptr<T>
createModule(boost::shared_ptr<ALBroker> pBroker, P1 p1)
145 boost::shared_ptr<T> module(
new T(pBroker, p1));
146 module->initModule();
151 (boost::static_pointer_cast<
ALModule>(module))->init();
153 catch(
const ALError& e)
171 ALModule(boost::shared_ptr<ALBroker> pBroker,
const std::string& pName);
194 virtual void stop(
const int &taskId);
210 bool wait(
const int &taskId,
const int &timeout);
258 #endif // _LIBALCOMMON_ALCOMMON_ALMODULE_H_
static boost::shared_ptr< T > createModule(boost::shared_ptr< ALBroker > pBroker, P1 p1)
Create a module and link it to a broker.
virtual ~ALModule()
Destructor.
bool isRunning(const int &taskId)
Determines if the method created with a 'post' is still running.
static boost::shared_ptr< T > createModule(boost::shared_ptr< ALBroker > pBroker)
Create a module and link it to a broker.
QI_API_DEPRECATED void functionStop(int pIDTask)
deprecated
bool isPCalled()
Check if the module is pcalled.
ALModuleCore is the superclass of user modules.
bool isStopRequired(const int &taskId=-1)
Check if the user call stop.
ALModule(boost::shared_ptr< ALBroker > pBroker, const std::string &pName)
Creates an ALModule.
virtual void exit()
Exit the module and unregister it.
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 wit...
virtual void stop(const int &taskId)
Stops a module's method using the ID given returned by a 'post' call. Module authors are encouraged t...
ALModule can be used as a base class for user modules to help serve and advertise their methods...
virtual void init(void)
It will be called at every module creation, user can overload it.
virtual std::string httpGet()
Called by the broker webpage to detail the module. This can be overriden to provide information speci...
int getMethodID(void)
Return unique ID if method call.