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