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