source: trunk/FACT++/src/StateMachineDimControl.h@ 18982

Last change on this file since 18982 was 18971, checked in by tbretz, 7 years ago
Removed an unused data memeber
File size: 3.0 KB
Line 
1#ifndef FACT_StateMachineDimControl
2#define FACT_StateMachineDimControl
3
4#include <set>
5
6#include "DimState.h"
7#include "StateMachineDim.h"
8
9class Configuration;
10
11class StateMachineDimControl : public StateMachineDim
12{
13 std::mutex fMutex;
14
15 std::vector<DimDescriptions*> fDimDescriptionsList;
16
17 std::set<std::string> fServerList;
18 std::set<Service> fServiceList;
19 std::map<std::string, std::vector<std::string>> fCommandList;
20 std::map<std::string, State> fCurrentStateList;
21 std::map<std::pair<std::string, int32_t>, std::pair<std::string, std::string>> fStateDescriptionList;
22 std::map<std::string, std::vector<Description>> fServiceDescriptionList;
23
24 std::function<void(const std::string &, const State&)> fStateCallback;
25
26 DimVersion fDim;
27 DimDnsServiceList fDimList;
28
29 bool fDebug;
30
31 std::string fUser;
32 std::string fScriptUser;
33
34 /// Default arguments provided to every java script
35 std::string fArgumentsJS;
36
37 std::function<int(const EventImp &)> fInterruptHandler;
38
39 std::string Line(const std::string &txt, char fill);
40
41public:
42 static bool fIsServer;
43
44 int ChangeState(int qos, const Time &time, int scriptdepth, std::string scriptfile, std::string user);
45 int ChangeState(int state);
46
47 int StartScript(const EventImp &imp, const std::string &cmd);
48 int StopScript(const EventImp &imp);
49 int InterruptScript(const EventImp &imp);
50
51 int HandleStateChange(const std::string &server, DimDescriptions *state);
52 int HandleDescriptions(DimDescriptions *state);
53 int HandleStates(const std::string &server, DimDescriptions *state);
54 int HandleServerAdd(const std::string &server);
55 int HandleServerRemove(const std::string &server);
56 int HandleAddService(const Service &svc);
57
58 bool HasServer(const std::string &server);
59
60 std::vector<std::string> GetServerList();
61 std::vector<std::string> GetCommandList(const std::string &server);
62 std::vector<std::string> GetCommandList();
63 std::vector<Description> GetDescription(const std::string &service);
64 std::vector<State> GetStates(const std::string &server);
65 std::set<Service> GetServiceList();
66
67 std::string GetArguments() const { return fArgumentsJS; }
68
69 int PrintStates(std::ostream &out, const std::string &serv="");
70 int PrintDescription(std::ostream &out, bool iscmd, const std::string &serv="", const std::string &service="");
71
72 State GetServerState(const std::string &server);
73
74 bool SendDimCommand(const std::string &server, std::string str, std::ostream &lout);
75
76 void SetStateCallback(const std::function<void(const std::string &, const State &)> &func) { fStateCallback = func; }
77
78 void SetInterruptHandler(const std::function<int(const EventImp &)> &func=std::function<int(const EventImp &)>()) { fInterruptHandler = func; }
79
80 void Stop(int code=0);
81
82public:
83 StateMachineDimControl(std::ostream &out=std::cout);
84 ~StateMachineDimControl();
85
86 int EvalOptions(Configuration &conf);
87};
88
89#endif
Note: See TracBrowser for help on using the repository browser.