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