RINASim  October 2016
Documentation of framework for OMNeT++
ConnectionId.cc
Go to the documentation of this file.
1 // The MIT License (MIT)
2 //
3 // Copyright (c) 2014-2016 Brno University of Technology, PRISTINE project
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 // THE SOFTWARE.
22 
23 #include "ConnectionId.h"
24 
25 //Consts
26 const int VAL_UNDEF_CEPID = -1;
27 const int VAL_MGMT_CEPID = 0;
28 
30  qosId(VAL_UNDEF_QOSID), srcCEPId(VAL_UNDEF_CEPID), dstCEPId(VAL_UNDEF_CEPID)
31 {
32 }
33 
35 {
36  return dstCEPId;
37 }
38 
39 void ConnectionId::setDstCepId(int destCepId)
40 {
41  dstCEPId = destCepId;
42 }
43 
44 std::string ConnectionId::getQoSId() const
45 {
46  return qosId;
47 }
48 
49 void ConnectionId::setQoSId(std::string qoSId)
50 {
51  this->qosId = qoSId;
52 }
53 
55 {
56  return srcCEPId;
57 }
58 
59 void ConnectionId::setSrcCepId(int srcCepId)
60 {
61  srcCEPId = srcCepId;
62 }
63 
65 {
67  srcCEPId = 0;
68  dstCEPId = 0;
69 }
70 
72 {
73  ConnectionId* connId = new ConnectionId();
74  connId->setDstCepId(this->dstCEPId);
75  connId->setSrcCepId(this->srcCEPId);
76  connId->setQoSId(this->qosId);
77  return connId;
78 }
79 
80 bool ConnectionId::operator<(const ConnectionId other) const
81 {
82  if (qosId < other.qosId) return true;
83  if (qosId > other.qosId) return false;
84 
85  if (dstCEPId < other.dstCEPId) return true;
86  if (dstCEPId > other.dstCEPId) return false;
87 
88  if (srcCEPId < other.srcCEPId) return true;
89  if (srcCEPId > other.srcCEPId) return false;
90 
91  return false;
92 }
93 
94 bool ConnectionId::operator==(const ConnectionId other) const
95 {
96  return qosId == other.qosId
97  && dstCEPId == other.dstCEPId
98  && srcCEPId == other.srcCEPId;
99 }
100 
102 {
103  int tmp = srcCEPId;
104  srcCEPId = dstCEPId;
105  dstCEPId = tmp;
106  return *this;
107 }
108 
109 std::string ConnectionId::info() const
110 {
111  std::ostringstream os;
112 
113  os << srcCEPId << ":" << dstCEPId << ":" << qosId;
114  return os.str();
115 }
116 
117 std::ostream& operator <<(std::ostream& os, const ConnectionId& connId)
118 {
119  return os << connId.info();
120 }
121 
int srcCEPId
Source Connection-Endpoint identifier.
Definition: ConnectionId.h:135
int dstCEPId
Destination Connection-Endpoint identifier.
Definition: ConnectionId.h:140
ConnectionId & swapCepIds()
Exchanges source and destination CEP identifiers.
std::string getQoSId() const
Getter of selected QoS-cube identifier.
Definition: ConnectionId.cc:44
std::ostream & operator<<(std::ostream &os, const ConnectionId &connId)
bool operator==(const ConnectionId other) const
Equal operator overload.
Definition: ConnectionId.cc:94
Connection identifier as defined in specifications.
Definition: ConnectionId.h:42
int getSrcCepId() const
Getter of source Connection-Endpoint identifier.
Definition: ConnectionId.cc:54
virtual ConnectionId * dup() const
Duplicate overload creates exact copy of ConnectionId.
Definition: ConnectionId.cc:71
void setDstCepId(int destCepId)
Setter of destination Connection-Endpoint identifier.
Definition: ConnectionId.cc:39
const int VAL_UNDEF_CEPID
Definition: ConnectionId.cc:26
const std::string VAL_UNDEF_QOSID
Definition: QoSCube.cc:36
ConnectionId()
Constructor of blank ConnectionId.
Definition: ConnectionId.cc:29
virtual ~ConnectionId()
Destructor assigning undefined values.
Definition: ConnectionId.cc:64
int getDstCepId() const
Getter of destination Connection-Endpoint identifier.
Definition: ConnectionId.cc:34
bool operator<(const ConnectionId other) const
Less operator overload.
Definition: ConnectionId.cc:80
std::string info() const
Info text outpu suitable for << strinng streams and WATCH.
std::string qosId
QoS-cube identifier.
Definition: ConnectionId.h:130
const int VAL_MGMT_CEPID
Definition: ConnectionId.cc:27
void setQoSId(std::string qoSId)
Setter of selected QoS-cube identifier.
Definition: ConnectionId.cc:49
void setSrcCepId(int srcCepId)
Setter of source Connection-Endpoint identifier.
Definition: ConnectionId.cc:59