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

Last change on this file since 14716 was 14674, checked in by tbretz, 12 years ago
Implemenetd a way to just check if a server is available and command descriptions have been received.
File size: 2.6 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 int fVerbosity;
30 bool fDebug;
31
32 std::string fUser;
33 std::string fScriptUser;
34
35 /// Default arguments provided to very java script
36 std::string fArgumentsJS;
37
38 std::string Line(const std::string &txt, char fill);
39
40public:
41 static bool fIsServer;
42
43 int ChangeState(int qos, const Time &time=Time(), int scriptdepth=-1, std::string scriptfile="", std::string user="");
44 int Write(const Time &time, const std::string &txt, int qos=kMessage);
45
46 int StartScript(const EventImp &imp, const std::string &cmd);
47 int StopScript();
48
49 int HandleStateChange(const std::string &server, DimDescriptions *state);
50 int HandleDescriptions(DimDescriptions *state);
51 int HandleStates(const std::string &server, DimDescriptions *state);
52 int HandleServerAdd(const std::string &server);
53 int HandleServerRemove(const std::string &server);
54 int HandleAddService(const Service &svc);
55
56 bool HasServer(const std::string &server);
57
58 std::vector<std::string> GetServerList();
59 std::vector<std::string> GetCommandList(const std::string &server);
60 std::vector<std::string> GetCommandList();
61 std::vector<Description> GetDescription(const std::string &service);
62
63 int PrintStates(std::ostream &out, const std::string &serv="");
64 int PrintDescription(std::ostream &out, bool iscmd, const std::string &serv="", const std::string &service="");
65
66 State GetServerState(const std::string &server);
67
68 bool SendDimCommand(const std::string &server, std::string str, std::ostream &lout);
69
70 void SetStateCallback(const std::function<void(const std::string &, const State &)> &func) { fStateCallback = func; }
71
72public:
73 StateMachineDimControl(std::ostream &out=std::cout);
74 ~StateMachineDimControl();
75
76 int EvalOptions(Configuration &conf);
77};
78
79#endif
Note: See TracBrowser for help on using the repository browser.