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

Last change on this file since 14368 was 14132, checked in by tbretz, 12 years ago
Added new version of the core of dimctrl with callbacks to access the data from JavaScript.
File size: 2.3 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, std::pair<int32_t, std::string>> 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 DimVersion fDim;
25 DimDnsServiceList fDimList;
26
27 int fVerbosity;
28 bool fDebug;
29
30 std::string fUser;
31 std::string fScriptUser;
32
33 std::string Line(const std::string &txt, char fill);
34
35public:
36 static bool fIsServer;
37
38 int ChangeState(int qos, const Time &time=Time(), int scriptdepth=-1, std::string scriptfile="", std::string user="");
39 int Write(const Time &time, const std::string &txt, int qos=kMessage);
40
41 int StartScript(const EventImp &imp, const std::string &cmd);
42 int StopScript();
43
44 int HandleStateChange(const std::string &server, DimDescriptions *state);
45 int HandleDescriptions(DimDescriptions *state);
46 int HandleStates(const std::string &server, DimDescriptions *state);
47 int HandleServerAdd(const std::string &server);
48 int HandleServerRemove(const std::string &server);
49 int HandleAddService(const Service &svc);
50
51 bool HasServer(const std::string &server);
52
53 std::vector<std::string> GetServerList();
54 std::vector<std::string> GetCommandList(const std::string &server);
55 std::vector<std::string> GetCommandList();
56 std::vector<Description> GetDescription(const std::string &service);
57
58 int PrintStates(std::ostream &out, const std::string &serv="");
59 int PrintDescription(std::ostream &out, bool iscmd, const std::string &serv="", const std::string &service="");
60
61 std::pair<int32_t, std::string> GetServerState(const std::string &server);
62
63 void SendDimCommand(const std::string &server, std::string str, std::ostream &lout);
64
65public:
66 StateMachineDimControl(std::ostream &out=std::cout);
67 ~StateMachineDimControl();
68
69 int EvalOptions(Configuration &conf);
70};
71
72#endif
Note: See TracBrowser for help on using the repository browser.