#ifndef FACT_DimServiceInfoList #define FACT_DimServiceInfoList #include #include #include #include "State.h" #include "Description.h" #include "DimServerList.h" class DimInfo; class DimServiceInfoList : public DimServerList { public: typedef std::map> ServiceInfoList; // Format IsCmd typedef std::pair ServiceType; // name of service Format/description typedef std::map TypeList; // ServiceName comment list of descriptions typedef std::map>> DescriptionList; struct ServerInfo { TypeList first; /// Format and description of the service DescriptionList second; /// Description of the arguments std::vector third; /// Available states of teh server }; // Server ServerInfo typedef std::map ServiceList; private: ServiceInfoList fServiceInfoList; /// A map storing the service description to retrieve all informations ServiceList fServiceList; /// A mal containing all the available informations DimInfo *CreateDimInfo(const std::string &str, const std::string &svc) const; DimInfo *CreateSL(const std::string &str) const { return CreateDimInfo(str, "SERVICE_LIST"); } DimInfo *CreateFMT(const std::string &str) const { return CreateDimInfo(str, "SERVICE_DESC"); } DimInfo *CreateDS(const std::string &str) const { return CreateDimInfo(str, "STATE_LIST"); } protected: void AddServer(const std::string &s); void RemoveServer(const std::string &s); void RemoveAllServers(); virtual void AddService(const std::string &, const std::string &, const std::string &, bool) { } virtual void RemoveService(const std::string &, const std::string &, bool) { } virtual void RemoveAllServices(const std::string &) { } virtual void AddDescription(const std::string &, const std::string &, const std::vector &) { } virtual void AddStates(const std::string &, const std::vector &) { } protected: void infoHandler(); public: DimServiceInfoList() { } ~DimServiceInfoList() { RemoveAllServers(); } std::vector GetServiceList(bool iscmd=false) const; std::vector GetServiceList(const std::string &server, bool iscmd=false) const; std::vector GetCommandList() const { return GetServiceList(true); } std::vector GetCommandList(const std::string &server) const { return GetServiceList(server, true); } std::vector GetDescription(const std::string &server, const std::string &service) const; std::vector GetStates(const std::string &server) const; State GetState(const std::string &server, int state) const; int IsCommand(const std::string &server, const std::string &service) const; int PrintDescription(std::ostream &out, bool iscmd, const std::string &serv="", const std::string &svc="") const; int PrintStates(std::ostream &out, const std::string &serv="") const; bool SendDimCommand(std::ostream &lout, const std::string &server, const std::string &str) const; void SendDimCommand(const std::string &server, std::string str, std::ostream &lout) const; void SendDimCommand(const std::string &server, const std::string &str) const; }; // *************************************************************************** /** @fn DimServiceInfoList::AddService(const std::string &server, const std::string &service, const std::string &fmt, bool iscmd) This virtual function is called as a callback whenever a new service appears. The default is to do nothing. @param server Server name of the server at which the new service appeared @param service Service name which appeared @param fmt Dim format string associated with the service @param iscmd boolean which is true if it is a command, and false if it is a service **/ // *************************************************************************** /** @fn DimServiceInfoList::RemoveService(const std::string &server, const std::string &service, bool iscmd) This virtual function is called as a callback whenever a service disappears. The default is to do nothing. @param server Server name of the server at which the new service appeared @param service Service name which appeared @param iscmd boolean which is true if it is a command, and false if it is a service **/ // *************************************************************************** /** @fn DimServiceInfoList::RemoveAllServices(const std::string &server) This virtual function is called as a callback whenever a server disappears, or the list must be cleared because a new list has been retrieved. The default is to do nothing. @param server Server name of the server at which the new service appeared **/ // *************************************************************************** /** @fn DimServiceInfoList::AddDescription(const std::string &server, const std::string &service, const std::vector &vec) This virtual function is called as a callback whenever a new description was received. The default is to do nothing. @param server Server name of the server for which something was received @param service Service name for which the description weer received @param vec vector associated with this service. The first entry in the list belongs to the service itself, each consecutive entry to its arguments **/ // *************************************************************************** /** @fn DimServiceInfoList::AddStates(const std::string &server, const std::vector &vec) This virtual function is called as a callback whenever a new list of states was received. The default is to do nothing. @param server Server name for which the list was received @param vec vector associated with this server. **/ // *************************************************************************** #endif