OverSim
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
BrooseHandle.cc
Go to the documentation of this file.
1
//
2
// Copyright (C) 2006 Institut fuer Telematik, Universitaet Karlsruhe (TH)
3
//
4
// This program is free software; you can redistribute it and/or
5
// modify it under the terms of the GNU General Public License
6
// as published by the Free Software Foundation; either version 2
7
// of the License, or (at your option) any later version.
8
//
9
// This program is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with this program; if not, write to the Free Software
16
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
//
18
24
#include <omnetpp.h>
25
26
#include <IPAddress.h>
27
28
#include "
BrooseHandle.h
"
29
30
std::ostream&
operator<<
(std::ostream& os,
const
BrooseHandle
& n)
31
{
32
if
(n.
isUnspecified
()) {
33
os <<
"<unspec>"
;
34
}
else
{
35
os << n.
getIp
() <<
":"
<< n.
getPort
() <<
" "
<< n.
getKey
() <<
" last-seen: "
<< n.
lastSeen
36
<<
" failedResponses: "
<< n.
failedResponses
<<
" rtt: "
<< n.
rtt
;
37
}
38
39
return
os;
40
};
41
42
BrooseHandle::BrooseHandle
()
43
{
44
//
45
// Default-constructor.
46
//
47
port
= -1;
48
key
=
OverlayKey::UNSPECIFIED_KEY
;
49
failedResponses
= 0;
50
rtt
= -1;
51
lastSeen
= -1;
52
}
53
54
BrooseHandle::BrooseHandle
(
OverlayKey
initKey, IPvXAddress initIP,
int
initPort)
55
{
56
//
57
// Constructor. Initializes the node handle with the passed arguments.
58
//
59
ip
= initIP;
60
port
= initPort;
61
key
= initKey;
62
failedResponses
= 0;
63
rtt
= -1;
64
lastSeen
= -1;
65
}
66
67
BrooseHandle::BrooseHandle
(
const
NodeHandle
& node)
68
{
69
//
70
// Constructor. Initializes the node handle with the passed arguments.
71
//
72
ip
= node.
getIp
();
73
port
= node.
getPort
();
74
key
= node.
getKey
();
75
failedResponses
= 0;
76
rtt
= -1;
77
lastSeen
= -1;
78
}
79
80
81
BrooseHandle::BrooseHandle
(
const
TransportAddress
& node,
const
OverlayKey
& destKey)
82
{
83
//
84
// Constructor. Initializes the node handle with the passed arguments.
85
//
86
ip
= node.
getIp
();
87
port
= node.
getPort
();
88
key
= destKey;
89
rtt
= -1;
90
lastSeen
= -1;
91
}
92
93
BrooseHandle
&
BrooseHandle::operator=
(
const
BrooseHandle
& rhs)
94
{
95
96
this->
key
= rhs.
getKey
();
97
this->
ip
= rhs.
getIp
();
98
this->
port
= rhs.
getPort
();
99
this->
failedResponses
= rhs.
failedResponses
;
100
this->
rtt
= rhs.
rtt
;
101
this->
lastSeen
= rhs.
lastSeen
;
102
return
*
this
;
103
}
104
105
bool
BrooseHandle::operator==
(
const
BrooseHandle
& rhs)
const
106
{
107
if
(this->
isUnspecified
() || rhs.
isUnspecified
())
108
opp_error(
"BrooseHandle: Trying to compare unspecified nodeHandle!"
);
109
110
if
(this->
key
!= rhs.
getKey
() )
111
return
false
;
112
if
(this->
ip
!= rhs.
getIp
() )
113
return
false
;
114
if
(this->
port
!= rhs.
getPort
() )
115
return
false
;
116
return
true
;
117
}
118
119
bool
BrooseHandle::operator!=
(
const
BrooseHandle
& rhs)
const
120
{
121
if
(this->
isUnspecified
() || rhs.
isUnspecified
())
122
opp_error(
"BrooseHandle: Trying to compare unspecified nodeHandle!"
);
123
124
if
(this->
key
== rhs.
getKey
() &&
125
this->
ip
== rhs.
getIp
() && this->
port
== rhs.
getPort
())
126
return
false
;
127
return
true
;
128
}
129
src
overlay
broose
BrooseHandle.cc
Generated on Fri Dec 7 2012 13:37:52 for OverSim by
1.8.1.2