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 |
|
17 |
#else |
18 |
|
19 |
#include <Winsock2.h> |
20 |
#include <Ws2tcpip.h> |
21 |
|
22 |
typedef unsigned long in_addr_t; |
23 |
|
24 |
#endif |
25 |
|
26 |
class Host |
27 |
{ |
28 |
private: |
29 |
#ifdef _WIN32 |
30 |
static unsigned count; |
31 |
static WSADATA data; |
32 |
#endif |
33 |
string host; |
34 |
string name; |
35 |
struct in_addr* address; |
36 |
string platform; |
37 |
public: |
38 |
Host(const string& host, const string& name = "", const string& address = |
39 |
"", const string& platform = "Unknown"); |
40 |
~Host(); |
41 |
void setHost(const string& host) { this->host = host; } |
42 |
void setName(const string& name, bool lookup = false); |
43 |
void setAddress(const string& address, bool lookup = false); |
44 |
void setPlatform(const string& platform) { this->platform = platform; } |
45 |
string getHost() const { return host; } |
46 |
string getName() const { return name; } |
47 |
string getAddress() const { return inet_ntoa(*address); } |
48 |
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_ |