-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommonClasses.cpp
More file actions
51 lines (38 loc) · 1.12 KB
/
Copy pathCommonClasses.cpp
File metadata and controls
51 lines (38 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "BaseLib/CommonClasses.h"
namespace BaseLib
{
std::ostream& operator<<(std::ostream &ostr, const ClientTriplet &triplet)
{
ostr << "(" << triplet.GetHost() << "," << triplet.GetPort() << "," << triplet.GetSocket() << ")";
return ostr;
}
ClientTriplet::ClientTriplet() : socket_(0), port_(0)
{
}
ClientTriplet::ClientTriplet(int socket, int port, std::string host)
: socket_(socket)
, port_(port)
, host_(host)
{
}
ClientTriplet::~ClientTriplet()
{
}
bool ClientTriplet::operator<(const ClientTriplet &other) const
{
return socket_ < other.GetSocket() ||
(socket_ == other.GetSocket() && port_ < other.GetPort()) ||
(socket_ == other.GetSocket() && port_ == other.GetPort() && host_.length() < other.GetHost().length());
}
bool ClientTriplet::operator==(const ClientTriplet &other) const
{
if(host_ == other.GetHost() &&
port_ == other.GetPort() &&
socket_ == other.GetSocket())
return true;
return false;
}
std::string ClientTriplet::GetHost() const { return host_; }
int ClientTriplet::GetPort() const { return port_; }
int ClientTriplet::GetSocket() const { return socket_; }
} // namespace BaseLib