otsdaq  v2_00_00
CoreSupervisorBase.h
1 #ifndef _ots_CoreSupervisorBase_h_
2 #define _ots_CoreSupervisorBase_h_
3 
4 #include "otsdaq-core/SupervisorInfo/AllSupervisorInfo.h"
5 #include "otsdaq-core/WorkLoopManager/WorkLoopManager.h"
6 #include "otsdaq-core/FiniteStateMachine/RunControlStateMachine.h"
7 #include "otsdaq-core/SupervisorInfo/AllSupervisorInfo.h"
8 #include "otsdaq-core/SOAPUtilities/SOAPMessenger.h"
9 
10 #include "otsdaq-core/XmlUtilities/HttpXmlDocument.h"
11 #include "otsdaq-core/SOAPUtilities/SOAPUtilities.h"
12 #include "otsdaq-core/SOAPUtilities/SOAPCommand.h"
13 #include "otsdaq-core/CgiDataUtilities/CgiDataUtilities.h"
14 
15 #include "otsdaq-core/ConfigurationDataFormats/ConfigurationGroupKey.h"
16 #include "otsdaq-core/ConfigurationInterface/ConfigurationManager.h"
17 #include "otsdaq-core/ConfigurationInterface/ConfigurationTree.h"
18 #include "otsdaq-core/ConfigurationPluginDataFormats/XDAQContextConfiguration.h"
19 #include "otsdaq-core/MessageFacility/MessageFacility.h"
20 #include "otsdaq-core/Macros/CoutHeaderMacros.h"
21 #include "otsdaq-core/FiniteStateMachine/VStateMachine.h"
22 
23 #include "otsdaq-core/WebUsersUtilities/RemoteWebUsers.h"
24 
25 #pragma GCC diagnostic push
26 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
27 #include <xdaq/Application.h>
28 #pragma GCC diagnostic pop
29 #include "xgi/Method.h"
30 
31 #include <toolbox/fsm/FailedEvent.h>
32 
33 #include <xdaq/NamespaceURI.h>
34 #include <xoap/Method.h>
35 
36 #include <string>
37 #include <vector>
38 #include <map>
39 #include <memory>
40 
41 
42 
43 namespace ots
44 {
45 
46 class CoreSupervisorBase: public xdaq::Application, public SOAPMessenger, public RunControlStateMachine
47 {
48 
49 public:
50 
51  CoreSupervisorBase (xdaq::ApplicationStub * s) throw (xdaq::exception::Exception);
52  virtual ~CoreSupervisorBase(void);
53 
54  virtual void setSupervisorPropertyDefaults (void);
55  void destroy (void);
56 
57 private:
58  xoap::MessageReference workLoopStatusRequestWrapper (xoap::MessageReference message ) throw (xoap::exception::Exception);
59  void DefaultWrapper (xgi::Input* in, xgi::Output* out) throw (xgi::exception::Exception);
60  void requestWrapper (xgi::Input* in, xgi::Output* out) throw (xgi::exception::Exception);
61 
62 public:
63  //common web request handlers
64  virtual void Default (xgi::Input* in, xgi::Output* out) throw (xgi::exception::Exception);
65  virtual void request (xgi::Input* in, xgi::Output* out) throw (xgi::exception::Exception);
66 
67  //bool loginGateway (xgi::Input* in, xgi::Output* out);
68 
69  //State Machine request handlers
70  void stateMachineXgiHandler (xgi::Input* in, xgi::Output* out ) throw (xgi::exception::Exception);
71  void stateMachineResultXgiHandler (xgi::Input* in, xgi::Output* out ) throw (xgi::exception::Exception);
72  xoap::MessageReference stateMachineXoapHandler (xoap::MessageReference message ) throw (xoap::exception::Exception);
73  xoap::MessageReference stateMachineResultXoapHandler (xoap::MessageReference message ) throw (xoap::exception::Exception);
74 
75  xoap::MessageReference stateMachineStateRequest (xoap::MessageReference message ) throw (xoap::exception::Exception);
76  xoap::MessageReference stateMachineErrorMessageRequest (xoap::MessageReference message ) throw (xoap::exception::Exception);
77 
78  virtual xoap::MessageReference workLoopStatusRequest (xoap::MessageReference message ) throw (xoap::exception::Exception);
79 
80  bool stateMachineThread (toolbox::task::WorkLoop* workLoop);
81 
82  virtual void stateInitial (toolbox::fsm::FiniteStateMachine& fsm) throw (toolbox::fsm::exception::Exception);
83  virtual void statePaused (toolbox::fsm::FiniteStateMachine& fsm) throw (toolbox::fsm::exception::Exception);
84  virtual void stateRunning (toolbox::fsm::FiniteStateMachine& fsm) throw (toolbox::fsm::exception::Exception);
85  virtual void stateHalted (toolbox::fsm::FiniteStateMachine& fsm) throw (toolbox::fsm::exception::Exception);
86  virtual void stateConfigured (toolbox::fsm::FiniteStateMachine& fsm) throw (toolbox::fsm::exception::Exception);
87  virtual void inError (toolbox::fsm::FiniteStateMachine& fsm) throw (toolbox::fsm::exception::Exception);
88 
89  virtual void transitionConfiguring (toolbox::Event::Reference e) throw (toolbox::fsm::exception::Exception);
90  virtual void transitionHalting (toolbox::Event::Reference e) throw (toolbox::fsm::exception::Exception);
91  virtual void transitionInitializing (toolbox::Event::Reference e) throw (toolbox::fsm::exception::Exception);
92  virtual void transitionPausing (toolbox::Event::Reference e) throw (toolbox::fsm::exception::Exception);
93  virtual void transitionResuming (toolbox::Event::Reference e) throw (toolbox::fsm::exception::Exception);
94  virtual void transitionStarting (toolbox::Event::Reference e) throw (toolbox::fsm::exception::Exception);
95  virtual void transitionStopping (toolbox::Event::Reference e) throw (toolbox::fsm::exception::Exception);
96  virtual void enteringError (toolbox::Event::Reference e) throw (toolbox::fsm::exception::Exception);
97 
98 
99  static const std::string WORK_LOOP_DONE, WORK_LOOP_WORKING;
100 protected:
101 
102 
103  WorkLoopManager stateMachineWorkLoopManager_;
104  toolbox::BSem stateMachineSemaphore_;
105 
106  ConfigurationManager* theConfigurationManager_;
107 
108  std::string XDAQContextConfigurationName_;
109  std::string supervisorConfigurationPath_;
110 
111  std::string supervisorContextUID_;
112  std::string supervisorApplicationUID_;
113  std::string supervisorClass_;
114  std::string supervisorClassNoNamespace_;
115 
116  AllSupervisorInfo allSupervisorInfo_;
117  RemoteWebUsers theRemoteWebUsers_;
118  std::vector<VStateMachine*> theStateMachineImplementation_;
119 
120  bool LOCK_REQUIRED_;
121  uint8_t USER_PERMISSIONS_THRESHOLD_;
122  std::string USER_GROUPS_ALLOWED_;
123  std::string USER_GROUPS_DISALLOWED_;
124 
125  //Supervisor Property names
127  {
128  std::string const fieldRequireLock = "RequireUserHasLock";
129  std::string const fieldUserPermissionsThreshold = "UserPermissionsThreshold";
130  std::string const fieldUserGroupsAllowed = "UserGroupsAllowed";
131  std::string const fieldUserGroupsDisallowed = "UserGroupsDisallowed";
132  } supervisorProperties_;
133 };
134 
135 }
136 
137 #endif