1 |
// Host Update |
2 |
// |
3 |
// Douglas Thrift |
4 |
// |
5 |
// $Id$ |
6 |
|
7 |
#ifndef _Host_hpp_ |
8 |
#define _Host_hpp_ |
9 |
|
10 |
#include "HostUpdate.hpp" |
11 |
|
12 |
#ifndef _WIN32 |
13 |
|
14 |
#include <sys/socket.h> |
15 |
#include <netdb.h> |
16 |
#include <netinet/in.h> |
17 |
#include <arpa/inet.h> |
18 |
|
19 |
#else |
20 |
|
21 |
#include <winsock2.h> |
22 |
|
23 |
typedef unsigned long in_addr_t; |
24 |
|
25 |
#endif |
26 |
|
27 |
class Host |
28 |
{ |
29 |
private: |
30 |
#ifdef _WIN32 |
31 |
static unsigned count; |
32 |
static WSADATA data; |
33 |
#endif |
34 |
std::string host; |
35 |
std::string name; |
36 |
struct ::in_addr address; |
37 |
std::string platform; |
38 |
public: |
39 |
Host(const std::string& host, const std::string& name = "", const std::string& address = "", const std::string& platform = "Unknown"); |
40 |
~Host(); |
41 |
void setHost(const std::string& host) { this->host = host; } |
42 |
void setName(const std::string& name, bool lookup = false); |
43 |
void setAddress(const std::string& address, bool lookup = false); |
44 |
void setPlatform(const std::string& platform) { this->platform = platform; } |
45 |
std::string getHost() const { return host; } |
46 |
std::string getName() const { return name; } |
47 |
std::string getAddress() const { return inet_ntoa(address); } |
48 |
std::string getPlatform() const { return platform; } |
49 |
bool operator==(const Host& host) const; |
50 |
bool operator!=(const Host& host) const { return !(*this == host); } |
51 |
bool operator<(const Host& host) const { return this->host < host.host; } |
52 |
bool operator>(const Host& host) const { return this->host > host.host; } |
53 |
Host operator++(); |
54 |
Host operator++(int); |
55 |
Host operator--(); |
56 |
Host operator--(int); |
57 |
}; |
58 |
|
59 |
#endif // _Host_hpp_ |