source: trunk/FACT++/src/DimServiceInfoList.h@ 10420

Last change on this file since 10420 was 10388, checked in by tbretz, 14 years ago
Added descriptions for the virtual function.
File size: 6.1 KB
Line 
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
12class DimInfo;
13
14class DimServiceInfoList : public DimServerList
15{
16public:
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
39private:
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
48protected:
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 &, const std::string &, const std::string &, bool) { }
54 virtual void RemoveService(const std::string &, const std::string &, bool) { }
55 virtual void RemoveAllServices(const std::string &) { }
56 virtual void AddDescription(const std::string &, const std::string &, const std::vector<Description> &) { }
57 virtual void AddStates(const std::string &, const std::vector<State> &) { }
58
59protected:
60 void infoHandler();
61
62public:
63 DimServiceInfoList() { }
64 ~DimServiceInfoList() { RemoveAllServers(); }
65
66 std::vector<std::string> GetServiceList(bool iscmd=false) const;
67 std::vector<std::string> GetServiceList(const std::string &server, bool iscmd=false) const;
68
69 std::vector<std::string> GetCommandList() const { return GetServiceList(true); }
70 std::vector<std::string> GetCommandList(const std::string &server) const { return GetServiceList(server, true); }
71
72 std::vector<Description> GetDescription(const std::string &server, const std::string &service) const;
73 std::vector<State> GetStates(const std::string &server) const;
74 State GetState(const std::string &server, int state) const;
75
76 int IsCommand(const std::string &server, const std::string &service) const;
77
78 int PrintDescription(std::ostream &out, bool iscmd, const std::string &serv="", const std::string &svc="") const;
79 int PrintStates(std::ostream &out, const std::string &serv="") const;
80
81 bool SendDimCommand(std::ostream &lout, const std::string &server, const std::string &str) const;
82 void SendDimCommand(const std::string &server, std::string str, std::ostream &lout) const;
83 void SendDimCommand(const std::string &server, const std::string &str) const;
84};
85
86// ***************************************************************************
87/** @fn DimServiceInfoList::AddService(const std::string &server, const std::string &service, const std::string &fmt, bool iscmd)
88
89This virtual function is called as a callback whenever a new service appears.
90The default is to do nothing.
91
92@param server
93 Server name of the server at which the new service appeared
94
95@param service
96 Service name which appeared
97
98@param fmt
99 Dim format string associated with the service
100
101@param iscmd
102 boolean which is true if it is a command, and false if it is a service
103
104
105**/
106// ***************************************************************************
107/** @fn DimServiceInfoList::RemoveService(const std::string &server, const std::string &service, bool iscmd)
108
109This virtual function is called as a callback whenever a service disappears.
110The default is to do nothing.
111
112@param server
113 Server name of the server at which the new service appeared
114
115@param service
116 Service name which appeared
117
118@param iscmd
119 boolean which is true if it is a command, and false if it is a service
120
121
122**/
123// ***************************************************************************
124/** @fn DimServiceInfoList::RemoveAllServices(const std::string &server)
125
126This virtual function is called as a callback whenever a server disappears,
127or the list must be cleared because a new list has been retrieved.
128The default is to do nothing.
129
130@param server
131 Server name of the server at which the new service appeared
132
133
134**/
135// ***************************************************************************
136/** @fn DimServiceInfoList::AddDescription(const std::string &server, const std::string &service, const std::vector<Description> &vec)
137
138This virtual function is called as a callback whenever a new description
139was received.
140The default is to do nothing.
141
142@param server
143 Server name of the server for which something was received
144
145@param service
146 Service name for which the description weer received
147
148@param vec
149 vector<Description> associated with this service. The first entry in the
150 list belongs to the service itself, each consecutive entry to its arguments
151
152
153**/
154// ***************************************************************************
155/** @fn DimServiceInfoList::AddStates(const std::string &server, const std::vector<State> &vec)
156
157This virtual function is called as a callback whenever a new list of states
158was received.
159The default is to do nothing.
160
161@param server
162 Server name for which the list was received
163
164@param vec
165 vector<State> associated with this server.
166
167**/
168// ***************************************************************************
169
170#endif
Note: See TracBrowser for help on using the repository browser.