make modules know their name
Stefan Schuermans

Stefan Schuermans commited on 2011-12-22 19:41:00
Showing 30 changed files, with 108 additions and 55 deletions.

... ...
@@ -25,12 +25,12 @@ namespace Blinker {
25 25
 
26 26
 /**
27 27
  * @brief constructor
28
+ * @param[in] name module name
28 29
  * @param[in] mgrs managers
29 30
  * @param[in] dirBase base directory
30 31
  */
31
-Canvas::Canvas(Mgrs &mgrs,
32
-               const Directory &dirBase):
33
-  Module(mgrs, dirBase),
32
+Canvas::Canvas(const std::string &name, Mgrs &mgrs, const Directory &dirBase):
33
+  Module(name, mgrs, dirBase),
34 34
   m_fileFormat(dirBase.getFile("format")),
35 35
   m_fileOutStream(dirBase.getFile("outstream"), mgrs.m_streamMgr),
36 36
   m_pCanvas(NULL),
... ...
@@ -35,10 +35,11 @@ protected:
35 35
 public:
36 36
   /**
37 37
    * @brief constructor
38
+   * @param[in] name module name
38 39
    * @param[in] mgrs managers
39 40
    * @param[in] dirBase base directory
40 41
    */
41
-  Canvas(Mgrs &mgrs, const Directory &dirBase);
42
+  Canvas(const std::string &name, Mgrs &mgrs, const Directory &dirBase);
42 43
 
43 44
   /// virtual destructor
44 45
   virtual ~Canvas();
... ...
@@ -32,12 +32,13 @@ namespace Blinker {
32 32
 
33 33
 /**
34 34
  * @brief constructor
35
+ * @param[in] name module name
35 36
  * @param[in] mgrs managers
36 37
  * @param[in] dirBase base directory
37 38
  */
38
-FlexiPix::FlexiPix(Mgrs &mgrs,
39
+FlexiPix::FlexiPix(const std::string &name, Mgrs &mgrs,
39 40
                  const Directory &dirBase):
40
-  Module(mgrs, dirBase),
41
+  Module(name, mgrs, dirBase),
41 42
   m_fileInStream(dirBase.getFile("instream"), mgrs.m_streamMgr),
42 43
   m_fileConfig(dirBase.getFile("flexipix.flp")),
43 44
   m_pDisplay(NULL)
... ...
@@ -182,7 +183,7 @@ void FlexiPix::sendFrame()
182 183
 #ifdef BLINKER_CFG_FLEXIPIX
183 184
   if (m_pDisplay) {
184 185
     flp_display_send(m_pDisplay);
185
-    m_mgrs.m_callMgr.requestTimeCall(this, Time::now() + Time(1)); // for refresh
186
+    m_mgrs.m_callMgr.requestTimeCall(this, Time::now() + Time(1)); // refresh
186 187
   }
187 188
 #endif // #ifdef BLINKER_CFG_FLEXIPIX
188 189
 }
... ...
@@ -28,10 +28,11 @@ class FlexiPix: public Module, public StreamRecv, public TimeCallee
28 28
 public:
29 29
   /**
30 30
    * @brief constructor
31
+   * @param[in] name module name
31 32
    * @param[in] mgrs managers
32 33
    * @param[in] dirBase base directory
33 34
    */
34
-  FlexiPix(Mgrs &mgrs, const Directory &dirBase);
35
+  FlexiPix(const std::string &name, Mgrs &mgrs, const Directory &dirBase);
35 36
 
36 37
   /// virtual destructor
37 38
   virtual ~FlexiPix();
... ...
@@ -3,6 +3,8 @@
3 3
    Copyleft GNU public license - http://www.gnu.org/copyleft/gpl.html
4 4
    a blinkenarea.org project */
5 5
 
6
+#include <string>
7
+
6 8
 #include "Mgrs.h"
7 9
 #include "Directory.h"
8 10
 #include "Module.h"
... ...
@@ -11,10 +13,13 @@ namespace Blinker {
11 13
 
12 14
 /**
13 15
  * @brief constructor
16
+ * @param[in] name module name
17
+ * @param[in] name module name
14 18
  * @param[in] mgrs managers
15 19
  * @param[in] dirBase base directory
16 20
  */
17
-Module::Module(Mgrs &mgrs, const Directory &dirBase):
21
+Module::Module(const std::string &name, Mgrs &mgrs, const Directory &dirBase):
22
+  m_name(name),
18 23
   m_mgrs(mgrs),
19 24
   m_dirBase(dirBase)
20 25
 {
... ...
@@ -6,6 +6,8 @@
6 6
 #ifndef BLINKER_MODULE_H
7 7
 #define BLINKER_MODULE_H
8 8
 
9
+#include <string>
10
+
9 11
 #include "Mgrs.h"
10 12
 #include "Directory.h"
11 13
 
... ...
@@ -17,10 +19,12 @@ class Module
17 19
 public:
18 20
   /**
19 21
    * @brief constructor
22
+   * @param[in] name module name
23
+   * @param[in] name module name
20 24
    * @param[in] mgrs managers
21 25
    * @param[in] dirBase base directory
22 26
    */
23
-  Module(Mgrs &mgrs, const Directory &dirBase);
27
+  Module(const std::string &name, Mgrs &mgrs, const Directory &dirBase);
24 28
 
25 29
   /// virtual destructor
26 30
   virtual ~Module();
... ...
@@ -37,6 +41,7 @@ public:
37 41
   virtual void updateConfig() = 0;
38 42
 
39 43
 protected:
44
+  std::string m_name;    ///< module name
40 45
   Mgrs        &m_mgrs;   ///< managers
41 46
   Directory   m_dirBase; ///< base directory
42 47
 }; // class Module
... ...
@@ -7,6 +7,7 @@
7 7
 #define BLINKER_MODULEMGR_H
8 8
 
9 9
 #include <list>
10
+#include <string>
10 11
 
11 12
 #include "Directory.h"
12 13
 #include "ListTracker.h"
... ...
@@ -30,10 +31,12 @@ protected:
30 31
 public:
31 32
   /**
32 33
    * @brief constructor
34
+   * @param[in] name module manager name / module class name
35
+   * @param[in] name module name
33 36
    * @param[in] mgrs managers
34 37
    * @param[in] dirBase base directory
35 38
    */
36
-  ModuleMgr(Mgrs &mgrs, const Directory &dirBase);
39
+  ModuleMgr(const std::string &name, Mgrs &mgrs, const Directory &dirBase);
37 40
 
38 41
   /// destructor
39 42
   ~ModuleMgr();
... ...
@@ -54,6 +57,7 @@ protected:
54 57
   void updateConfig();
55 58
 
56 59
 protected:
60
+  std::string       m_name;              ///< module manager name
57 61
   Mgrs              &m_mgrs;             ///< managers
58 62
   Directory         m_dirBase;           ///< base directory
59 63
   ModuleListTracker m_moduleListTracker; ///< module list tracker
... ...
@@ -29,7 +29,7 @@ ModuleMgr<MODULE>::Cntr::Cntr(ModuleMgr &mgr, const std::string &name,
29 29
                               const Directory &dirBase):
30 30
   m_mgr(mgr),
31 31
   m_name(name),
32
-  m_mod(mgr.m_mgrs, dirBase)
32
+  m_mod(mgr.m_name + "/" + name, mgr.m_mgrs, dirBase)
33 33
 {
34 34
 }
35 35
 
... ...
@@ -7,6 +7,7 @@
7 7
 #define BLINKER_MODULEMGR_IMPL_H
8 8
 
9 9
 #include <list>
10
+#include <string>
10 11
 
11 12
 #include "Directory.h"
12 13
 #include "ListTracker.h"
... ...
@@ -22,11 +23,15 @@ namespace Blinker {
22 23
 
23 24
 /**
24 25
  * @brief constructor
26
+ * @param[in] name module manager name / module class name
27
+ * @param[in] name module name
25 28
  * @param[in] mgrs managers
26 29
  * @param[in] dirBase base directory
27 30
  */
28 31
 template<typename MODULE>
29
-ModuleMgr<MODULE>::ModuleMgr(Mgrs &mgrs, const Directory &dirBase):
32
+ModuleMgr<MODULE>::ModuleMgr(const std::string &name, Mgrs &mgrs,
33
+                             const Directory &dirBase):
34
+  m_name(name),
30 35
   m_mgrs(mgrs),
31 36
   m_dirBase(dirBase),
32 37
   m_moduleListTracker(*this, dirBase)
... ...
@@ -20,11 +20,13 @@ namespace Blinker {
20 20
 
21 21
 /**
22 22
  * @brief constructor
23
+ * @param[in] name module name
23 24
  * @param[in] mgrs managers
24 25
  * @param[in] dirBase base directory
25 26
  */
26
-OpPrinter::OpPrinter(Mgrs &mgrs, const Directory &dirBase):
27
-  Module(mgrs, dirBase)
27
+OpPrinter::OpPrinter(const std::string &name, Mgrs &mgrs,
28
+                     const Directory &dirBase):
29
+  Module(name, mgrs, dirBase)
28 30
 {
29 31
   m_mgrs.m_opMgr.open("TODO", this);
30 32
 }
... ...
@@ -24,10 +24,11 @@ class OpPrinter: public Module, public OpReqIf
24 24
 public:
25 25
   /**
26 26
    * @brief constructor
27
+   * @param[in] name module name
27 28
    * @param[in] mgrs managers
28 29
    * @param[in] dirBase base directory
29 30
    */
30
-  OpPrinter(Mgrs &mgrs, const Directory &dirBase);
31
+  OpPrinter(const std::string &name, Mgrs &mgrs, const Directory &dirBase);
31 32
 
32 33
   /// virtual destructor
33 34
   virtual ~OpPrinter();
... ...
@@ -27,12 +27,13 @@ namespace Blinker {
27 27
 
28 28
 /**
29 29
  * @brief constructor
30
+ * @param[in] name module name
30 31
  * @param[in] mgrs managers
31 32
  * @param[in] dirBase base directory
32 33
  */
33
-Output::Output(Mgrs &mgrs,
34
+Output::Output(const std::string &name, Mgrs &mgrs,
34 35
                const Directory &dirBase):
35
-  Module(mgrs, dirBase),
36
+  Module(name, mgrs, dirBase),
36 37
   m_fileInStream(dirBase.getFile("instream"), mgrs.m_streamMgr),
37 38
   m_fileProtocol(dirBase.getFile("protocol")),
38 39
   m_fileDevice(dirBase.getFile("device")),
... ...
@@ -32,10 +32,11 @@ class Output: public Module, public StreamRecv, public TimeCallee
32 32
 public:
33 33
   /**
34 34
    * @brief constructor
35
+   * @param[in] name module name
35 36
    * @param[in] mgrs managers
36 37
    * @param[in] dirBase base directory
37 38
    */
38
-  Output(Mgrs &mgrs, const Directory &dirBase);
39
+  Output(const std::string &name, Mgrs &mgrs, const Directory &dirBase);
39 40
 
40 41
   /// virtual destructor
41 42
   virtual ~Output();
... ...
@@ -49,10 +49,11 @@ protected:
49 49
 public:
50 50
   /**
51 51
    * @brief constructor
52
+   * @param[in] name module name
52 53
    * @param[in] mgrs managers
53 54
    * @param[in] dirBase base directory
54 55
    */
55
-  Phone(Mgrs &mgrs, const Directory &dirBase);
56
+  Phone(const std::string &name, Mgrs &mgrs, const Directory &dirBase);
56 57
 
57 58
   /// virtual destructor
58 59
   virtual ~Phone();
... ...
@@ -31,12 +31,14 @@ namespace Blinker {
31 31
 
32 32
 /**
33 33
  * @brief constructor
34
+ * @param[in] name module name
34 35
  * @param[in] mgrs managers
35 36
  * @param[in] dirBase base directory
36 37
  */
37 38
 template<typename ADDR, typename SOCK>
38
-Phone<ADDR, SOCK>::Phone(Mgrs &mgrs, const Directory &dirBase):
39
-  Module(mgrs, dirBase),
39
+Phone<ADDR, SOCK>::Phone(const std::string &name, Mgrs &mgrs,
40
+                         const Directory &dirBase):
41
+  Module(name, mgrs, dirBase),
40 42
   m_fileBind(dirBase.getFile("bind")),
41 43
   m_fileServer(dirBase.getFile("server")),
42 44
   m_extListTracker(*this, dirBase.getSubdir("extensions")),
... ...
@@ -27,12 +27,13 @@ namespace Blinker {
27 27
 
28 28
 /**
29 29
  * @brief constructor
30
+ * @param[in] name module name
30 31
  * @param[in] mgrs managers
31 32
  * @param[in] dirBase base directory
32 33
  */
33
-Player::Player(Mgrs &mgrs,
34
+Player::Player(const std::string &name, Mgrs &mgrs,
34 35
                const Directory &dirBase):
35
-  Module(mgrs, dirBase),
36
+  Module(name, mgrs, dirBase),
36 37
   m_fileOutStream(dirBase.getFile("outstream"), mgrs.m_streamMgr),
37 38
   m_fileHaltStream(dirBase.getFile("haltstream"), mgrs.m_streamMgr),
38 39
   m_playlistTracker(*this, dirBase.getSubdir("playlist")),
... ...
@@ -40,10 +40,11 @@ protected:
40 40
 public:
41 41
   /**
42 42
    * @brief constructor
43
+   * @param[in] name module name
43 44
    * @param[in] mgrs managers
44 45
    * @param[in] dirBase base directory
45 46
    */
46
-  Player(Mgrs &mgrs, const Directory &dirBase);
47
+  Player(const std::string &name, Mgrs &mgrs, const Directory &dirBase);
47 48
 
48 49
   /// virtual destructor
49 50
   virtual ~Player();
... ...
@@ -22,11 +22,13 @@ namespace Blinker {
22 22
 
23 23
 /**
24 24
  * @brief constructor
25
+ * @param[in] name module name
25 26
  * @param[in] mgrs managers
26 27
  * @param[in] dirBase base directory
27 28
  */
28
-Printer::Printer(Mgrs &mgrs, const Directory &dirBase):
29
-  Module(mgrs, dirBase),
29
+Printer::Printer(const std::string &name, Mgrs &mgrs,
30
+                 const Directory &dirBase):
31
+  Module(name, mgrs, dirBase),
30 32
   m_fileInStream(dirBase.getFile("instream"), mgrs.m_streamMgr)
31 33
 {
32 34
   // set up
... ...
@@ -25,10 +25,11 @@ class Printer: public Module, public StreamRecv
25 25
 public:
26 26
   /**
27 27
    * @brief constructor
28
+   * @param[in] name module name
28 29
    * @param[in] mgrs managers
29 30
    * @param[in] dirBase base directory
30 31
    */
31
-  Printer(Mgrs &mgrs, const Directory &dirBase);
32
+  Printer(const std::string &name, Mgrs &mgrs, const Directory &dirBase);
32 33
 
33 34
   /// virtual destructor
34 35
   virtual ~Printer();
... ...
@@ -23,11 +23,13 @@ namespace Blinker {
23 23
 
24 24
 /**
25 25
  * @brief constructor
26
+ * @param[in] name module name
26 27
  * @param[in] mgrs managers
27 28
  * @param[in] dirBase base directory
28 29
  */
29
-Priority::Priority(Mgrs &mgrs, const Directory &dirBase):
30
-  Module(mgrs, dirBase),
30
+Priority::Priority(const std::string &name, Mgrs &mgrs,
31
+                   const Directory &dirBase):
32
+  Module(name, mgrs, dirBase),
31 33
   m_fileOutStream(dirBase.getFile("outstream"), mgrs.m_streamMgr),
32 34
   m_inListTracker(*this, dirBase.getSubdir("inputs")),
33 35
   m_itCurIn(m_inListTracker.m_list.rend())
... ...
@@ -36,10 +36,11 @@ protected:
36 36
 public:
37 37
   /**
38 38
    * @brief constructor
39
+   * @param[in] name module name
39 40
    * @param[in] mgrs managers
40 41
    * @param[in] dirBase base directory
41 42
    */
42
-  Priority(Mgrs &mgrs, const Directory &dirBase);
43
+  Priority(const std::string &name, Mgrs &mgrs, const Directory &dirBase);
43 44
 
44 45
   /// virtual destructor
45 46
   virtual ~Priority();
... ...
@@ -36,10 +36,11 @@ protected:
36 36
 public:
37 37
   /**
38 38
    * @brief constructor
39
+   * @param[in] name module name
39 40
    * @param[in] mgrs managers
40 41
    * @param[in] dirBase base directory
41 42
    */
42
-  Receiver(Mgrs &mgrs, const Directory &dirBase);
43
+  Receiver(const std::string &name, Mgrs &mgrs, const Directory &dirBase);
43 44
 
44 45
   /// virtual destructor
45 46
   virtual ~Receiver();
... ...
@@ -28,12 +28,14 @@ namespace Blinker {
28 28
 
29 29
 /**
30 30
  * @brief constructor
31
+ * @param[in] name module name
31 32
  * @param[in] mgrs managers
32 33
  * @param[in] dirBase base directory
33 34
  */
34 35
 template<typename ADDR, typename SOCK>
35
-Receiver<ADDR, SOCK>::Receiver(Mgrs &mgrs, const Directory &dirBase):
36
-  Module(mgrs, dirBase),
36
+Receiver<ADDR, SOCK>::Receiver(const std::string &name, Mgrs &mgrs,
37
+                               const Directory &dirBase):
38
+  Module(name, mgrs, dirBase),
37 39
   m_fileOutStream(dirBase.getFile("outstream"), mgrs.m_streamMgr),
38 40
   m_fileBind(dirBase.getFile("bind")),
39 41
   m_fileSrc(dirBase.getFile("source")),
... ...
@@ -24,12 +24,13 @@ namespace Blinker {
24 24
 
25 25
 /**
26 26
  * @brief constructor
27
+ * @param[in] name module name
27 28
  * @param[in] mgrs managers
28 29
  * @param[in] dirBase base directory
29 30
  */
30
-Resizer::Resizer(Mgrs &mgrs,
31
+Resizer::Resizer(const std::string &name, Mgrs &mgrs,
31 32
                  const Directory &dirBase):
32
-  Module(mgrs, dirBase),
33
+  Module(name, mgrs, dirBase),
33 34
   m_fileInStream(dirBase.getFile("instream"), mgrs.m_streamMgr),
34 35
   m_fileFormat(dirBase.getFile("format")),
35 36
   m_fileOutStream(dirBase.getFile("outstream"), mgrs.m_streamMgr)
... ...
@@ -28,10 +28,11 @@ class Resizer: public Module, public StreamRecv
28 28
 public:
29 29
   /**
30 30
    * @brief constructor
31
+   * @param[in] name module name
31 32
    * @param[in] mgrs managers
32 33
    * @param[in] dirBase base directory
33 34
    */
34
-  Resizer(Mgrs &mgrs, const Directory &dirBase);
35
+  Resizer(const std::string &name, Mgrs &mgrs, const Directory &dirBase);
35 36
 
36 37
   /// virtual destructor
37 38
   virtual ~Resizer();
... ...
@@ -23,12 +23,13 @@ namespace Blinker {
23 23
 
24 24
 /**
25 25
  * @brief constructor
26
+ * @param[in] name module name
26 27
  * @param[in] mgrs managers
27 28
  * @param[in] dirBase base directory
28 29
  */
29
-Scaler::Scaler(Mgrs &mgrs,
30
+Scaler::Scaler(const std::string &name, Mgrs &mgrs,
30 31
                  const Directory &dirBase):
31
-  Module(mgrs, dirBase),
32
+  Module(name, mgrs, dirBase),
32 33
   m_fileInStream(dirBase.getFile("instream"), mgrs.m_streamMgr),
33 34
   m_fileSize(dirBase.getFile("size")),
34 35
   m_fileOutStream(dirBase.getFile("outstream"), mgrs.m_streamMgr)
... ...
@@ -28,10 +28,11 @@ class Scaler: public Module, public StreamRecv
28 28
 public:
29 29
   /**
30 30
    * @brief constructor
31
+   * @param[in] name module name
31 32
    * @param[in] mgrs managers
32 33
    * @param[in] dirBase base directory
33 34
    */
34
-  Scaler(Mgrs &mgrs, const Directory &dirBase);
35
+  Scaler(const std::string &name, Mgrs &mgrs, const Directory &dirBase);
35 36
 
36 37
   /// virtual destructor
37 38
   virtual ~Scaler();
... ...
@@ -50,10 +50,11 @@ protected:
50 50
 public:
51 51
   /**
52 52
    * @brief constructor
53
+   * @param[in] name module name
53 54
    * @param[in] mgrs managers
54 55
    * @param[in] dirBase base directory
55 56
    */
56
-  Sender(Mgrs &mgrs, const Directory &dirBase);
57
+  Sender(const std::string &name, Mgrs &mgrs, const Directory &dirBase);
57 58
 
58 59
   /// virtual destructor
59 60
   virtual ~Sender();
... ...
@@ -35,12 +35,14 @@ namespace Blinker {
35 35
 
36 36
 /**
37 37
  * @brief constructor
38
+ * @param[in] name module name
38 39
  * @param[in] mgrs managers
39 40
  * @param[in] dirBase base directory
40 41
  */
41 42
 template<typename ADDR, typename SOCK>
42
-Sender<ADDR, SOCK>::Sender(Mgrs &mgrs, const Directory &dirBase):
43
-  Module(mgrs, dirBase),
43
+Sender<ADDR, SOCK>::Sender(const std::string &name, Mgrs &mgrs,
44
+                           const Directory &dirBase):
45
+  Module(name, mgrs, dirBase),
44 46
   m_fileInStream(dirBase.getFile("instream"), mgrs.m_streamMgr),
45 47
   m_fileBind(dirBase.getFile("bind")),
46 48
   m_fileProtocol(dirBase.getFile("protocol")),
... ...
@@ -31,18 +31,23 @@ void run(const std::string &dirConfig)
31 31
 
32 32
   Mgrs mgrs;
33 33
 
34
-  ModuleMgr<Canvas>       canvases(mgrs,      cfg.getSubdir("canvases"));
35
-  ModuleMgr<FlexiPix>     flexipixes(mgrs,    cfg.getSubdir("flexipixes"));
36
-  ModuleMgr<OpPrinter>    opprinters(mgrs,    cfg.getSubdir("opprinters"));
37
-  ModuleMgr<Output>       outputs(mgrs,       cfg.getSubdir("outputs"));
38
-  ModuleMgr<Player>       players(mgrs,       cfg.getSubdir("players"));
39
-  ModuleMgr<Printer>      printers(mgrs,      cfg.getSubdir("printers"));
40
-  ModuleMgr<Priority>     priorities(mgrs,    cfg.getSubdir("priorities"));
41
-  ModuleMgr<Resizer>      resizers(mgrs,      cfg.getSubdir("resizers"));
42
-  ModuleMgr<Scaler>       scalers(mgrs,       cfg.getSubdir("scalers"));
43
-  ModuleMgr<Udp4Phone>    udp4Phone(mgrs,     cfg.getSubdir("udp4phones"));
44
-  ModuleMgr<Udp4Receiver> udp4Receivers(mgrs, cfg.getSubdir("udp4receivers"));
45
-  ModuleMgr<Udp4Sender>   udp4Senders(mgrs,   cfg.getSubdir("udp4senders"));
34
+#define MODULEMGR(TYPE, CLASS) \
35
+  ModuleMgr<TYPE> CLASS(#CLASS, mgrs, cfg.getSubdir(#CLASS))
36
+
37
+  MODULEMGR(Canvas,       canvases);
38
+  MODULEMGR(FlexiPix,     flexipixes);
39
+  MODULEMGR(OpPrinter,    opprinters);
40
+  MODULEMGR(Output,       outputs);
41
+  MODULEMGR(Player,       players);
42
+  MODULEMGR(Printer,      printers);
43
+  MODULEMGR(Priority,     priorities);
44
+  MODULEMGR(Resizer,      resizers);
45
+  MODULEMGR(Scaler,       scalers);
46
+  MODULEMGR(Udp4Phone,    udp4phones);
47
+  MODULEMGR(Udp4Receiver, udp4receivers);
48
+  MODULEMGR(Udp4Sender,   udp4senders);
49
+
50
+#undef MODULEMGR
46 51
 
47 52
   mgrs.m_callMgr.run();
48 53
 }
49 54