RINASim  October 2016
Documentation of framework for OMNeT++
ConnectionTable.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 "ConnectionTable.h"
24 
26 
28 {
29  WATCH_LIST(ConTable);
30 }
31 
32 std::string ConnectionTable::info() const {
33  std::ostringstream os;
34  os << "id=" << this->getId() << endl;
35  /*
36  for(TCTConstIter it = ConTable.begin(); it != ConTable.end(); ++it )
37  {
38  ConnectionTableEntry cte = *it;
39  os << cte << endl;
40  }
41  */
42  return os.str();
43 }
44 
46  Enter_Method("insertNew()");
47  this->insert(ConnectionTableEntry(flow));
48 }
49 
51  Enter_Method("insert()");
52  ConTable.push_back(entry);
53 }
54 
56 }
57 
59  for(TCTIter it = ConTable.begin(); it != ConTable.end(); ++it) {
60  if ( it->getApni() == apni )
61  return &(*it);
62  }
63  return NULL;
64 }
65 
67  return findEntryByAPNI(flow->getSrcApni());
68 }
69 
70 bool ConnectionTable::setSouthGates(Flow* flow, cGate* sIn, cGate* sOut) {
72  if (cte) {
73  cte->setSouthGateIn(sIn);
74  cte->setSouthGateOut(sOut);
75  return true;
76  }
77  else
78  return false;
79 }
80 
81 bool ConnectionTable::setNorthGates(Flow* flow, cGate* nIn, cGate* nOut) {
83  if (cte) {
84  cte->setNorthGateIn(nIn);
85  cte->setNorthGateOut(nOut);
86  return true;
87  }
88  else
89  return false;
90 }
91 
94  if (cte) {
95  cte->setFlowAlloc(fa);
96  return true;
97  }
98  else
99  return false;
100 }
101 
102 cGate* ConnectionTable::findOutputGate(cGate* input, bool& isGoingUp) {
103  for(TCTIter it = ConTable.begin(); it != ConTable.end(); ++it) {
104  if ( it->getNorthGateIn() == input ) {
105  isGoingUp = false;
106  return it->getSouthGateOut();
107  }
108  if ( it->getSouthGateIn() == input ) {
109  isGoingUp = true;
110  return it->getNorthGateOut();
111  }
112  }
113  return NULL;
114 }
115 
118  if (cte) {
119  cte->setConStatus(status);
120  return true;
121  }
122  else
123  return false;
124 }
125 
127 {
128 
129 }
130 
133  return cte ? cte->getFlowAlloc() : NULL;
134 }
135 
138  if (cte) {
139  return cte->getConStatus();
140  }
142 }
FABase * getFlowAlloc() const
bool setStatus(Flow *flow, ConnectionTableEntry::ConnectionStatus status)
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 * findOutputGate(cGate *input, bool &isGoingUp)
ConnectionStatus
ConnectionTableEntry::ConnectionStatus getConStatus() const
bool setNorthGates(Flow *flow, cGate *nIn, cGate *nOut)
Define_Module(ConnectionTable)
void insert(const ConnectionTableEntry &entry)
FABase * getFa(Flow *flow)
void setSouthGateIn(cGate *southGateIn)
APNamingInfo holds complete naming info for particular application process.
Definition: APNamingInfo.h:43
bool setFa(Flow *flow, FABase *fa)
ConnectionTableEntry::ConnectionStatus getStatus(Flow *flow)
virtual void handleMessage(cMessage *msg)
void insertNew(Flow *flow)
ConnectionTableEntry * findEntryByFlow(Flow *flow)
void setSouthGateOut(cGate *southGateOut)
std::string info() const
TConTable ConTable
TConTable::iterator TCTIter
virtual void initialize()
Definition: FABase.h:33
bool setSouthGates(Flow *flow, cGate *sIn, cGate *sOut)
void setNorthGateIn(cGate *northGateIn)
ConnectionTableEntry * findEntryByAPNI(const APNamingInfo &apni)
void setConStatus(ConnectionStatus conStatus)
void setFlowAlloc(FABase *flowAlloc)
void setNorthGateOut(cGate *northGateOut)