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 |
|
|
|
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 |
Douglas Thrift |
12 |
string platform; |
37 |
Douglas Thrift |
11 |
public: |
38 |
Douglas Thrift |
12 |
Host(const string& host, const string& name = "", const string& address = |
39 |
|
|
"", const string& platform = "Unknown"); |
40 |
Douglas Thrift |
11 |
~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 |
Douglas Thrift |
12 |
void setPlatform(const string& platform) { this->platform = platform; } |
45 |
Douglas Thrift |
11 |
string getHost() const { return host; } |
46 |
|
|
string getName() const { return name; } |
47 |
|
|
string getAddress() const { return inet_ntoa(*address); } |
48 |
Douglas Thrift |
12 |
string getPlatform() const { return platform; } |
49 |
Douglas Thrift |
11 |
void operator++(); |
50 |
|
|
void operator++(int) { operator++(); } |
51 |
|
|
void operator--(); |
52 |
Douglas Thrift |
12 |
void operator--(int) { operator--(); } |
53 |
Douglas Thrift |
11 |
}; |
54 |
|
|
|
55 |
Douglas Thrift |
12 |
#endif // _Host_hpp_ |