otsdaq  v2_01_00
SystemMessenger.h
1 #ifndef _ots_Utilities_SystemMessenger_h
2 #define _ots_Utilities_SystemMessenger_h
3 
4 #include "otsdaq-core/MessageFacility/MessageFacility.h"
5 #include "otsdaq-core/Macros/CoutMacros.h"
6 
7 #include <string>
8 #include <vector>
9 #include <iostream>
10 
11 namespace ots
12 {
13 
15 {
16 public:
17 
18  SystemMessenger() : sysMsgLock_(false) {}; //constructor
19 
20  void addSystemMessage(std::string targetUser, std::string msg);
21  std::string getSystemMessage(std::string targetUser);
22 
23 private:
24 
25  //Members for system messages ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26  // Set of vectors to delivers system messages to active users of the Web Gui
27  // When a message is generated, sysMsgLock is set,
28  // message is added the vector set sysMsgDelivered_[i] = false,
29  // and sysMsgLock is unset.
30  // When a message is delivered sysMsgDelivered_[i] = true,
31  // During sysMsgCleanup(), sysMsgLock is set, delivered messages are removed,
32  // and sysMsgLock is unset.
33  std::vector<std::string> sysMsgTargetUser_;
34  std::vector<std::string> sysMsgMessage_;
35  std::vector<time_t> sysMsgTime_;
36  std::vector<bool> sysMsgDelivered_;
37  void sysMsgSetLock(bool set);
38  void sysMsgCleanup();
39 
40  volatile bool sysMsgLock_;
41 
42  enum {
43  SYS_CLEANUP_WILDCARD_TIME = 30, //30 seconds
44  };
45 };
46 
47 
48 }
49 
50 #endif