source: trunk/FACT++/src/ServiceList.h@ 10252

Last change on this file since 10252 was 10183, checked in by tbretz, 10 years ago
New import.
File size: 2.7 KB
Line 
1#ifndef FACT_ServiceList
2#define FACT_ServiceList
3
4#include <map>
5#include <vector>
6#include <string>
7#include <iostream>
8
9#include "dic.hxx"
10#include "dis.hxx"
11
12class ServiceList : public DimClient
13{
14public:
15 typedef std::map<const std::string, DimInfo*> ServerMap;
16 typedef std::map<const std::string, std::vector<std::string>> ServiceMap;
17 typedef std::map<const std::string, std::string> FormatMap;
18
19private:
20 std::ostream &wout; /// stream for redirection of the output
21
22 DimInfo fDimServers; /// A DimInfo to retrieve the SERVER_LIST from teh DNS server
23
24 const std::string fType; /// A filter for the type of the services to be collected, e.g. CMD
25
26 ServerMap fServerList; /// A map storing server names and a DimInfo for their SERVICE_LIST
27 ServiceMap fServiceList; /// A map storing server names and vector with all their available commands
28 FormatMap fFormatList; /// A map storing all commands and their format strings
29
30 DimInfoHandler *fHandler; /// A callback to signal updates
31
32 DimInfo *CreateDimInfo(const std::string &str) const;
33
34 void ProcessServerList();
35 void ProcessServiceList(DimInfo &info);
36
37 void infoHandler();
38
39public:
40 ServiceList(const char *type, std::ostream &out=std::cout);
41 ServiceList(std::ostream &out=std::cout);
42 ~ServiceList();
43
44 void SetHandler(DimInfoHandler *handler=0) { fHandler=handler; }
45
46 std::vector<std::string> GetServerList() const;
47 std::vector<std::string> GetServiceList(const std::string &server) const;
48
49 bool HasServer(const std::string &name) const;
50 bool HasService(const std::string &server, const std::string &service) const;
51
52 ServiceMap::const_iterator begin() const { return fServiceList.begin(); }
53 ServiceMap::const_iterator end() const { return fServiceList.end(); }
54
55 std::vector<std::string>::const_iterator begin(const std::string &server) const;
56 std::vector<std::string>::const_iterator end(const std::string &server) const;
57
58 std::string GetFormat(const std::string &server, const std::string &name) const;
59 std::string GetFormat(const std::string &service) const;
60
61 void PrintServerList(std::ostream &out) const;
62 void PrintServiceList(std::ostream &out) const;
63 void PrintServerList() const { PrintServerList(wout); }
64 void PrintServiceList() const { PrintServiceList(wout); }
65
66 static void DumpServiceList(std::ostream &out);
67 void DumpServiceList() const { DumpServiceList(wout); }
68
69 bool SendDimCommand(std::ostream &lout, const std::string &server, const std::string &str) const;
70 bool SendDimCommand(const std::string &server, const std::string &str) const
71 {
72 return SendDimCommand(std::cout, server, str);
73 }
74};
75
76#endif
Note: See TracBrowser for help on using the repository browser.