RINASim  October 2016
Documentation of framework for OMNeT++
ConnectionTableEntry.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 <ConnectionTableEntry.h>
24 
26  : //FlowObject(NULL)
27  apni(APNamingInfo()), conStatus(CON_ERROR),
28  northGateIn(NULL), northGateOut(NULL),
29  southGateIn(NULL), southGateOut(NULL),
30  FlowAlloc(NULL)
31 {
32 }
33 
35  : conStatus(CON_FLOWPENDING),
36  northGateIn(NULL), northGateOut(NULL),
37  southGateIn(NULL), southGateOut(NULL),
38  FlowAlloc(NULL)
39 {
40  apni = flow->getSrcApni();
41 }
42 
44  //this->FlowObject = NULL;
45  this->conStatus = CON_ERROR;
46  this->northGateIn = NULL;
47  this->northGateOut = NULL;
48  this->southGateIn = NULL;
49  this->southGateOut = NULL;
50  this->FlowAlloc = NULL;
51 }
52 
53 std::string ConnectionTableEntry::info() const {
54  std::ostringstream os;
55  os << apni.info() << "\n";
56  if (FlowAlloc)
57  os << "FA path: " << FlowAlloc->getFullPath() << "\n";
59  os << "northIn: " << this->northGateIn->getName() << "[" << this->northGateIn->getIndex() << "]"
60  << "\tnorthOut: " << this->northGateOut->getName() << "[" << this->northGateIn->getIndex() << "]\n";
62  os << "southIn: " << this->southGateIn->getName()
63  << "\tsouthOut: " << this->southGateOut->getName() << "\n";
64  os << "status: " << this->getConnectionStatusString();
65  return os.str();
66 }
67 
69  switch(this->conStatus)
70  {
71  case CON_NIL: return "NULL";
72  case CON_FLOWPENDING: return "flow pending";
73  case CON_CONNECTPENDING: return "connect pending";
74  case CON_AUTHENTICATING: return "authenticating";
75  case CON_ESTABLISHED: return "established";
76  case CON_RELEASING: return "releasing";
77  case CON_ERROR:
78  default: return "UNKNOWN";
79  }
80 }
81 
83  this->conStatus = conStatus;
84 }
85 
86 std::ostream& operator <<(std::ostream& os, const ConnectionTableEntry& cte) {
87  return os << cte.info();
88 }
89 
91  return FlowAlloc;
92 }
93 
95  FlowAlloc = flowAlloc;
96 }
97 
99  return northGateIn;
100 }
101 
102 void ConnectionTableEntry::setNorthGateIn(cGate* northGateIn) {
103  this->northGateIn = northGateIn;
104 }
105 
107  return northGateOut;
108 }
109 
110 void ConnectionTableEntry::setNorthGateOut(cGate* northGateOut) {
111  this->northGateOut = northGateOut;
112 }
113 
115  return southGateIn;
116 }
117 
118 void ConnectionTableEntry::setSouthGateIn(cGate* southGateIn) {
119  this->southGateIn = southGateIn;
120 }
121 
123  return southGateOut;
124 }
125 
126 void ConnectionTableEntry::setSouthGateOut(cGate* southGateOut) {
127  this->southGateOut = southGateOut;
128 }
129 
131  return FlowAlloc->getModuleByPath("^.^");
132 }
133 
135  return apni;
136 }
137 
139  this->apni = apni;
140 }
141 
143  return conStatus;
144 }
FABase * getFlowAlloc() const
Class representing flow object with attributes from specs.
Definition: Flow.h:45
const APNamingInfo & getSrcApni() const
Gets read-only source APNamingInfo.
Definition: Flow.cc:134
cGate * getSouthGateOut() const
std::string info() const
ConnectionStatus
ConnectionTableEntry::ConnectionStatus getConStatus() const
std::ostream & operator<<(std::ostream &os, const ConnectionTableEntry &cte)
std::string getConnectionStatusString() const
cGate * northGateIn
cModule * getIpc() const
void setApni(const APNamingInfo &apni)
cGate * getSouthGateIn() const
void setSouthGateIn(cGate *southGateIn)
APNamingInfo holds complete naming info for particular application process.
Definition: APNamingInfo.h:43
const APNamingInfo & getApni() const
cGate * southGateOut
cGate * getNorthGateOut() const
void setSouthGateOut(cGate *southGateOut)
ConnectionStatus conStatus
cGate * southGateIn
ConnectionTableEntry()
FABase * FlowAlloc
cGate * getNorthGateIn() const
virtual ~ConnectionTableEntry()
APNamingInfo apni
Definition: FABase.h:33
void setNorthGateIn(cGate *northGateIn)
cGate * northGateOut
void setConStatus(ConnectionStatus conStatus)
std::string info() const
Info text output suitable for << string streams and WATCH.
Definition: APNamingInfo.cc:51
void setFlowAlloc(FABase *flowAlloc)
void setNorthGateOut(cGate *northGateOut)