- Aldebaran documentation |
- C++ Libraries |
- index

libalcommon 2.8.7.4

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
almodule.h
Go to the documentation of this file.
1
10 #pragma once
11 #ifndef _LIBALCOMMON_ALCOMMON_ALMODULE_H_
12 #define _LIBALCOMMON_ALCOMMON_ALMODULE_H_
13
14 # include <alcommon/api.h>
15 # include <qi/macro.hpp>
16 # include <alcommon/almodulecore.h>
17 # include <boost/signals2.hpp>
18
20 namespace AL
21 {
22 class ALBroker;
23 class ALProxy;
24 class ALValue;
25
26
27 namespace detail
28 {
29 class ALCOMMON_API ALProcessSignals
30 {
31 public:
32 ALProcessSignals() {}
33 virtual ~ALProcessSignals() {}
34
35 typedef boost::signals2::signal<void ()> ProcessSignal;
36 typedef boost::signals2::signal<void ()>::slot_function_type ProcessSignalSlot;
37 typedef boost::signals2::connect_position ProcessSignalPosition;
38 typedef boost::signals2::connection ProcessSignalConnection;
39
43 inline ProcessSignalConnection atPreProcess(
44 ProcessSignalSlot subscriber,
45 ProcessSignalPosition pos = boost::signals2::at_back)
46 {
47 return fPreProcess.connect(subscriber, pos);
48 }
49
51 inline ProcessSignalConnection atPostProcess(
52 ProcessSignalSlot subscriber,
53 ProcessSignalPosition pos = boost::signals2::at_back)
54 {
55 return fPostProcess.connect(subscriber, pos);
56 }
57
58 inline void removeAllPreProcess(void) {
59 fPreProcess.disconnect_all_slots();
60 }
61
62 inline void removeAllPostProcess(void) {
63 fPostProcess.disconnect_all_slots();
64 }
65
67 inline void preProcess(void) {
68 fPreProcess();
69 }
70
72 inline void postProcess(void) {
73 fPostProcess();
74 }
75
76 protected:
77 ProcessSignal fPreProcess;
78 ProcessSignal fPostProcess;
79 };
80 }
81
82
105 class ALCOMMON_API ALModule: public ALModuleCore, public detail::ALProcessSignals
106 {
107 friend class baseModule;
108
109 public:
116 template <class T>
117 static boost::shared_ptr<T> createModule(boost::shared_ptr<ALBroker> pBroker)
118 {
119 boost::shared_ptr<T> module(new T(pBroker));
120 module->initModule();
121 try
122 {
123 // we call init on a ALModule::Ptr as init may be protected
124 // init is a virtual method that can be reimplemented
125 (boost::static_pointer_cast<ALModule>(module))->init();
126 }
127 catch(const ALError& e)
128 {
129 module->exit();
130 throw(e);
131 }
132 return module;
133 }
134
142 template <class T, typename P1>
143 static boost::shared_ptr<T> createModule(boost::shared_ptr<ALBroker> pBroker, P1 p1)
144 {
145 boost::shared_ptr<T> module(new T(pBroker, p1));
146 module->initModule();
147 try
148 {
149 // we call init on a ALModule::Ptr as init may be protected
150 // init is a virtual method that can be reimplemented
151 (boost::static_pointer_cast<ALModule>(module))->init();
152 }
153 catch(const ALError& e)
154 {
155 module->exit();
156 throw(e);
157 }
158 return module;
159 }
160
171 ALModule(boost::shared_ptr<ALBroker> pBroker, const std::string& pName);
172
174 virtual ~ALModule();
175
186 virtual void stop(const int &taskId);
187
193 bool isStopRequired(const int &taskId = -1);
194
202 bool wait(const int &taskId, const int &timeout);
203
210 qi::FutureSync<void> wait(const int &taskId);
211
217 bool isRunning(const int &taskId);
218
226 int getMethodID(void);
227
232 bool isPCalled();
233
234
238 virtual void exit();
239
249 QI_API_DEPRECATED void functionStop(int pIDTask);
250
254 virtual void init(void) {}
255 };
256 }
257
258 #endif // _LIBALCOMMON_ALCOMMON_ALMODULE_H_
AL::detail::ALProcessSignals::ALProcessSignals
ALProcessSignals()
Definition: almodule.h:32
AL::detail::ALProcessSignals::atPostProcess
ProcessSignalConnection atPostProcess(ProcessSignalSlot subscriber, ProcessSignalPosition pos=boost::signals2::at_back)
Connect to the postProcess signal.
Definition: almodule.h:51
AL::detail::ALProcessSignals::fPostProcess
ProcessSignal fPostProcess
Definition: almodule.h:78
almodulecore.h
api.h
AL::detail::ALProcessSignals::preProcess
void preProcess(void)
Trigger methods attached to preProcess.
Definition: almodule.h:67
AL::ALModule
ALModule can be used as a base class for user modules to help serve and advertise their methods...
Definition: almodule.h:105
AL::detail::ALProcessSignals::fPreProcess
ProcessSignal fPreProcess
Definition: almodule.h:77
AL::ALModuleCore
ALModuleCore is the superclass of user modules.
Definition: almodulecore.h:57
AL::detail::ALProcessSignals::~ALProcessSignals
virtual ~ALProcessSignals()
Definition: almodule.h:33
AL::detail::ALProcessSignals::ProcessSignalSlot
boost::signals2::signal< void()>::slot_function_type ProcessSignalSlot
Definition: almodule.h:36
AL::detail::ALProcessSignals::removeAllPostProcess
void removeAllPostProcess(void)
Definition: almodule.h:62
AL::detail::ALProcessSignals::ProcessSignalConnection
boost::signals2::connection ProcessSignalConnection
Definition: almodule.h:38
AL::ALModule::init
virtual void init(void)
It will be called at every module creation, user can overload it.
Definition: almodule.h:254
AL::detail::ALProcessSignals
Definition: almodule.h:29
AL::ALModule::createModule
static boost::shared_ptr< T > createModule(boost::shared_ptr< ALBroker > pBroker)
Create a module and link it to a broker.
Definition: almodule.h:117
AL::ALModule::createModule
static boost::shared_ptr< T > createModule(boost::shared_ptr< ALBroker > pBroker, P1 p1)
Create a module and link it to a broker.
Definition: almodule.h:143
AL::detail::ALProcessSignals::ProcessSignalPosition
boost::signals2::connect_position ProcessSignalPosition
Definition: almodule.h:37
AL::detail::ALProcessSignals::atPreProcess
ProcessSignalConnection atPreProcess(ProcessSignalSlot subscriber, ProcessSignalPosition pos=boost::signals2::at_back)
Definition: almodule.h:43
ALCOMMON_API
#define ALCOMMON_API
Definition: api.h:14
AL::detail::ALProcessSignals::ProcessSignal
boost::signals2::signal< void()> ProcessSignal
Definition: almodule.h:35
AL::detail::ALProcessSignals::postProcess
void postProcess(void)
Trigger methods attached to postProcess.
Definition: almodule.h:72
AL::detail::ALProcessSignals::removeAllPreProcess
void removeAllPreProcess(void)
Definition: almodule.h:58