#ifndef FACT_StateMachineDimControl #define FACT_StateMachineDimControl #include #include "DimState.h" #include "StateMachineDim.h" class Configuration; class StateMachineDimControl : public StateMachineDim { std::mutex fMutex; std::vector fDimDescriptionsList; std::set fServerList; std::set fServiceList; std::map> fCommandList; std::map fCurrentStateList; std::map, std::pair> fStateDescriptionList; std::map> fServiceDescriptionList; std::function fStateCallback; DimVersion fDim; DimDnsServiceList fDimList; int fVerbosity; bool fDebug; std::string fUser; std::string fScriptUser; std::string Line(const std::string &txt, char fill); public: static bool fIsServer; int ChangeState(int qos, const Time &time=Time(), int scriptdepth=-1, std::string scriptfile="", std::string user=""); int Write(const Time &time, const std::string &txt, int qos=kMessage); int StartScript(const EventImp &imp, const std::string &cmd); int StopScript(); int HandleStateChange(const std::string &server, DimDescriptions *state); int HandleDescriptions(DimDescriptions *state); int HandleStates(const std::string &server, DimDescriptions *state); int HandleServerAdd(const std::string &server); int HandleServerRemove(const std::string &server); int HandleAddService(const Service &svc); bool HasServer(const std::string &server); std::vector GetServerList(); std::vector GetCommandList(const std::string &server); std::vector GetCommandList(); std::vector GetDescription(const std::string &service); int PrintStates(std::ostream &out, const std::string &serv=""); int PrintDescription(std::ostream &out, bool iscmd, const std::string &serv="", const std::string &service=""); State GetServerState(const std::string &server); void SendDimCommand(const std::string &server, std::string str, std::ostream &lout); void SetStateCallback(const std::function &func) { fStateCallback = func; } public: StateMachineDimControl(std::ostream &out=std::cout); ~StateMachineDimControl(); int EvalOptions(Configuration &conf); }; #endif