otsdaq  v2_05_02_indev
SupervisorInfo.h
1 #ifndef _ots_SupervisorInfo_h_
2 #define _ots_SupervisorInfo_h_
3 
4 #include <string>
5 #include "otsdaq/Macros/CoutMacros.h" /* also for XDAQ_CONST_CALL */
6 #include "otsdaq/TablePlugins/XDAQContextTable.h"
7 
8 #pragma GCC diagnostic push
9 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
10 #pragma GCC diagnostic ignored "-Wunused-variable"
11 #pragma GCC diagnostic ignored "-Wunused-parameter"
12 #if __GNUC__ >= 8
13 #pragma GCC diagnostic ignored "-Wcatch-value"
14 #endif
15 #include "xdaq/Application.h" /* for xdaq::ApplicationDescriptor */
16 #include "xdaq/ContextDescriptor.h" /* for xdaq::ContextDescriptor */
17 #pragma GCC diagnostic pop
18 #include "otsdaq/Macros/XDAQApplicationMacros.h"
19 
20 // clang-format off
21 namespace ots
22 {
24 {
25  public:
26  // when no configuration, e.g. Wizard Mode, then
27  // name and contextName are derived from the class name and LID
28  SupervisorInfo(XDAQ_CONST_CALL xdaq::ApplicationDescriptor* descriptor, const std::string& name, const std::string& contextName)
29  : descriptor_(descriptor)
30  , contextDescriptor_(descriptor ? descriptor->getContextDescriptor() : 0)
31  , name_(name)
32  , // this is the config app name
33  contextName_(contextName)
34  , // this is the config parent context name
35  id_(descriptor ? descriptor->getLocalId() : 0)
36  , class_(descriptor ? descriptor->getClassName() : "")
37  , contextURL_(contextDescriptor_ ? contextDescriptor_->getURL() : "")
38  , URN_(descriptor ? descriptor->getURN() : "")
39  , URL_(contextURL_ + "/" + URN_)
40  , port_(0)
41  , status_(SupervisorInfo::APP_STATUS_UNKNOWN)
42  {
43  // when no configuration, e.g. Wizard Mode, then
44  // name and contextName are derived from the class name and LID
45  if(name_ == "")
46  name_ = id_;
47  if(contextName_ == "")
48  contextName_ = class_;
49 
50  // __COUTV__(name_);
51  // __COUTV__(contextName_);
52  // __COUTV__(id_);
53  // __COUTV__(contextURL_);
54  // __COUTV__(URN_);
55  // __COUTV__(URL_);
56  // __COUTV__(port_);
57  // __COUTV__(class_);
58  }
59 
60  ~SupervisorInfo(void) { ; }
61 
62 
63  static const std::string APP_STATUS_UNKNOWN;
64 
65  // BOOLs -------------------
66  bool isGatewaySupervisor(void) const { return class_ == XDAQContextTable::GATEWAY_SUPERVISOR_CLASS; }
67  bool isWizardSupervisor(void) const { return class_ == XDAQContextTable::WIZARD_SUPERVISOR_CLASS; }
68  bool isTypeFESupervisor(void) const { return XDAQContextTable::FETypeClassNames_.find(class_) != XDAQContextTable::FETypeClassNames_.end(); }
69  bool isTypeDMSupervisor(void) const { return XDAQContextTable::DMTypeClassNames_.find(class_) != XDAQContextTable::DMTypeClassNames_.end(); }
70  bool isTypeLogbookSupervisor(void) const { return XDAQContextTable::LogbookTypeClassNames_.find(class_) != XDAQContextTable::LogbookTypeClassNames_.end(); }
71  bool isTypeMacroMakerSupervisor(void) const { return XDAQContextTable::MacroMakerTypeClassNames_.find(class_) != XDAQContextTable::MacroMakerTypeClassNames_.end(); }
72  bool isTypeConfigurationGUISupervisor(void) const { return XDAQContextTable::ConfigurationGUITypeClassNames_.find(class_) != XDAQContextTable::ConfigurationGUITypeClassNames_.end(); }
73  bool isTypeChatSupervisor(void) const { return XDAQContextTable::ChatTypeClassNames_.find(class_) != XDAQContextTable::ChatTypeClassNames_.end(); }
74  bool isTypeConsoleSupervisor(void) const { return XDAQContextTable::ConsoleTypeClassNames_.find(class_) != XDAQContextTable::ConsoleTypeClassNames_.end(); }
75 
76  // Getters -------------------
77  XDAQ_CONST_CALL xdaq::ApplicationDescriptor* getDescriptor (void) const { return descriptor_; }
78  const xdaq::ContextDescriptor* getContextDescriptor (void) const { return contextDescriptor_; }
79  const std::string& getName (void) const { return name_; }
80  const std::string& getContextName (void) const { return contextName_; }
81  const unsigned int& getId (void) const { return id_; }
82  const std::string& getClass (void) const { return class_; }
83  const std::string& getStatus (void) const { return status_; }
84  time_t getLastStatusTime (void) const { return lastStatusTime_; }
85  const unsigned int& getProgress (void) const { return progress_; }
86  const std::string& getDetail (void) const { return detail_; }
87  const std::string& getURL (void) const { return contextURL_; }
88  const std::string& getURN (void) const { return URN_; }
89  const std::string& getFullURL (void) const { return URL_; }
90  const uint16_t& getPort (void) const { return port_; }
91 
92  // Setters -------------------
93  void setStatus(const std::string& status, const unsigned int progress, const std::string& detail = "");
94  void clear(void);
95 
96  private:
97  XDAQ_CONST_CALL xdaq::ApplicationDescriptor* descriptor_;
98  XDAQ_CONST_CALL xdaq::ContextDescriptor* contextDescriptor_;
99  std::string name_;
100  std::string contextName_;
101  unsigned int id_;
102  std::string class_;
103  std::string contextURL_;
104  std::string URN_;
105  std::string URL_;
106  uint16_t port_;
107  std::string status_;
108  unsigned int progress_;
109  std::string detail_;
110  time_t lastStatusTime_;
111 };
112 // clang-format on
113 } // namespace ots
114 
115 #endif