FACT++  1.0
DimServiceInfoList.h
Go to the documentation of this file.
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;
14 
16 {
17 public:
18 
19  typedef std::map<const std::string, std::vector<DimInfo*>> ServiceInfoList;
20 
21  // Format IsCmd
22  typedef std::pair<std::string, bool> ServiceType;
23 
24  // name of service Format/description
25  typedef std::map<const std::string, ServiceType> TypeList;
26 
27  // ServiceName comment list of descriptions
28  typedef std::map<const std::string, std::pair<std::string, std::vector<Description>>> DescriptionList;
29 
30  struct ServerInfo
31  {
32  TypeList first;
33  DescriptionList second;
34  std::vector<State> third;
35  };
36 
37  // Server ServerInfo
38  typedef std::map<const std::string, ServerInfo> ServiceList;
39 
40 private:
42  ServiceInfoList fServiceInfoList;
43  ServiceList fServiceList;
44 
45  DimInfo *CreateDimInfo(const std::string &str, const std::string &svc) const;
46  DimInfo *CreateSL(const std::string &str) const { return CreateDimInfo(str, "SERVICE_LIST"); }
47  DimInfo *CreateFMT(const std::string &str) const { return CreateDimInfo(str, "SERVICE_DESC"); }
48  DimInfo *CreateDS(const std::string &str) const { return CreateDimInfo(str, "STATE_LIST"); }
49 
50 public:
51  void AddServer(const std::string &s);
52  void RemoveServer(std::string);
53  void RemoveAllServers();
54 
55 protected:
56  void infoHandler();
57 
58 public:
61 
62  std::vector<std::string> GetServiceList(bool iscmd=false) const;
63  std::vector<std::string> GetServiceList(const std::string &server, bool iscmd=false) const;
64 
65  std::vector<Description> GetDescription(const std::string &server, const std::string &service) const;
66  std::vector<State> GetStates(const std::string &server) const;
67  State GetState(const std::string &server, int state) const;
68 
69  int IsCommand(const std::string &server, const std::string &service) const;
70 
71  int PrintDescription(std::ostream &out, bool iscmd, const std::string &serv="", const std::string &service="") const;
72  int PrintStates(std::ostream &out, const std::string &serv="") const;
73 
74  bool SendDimCommand(std::ostream &lout, const std::string &server, const std::string &str) const;
75  void SendDimCommand(const std::string &server, std::string str, std::ostream &lout) const;
76  void SendDimCommand(const std::string &server, const std::string &str) const;
77 };
78 
80 {
81 public:
83 
84 protected:
85  virtual void AddServer(const std::string &s) { fInfo.AddServer(s); }
86  virtual void RemoveServer(std::string s) { fInfo.RemoveServer(s); }
87  virtual void RemoveAllServers() { fInfo.RemoveAllServers(); }
88 
89 public:
90  virtual void AddService(const std::string &, const std::string &, const std::string &, bool) { }
91  virtual void RemoveService(std::string, std::string, bool) { }
92  virtual void RemoveAllServices(const std::string &) { }
93  virtual void AddDescription(const std::string &, const std::string &, const std::vector<Description> &) { }
94  virtual void AddStates(const std::string &, const std::vector<State> &) { }
95 
96 public:
97  DimServiceInfoListImp() : fInfo(this) { }
99 
100  std::vector<std::string> GetServiceList(bool iscmd=false) const
101  { return fInfo.GetServiceList(iscmd); }
102  std::vector<std::string> GetServiceList(const std::string &server, bool iscmd=false) const
103  { return fInfo.GetServiceList(server, iscmd); }
104 
105  std::vector<std::string> GetCommandList() const { return GetServiceList(true); }
106  std::vector<std::string> GetCommandList(const std::string &server) const { return GetServiceList(server, true); }
107 
108  std::vector<Description> GetDescription(const std::string &server, const std::string &service) const
109  { return fInfo.GetDescription(server, service); }
110  std::vector<State> GetStates(const std::string &server) const
111  { return fInfo.GetStates(server); }
112  State GetState(const std::string &server, int state) const
113  { return fInfo.GetState(server, state); }
114 
115  int IsCommand(const std::string &server, const std::string &service) const
116  { return fInfo.IsCommand(server, service); }
117 
118  int PrintDescription(std::ostream &out, bool iscmd, const std::string &serv="", const std::string &service="") const
119  { return fInfo.PrintDescription(out, iscmd, serv, service); }
120  int PrintStates(std::ostream &out, const std::string &serv="") const
121  { return fInfo.PrintStates(out, serv); }
122 
123  bool SendDimCommand(std::ostream &lout, const std::string &server, const std::string &str) const
124  { return fInfo.SendDimCommand(lout, server, str); }
125  void SendDimCommand(const std::string &server, std::string str, std::ostream &lout) const
126  { return fInfo.SendDimCommand(server, str, lout); }
127  void SendDimCommand(const std::string &server, const std::string &str) const
128  { return fInfo.SendDimCommand(server, str); }
129 };
130 
131 
132 
133 // ***************************************************************************
153 // ***************************************************************************
170 // ***************************************************************************
182 // ***************************************************************************
201 // ***************************************************************************
215 // ***************************************************************************
216 
217 #endif
void RemoveServer(std::string)
virtual void AddDescription(const std::string &, const std::string &, const std::vector< Description > &)
std::map< const std::string, ServiceType > TypeList
ServiceList fServiceList
A map storing the service description to retrieve all informations.
void AddServer(const std::string &s)
int PrintDescription(std::ostream &out, bool iscmd, const std::string &serv="", const std::string &service="") const
char str[80]
Definition: test_client.c:7
std::vector< std::string > GetCommandList(const std::string &server) const
std::vector< State > GetStates(const std::string &server) const
std::vector< State > third
Description of the arguments.
DimInfo * CreateFMT(const std::string &str) const
Definition: dic.hxx:31
std::map< const std::string, std::pair< std::string, std::vector< Description > > > DescriptionList
DescriptionList second
Format and description of the service.
std::vector< Description > GetDescription(const std::string &server, const std::string &service) const
int PrintStates(std::ostream &out, const std::string &serv="") const
Maintains a list of all services available in the Dim network.
bool SendDimCommand(std::ostream &lout, const std::string &server, const std::string &str) const
State GetState(const std::string &server, int state) const
std::pair< std::string, bool > ServiceType
virtual void RemoveAllServices(const std::string &)
std::vector< std::string > GetCommandList() const
int IsCommand(const std::string &server, const std::string &service) const
DimServiceInfoList(DimServiceInfoListImp *list)
DimServiceInfoListImp * fList
Definition: dis.c:69
std::map< const std::string, ServerInfo > ServiceList
virtual void RemoveServer(std::string s)
std::vector< std::string > GetServiceList(bool iscmd=false) const
std::vector< std::string > GetServiceList(bool iscmd=false) const
virtual void RemoveService(std::string, std::string, bool)
DimServiceInfoList fInfo
bool SendDimCommand(std::ostream &lout, const std::string &server, const std::string &str) const
DimInfo * CreateSL(const std::string &str) const
virtual void AddStates(const std::string &, const std::vector< State > &)
virtual void AddService(const std::string &, const std::string &, const std::string &, bool)
DimInfo * CreateDimInfo(const std::string &str, const std::string &svc) const
A mal containing all the available informations.
int PrintDescription(std::ostream &out, bool iscmd, const std::string &serv="", const std::string &service="") const
std::vector< std::string > GetServiceList(const std::string &server, bool iscmd=false) const
std::vector< State > GetStates(const std::string &server) const
State GetState(const std::string &server, int state) const
ServiceInfoList fServiceInfoList
int PrintStates(std::ostream &out, const std::string &serv="") const
std::map< const std::string, std::vector< DimInfo * > > ServiceInfoList
virtual void RemoveAllServers()
DimInfo * CreateDS(const std::string &str) const
Maintains a list of all servers based on DIS_DNS/SERVER_LIST.
Definition: DimServerList.h:11
int IsCommand(const std::string &server, const std::string &service) const
void SendDimCommand(const std::string &server, const std::string &str) const
std::vector< Description > GetDescription(const std::string &server, const std::string &service) const
virtual void AddServer(const std::string &s)
void SendDimCommand(const std::string &server, std::string str, std::ostream &lout) const