11 #ifndef _LIBALCOMMON_ALCOMMON_ALMODULE_H_
12 #define _LIBALCOMMON_ALCOMMON_ALMODULE_H_
14 # include <qi/macro.hpp>
16 # include <boost/signal.hpp>
28 class ALProcessSignals
32 virtual ~ALProcessSignals() {}
34 typedef boost::signal<void ()> ProcessSignal;
35 typedef boost::signal<void ()>::slot_function_type ProcessSignalSlot;
36 typedef boost::signals::connect_position ProcessSignalPosition;
37 typedef boost::signals::connection ProcessSignalConnection;
42 inline ProcessSignalConnection atPreProcess(
43 ProcessSignalSlot subscriber,
44 ProcessSignalPosition pos = boost::signals::at_back)
46 return fPreProcess.connect(subscriber, pos);
50 inline ProcessSignalConnection atPostProcess(
51 ProcessSignalSlot subscriber,
52 ProcessSignalPosition pos = boost::signals::at_back)
54 return fPostProcess.connect(subscriber, pos);
57 inline void removeAllPreProcess(
void) {
58 fPreProcess.disconnect_all_slots();
61 inline void removeAllPostProcess(
void) {
62 fPostProcess.disconnect_all_slots();
66 inline void preProcess(
void) {
71 inline void postProcess(
void) {
76 ProcessSignal fPreProcess;
77 ProcessSignal fPostProcess;
106 friend class baseModule;
116 static boost::shared_ptr<T>
createModule(boost::shared_ptr<ALBroker> pBroker)
118 boost::shared_ptr<T> module = boost::shared_ptr<T>(
new T(pBroker));
119 module->initModule();
124 (boost::static_pointer_cast<
ALModule>(module))->init();
126 catch(
const ALError& e)
141 template <
class T,
typename P1>
142 static boost::shared_ptr<T>
createModule(boost::shared_ptr<ALBroker> pBroker, P1 p1)
144 boost::shared_ptr<T> module = boost::shared_ptr<T>(
new T(pBroker, p1));
145 module->initModule();
150 (boost::static_pointer_cast<
ALModule>(module))->init();
152 catch(
const ALError& e)
170 ALModule(boost::shared_ptr<ALBroker> pBroker,
const std::string& pName);
193 virtual void stop(
const int &
id);
209 bool wait(
const int &
id,
const int &timeout);
256 #endif // _LIBALCOMMON_ALCOMMON_ALMODULE_H_