1 | #ifndef FACT_DimServerList
|
---|
2 | #define FACT_DimServerList
|
---|
3 |
|
---|
4 | #include <vector>
|
---|
5 | #include <string>
|
---|
6 |
|
---|
7 | #include "dic.hxx"
|
---|
8 |
|
---|
9 | class DimServerListImp;
|
---|
10 |
|
---|
11 | class DimServerList : public DimInfoHandler
|
---|
12 | {
|
---|
13 | public:
|
---|
14 | typedef std::vector<std::string> ServerList;
|
---|
15 |
|
---|
16 | private:
|
---|
17 | DimServerListImp *fList;
|
---|
18 | ServerList fServerList; /// A list with the available servers
|
---|
19 | DimInfo fDimServers; /// A DimInfo to retrieve the SERVER_LIST from teh DNS server
|
---|
20 |
|
---|
21 | protected:
|
---|
22 | void infoHandler();
|
---|
23 |
|
---|
24 | public:
|
---|
25 | DimServerList(DimServerListImp *list);
|
---|
26 |
|
---|
27 | /// @returns a reference to the list of servers
|
---|
28 | const ServerList &GetServerList() const { return fServerList; }
|
---|
29 |
|
---|
30 | /// @returns whether the given server is in the list or not
|
---|
31 | /// @param server string with the server which availability should be checked
|
---|
32 | bool HasServer(const std::string &server) const;
|
---|
33 | };
|
---|
34 |
|
---|
35 | class DimServerListImp
|
---|
36 | {
|
---|
37 | DimServerList fList;
|
---|
38 |
|
---|
39 | public:
|
---|
40 | DimServerListImp() : fList(this) { }
|
---|
41 | virtual ~DimServerListImp() { }
|
---|
42 |
|
---|
43 | virtual void AddServer(const std::string &) { };
|
---|
44 | virtual void RemoveServer(std::string) { };
|
---|
45 | virtual void RemoveAllServers() { };
|
---|
46 |
|
---|
47 | /// @returns a reference to the list of servers
|
---|
48 | const DimServerList::ServerList &GetServerList() const { return fList.GetServerList(); }
|
---|
49 |
|
---|
50 | /// @returns whether the given server is in the list or not
|
---|
51 | /// @param server string with the server which availability should be checked
|
---|
52 | bool HasServer(const std::string &server) const { return fList.HasServer(server); }
|
---|
53 | };
|
---|
54 |
|
---|
55 | #endif
|
---|
56 |
|
---|
57 | // ***************************************************************************
|
---|
58 | /** @fn DimServerList::AddServer(const std::string &server)
|
---|
59 |
|
---|
60 | This virtual function is called as a callback whenever a new server appears
|
---|
61 | to be available on the dns.
|
---|
62 |
|
---|
63 | The default is to do nothing.
|
---|
64 |
|
---|
65 | @param server
|
---|
66 | Server name of the server which was added
|
---|
67 |
|
---|
68 | **/
|
---|
69 | // ***************************************************************************
|
---|
70 | /** @fn DimServerList::RemoveServer(const std::string &server)
|
---|
71 |
|
---|
72 | This virtual function is called as a callback whenever a server disappears
|
---|
73 | from the dns.
|
---|
74 |
|
---|
75 | The default is to do nothing.
|
---|
76 |
|
---|
77 | @param server
|
---|
78 | Server name of the server which was removed
|
---|
79 |
|
---|
80 |
|
---|
81 | **/
|
---|
82 | // ***************************************************************************
|
---|
83 | /** @fn DimServerList::RemoveAllServers()
|
---|
84 |
|
---|
85 | This virtual function is called as a callback whenever a all servers
|
---|
86 | disappear, e.g. the dns has vanished.
|
---|
87 |
|
---|
88 | The default is to do nothing.
|
---|
89 |
|
---|
90 |
|
---|
91 | **/
|
---|
92 | // ***************************************************************************
|
---|