1 | #ifndef FACT_DimServiceInfoList
|
---|
2 | #define FACT_DimServiceInfoList
|
---|
3 |
|
---|
4 | #include <map>
|
---|
5 | #include <vector>
|
---|
6 | #include <string>
|
---|
7 |
|
---|
8 | #include "State.h"
|
---|
9 | #include "Description.h"
|
---|
10 | #include "DimServerList.h"
|
---|
11 |
|
---|
12 | class DimInfo;
|
---|
13 |
|
---|
14 | class DimServiceInfoList : public DimServerList
|
---|
15 | {
|
---|
16 | public:
|
---|
17 |
|
---|
18 | typedef std::map<const std::string, std::vector<DimInfo*>> ServiceInfoList;
|
---|
19 |
|
---|
20 | // Format IsCmd
|
---|
21 | typedef std::pair<std::string, bool> ServiceType;
|
---|
22 |
|
---|
23 | // name of service Format/description
|
---|
24 | typedef std::map<const std::string, ServiceType> TypeList;
|
---|
25 |
|
---|
26 | // ServiceName comment list of descriptions
|
---|
27 | typedef std::map<const std::string, std::pair<std::string, std::vector<Description>>> DescriptionList;
|
---|
28 |
|
---|
29 | struct ServerInfo
|
---|
30 | {
|
---|
31 | TypeList first; /// Format and description of the service
|
---|
32 | DescriptionList second; /// Description of the arguments
|
---|
33 | std::vector<State> third; /// Available states of teh server
|
---|
34 | };
|
---|
35 |
|
---|
36 | // Server ServerInfo
|
---|
37 | typedef std::map<const std::string, ServerInfo> ServiceList;
|
---|
38 |
|
---|
39 | private:
|
---|
40 | ServiceInfoList fServiceInfoList; /// A map storing the service description to retrieve all informations
|
---|
41 | ServiceList fServiceList; /// A mal containing all the available informations
|
---|
42 |
|
---|
43 | DimInfo *CreateDimInfo(const std::string &str, const std::string &svc) const;
|
---|
44 | DimInfo *CreateSL(const std::string &str) const { return CreateDimInfo(str, "SERVICE_LIST"); }
|
---|
45 | DimInfo *CreateFMT(const std::string &str) const { return CreateDimInfo(str, "SERVICE_DESC"); }
|
---|
46 | DimInfo *CreateDS(const std::string &str) const { return CreateDimInfo(str, "STATE_LIST"); }
|
---|
47 |
|
---|
48 | protected:
|
---|
49 | void AddServer(const std::string &s);
|
---|
50 | void RemoveServer(const std::string &s);
|
---|
51 | void RemoveAllServers();
|
---|
52 |
|
---|
53 | virtual void AddService(const std::string &server, const std::string &service, const std::string &fmt, bool iscmd)
|
---|
54 | {
|
---|
55 | }
|
---|
56 | virtual void RemoveService(const std::string &server, const std::string &service, bool iscmd)
|
---|
57 | {
|
---|
58 | }
|
---|
59 | virtual void RemoveAllServices(const std::string &server)
|
---|
60 | {
|
---|
61 | }
|
---|
62 |
|
---|
63 | virtual void AddDescription(const std::string &server, const std::string &service, const std::vector<Description> &vec)
|
---|
64 | {
|
---|
65 | }
|
---|
66 |
|
---|
67 | virtual void AddStates(const std::string &server, const std::vector<State> &vec)
|
---|
68 | {
|
---|
69 | }
|
---|
70 |
|
---|
71 | protected:
|
---|
72 | void infoHandler();
|
---|
73 |
|
---|
74 | public:
|
---|
75 | DimServiceInfoList() { }
|
---|
76 | ~DimServiceInfoList() { RemoveAllServers(); }
|
---|
77 |
|
---|
78 | std::vector<std::string> GetServiceList(bool iscmd=false) const;
|
---|
79 | std::vector<std::string> GetServiceList(const std::string &server, bool iscmd=false) const;
|
---|
80 |
|
---|
81 | std::vector<std::string> GetCommandList() const { return GetServiceList(true); }
|
---|
82 | std::vector<std::string> GetCommandList(const std::string &server) const { return GetServiceList(server, true); }
|
---|
83 |
|
---|
84 | std::vector<Description> GetDescription(const std::string &server, const std::string &service) const;
|
---|
85 | std::vector<State> GetStates(const std::string &server) const;
|
---|
86 | State GetState(const std::string &server, int state) const;
|
---|
87 |
|
---|
88 | int IsCommand(const std::string &server, const std::string &service) const;
|
---|
89 |
|
---|
90 | int PrintDescription(std::ostream &out, bool iscmd, const std::string &serv="", const std::string &svc="") const;
|
---|
91 | int PrintStates(std::ostream &out, const std::string &serv="") const;
|
---|
92 |
|
---|
93 | bool SendDimCommand(std::ostream &lout, const std::string &server, const std::string &str) const;
|
---|
94 | void SendDimCommand(const std::string &server, std::string str, std::ostream &lout) const;
|
---|
95 | void SendDimCommand(const std::string &server, const std::string &str) const;
|
---|
96 | };
|
---|
97 |
|
---|
98 | #endif
|
---|