|
a |
|
b/src/DAF/IRM/ConnectionTable.cc |
|
|
1 |
//
|
|
|
2 |
// This program is free software: you can redistribute it and/or modify
|
|
|
3 |
// it under the terms of the GNU Lesser General Public License as published by
|
|
|
4 |
// the Free Software Foundation, either version 3 of the License, or
|
|
|
5 |
// (at your option) any later version.
|
|
|
6 |
//
|
|
|
7 |
// This program is distributed in the hope that it will be useful,
|
|
|
8 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
9 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
10 |
// GNU Lesser General Public License for more details.
|
|
|
11 |
//
|
|
|
12 |
// You should have received a copy of the GNU Lesser General Public License
|
|
|
13 |
// along with this program. If not, see http://www.gnu.org/licenses/.
|
|
|
14 |
//
|
|
|
15 |
|
|
|
16 |
#include "ConnectionTable.h"
|
|
|
17 |
|
|
|
18 |
Define_Module(ConnectionTable);
|
|
|
19 |
|
|
|
20 |
void ConnectionTable::initialize()
|
|
|
21 |
{
|
|
|
22 |
WATCH_LIST(ConTable);
|
|
|
23 |
//Insert info to the ConnectionTable
|
|
|
24 |
|
|
|
25 |
//Scan all AEs in DAP and add them to table
|
|
|
26 |
// for (cModule::SubmoduleIterator i(this->getParentModule()); !i.end(); i++) {
|
|
|
27 |
// cModule *submodp = i();
|
|
|
28 |
// if (dynamic_cast<AEBase*>(submodp))
|
|
|
29 |
// insertNewAe(dynamic_cast<AEBase*>(submodp));
|
|
|
30 |
// }
|
|
|
31 |
}
|
|
|
32 |
|
|
|
33 |
std::string ConnectionTable::info() const {
|
|
|
34 |
std::stringstream os;
|
|
|
35 |
os << "id=" << this->getId() << endl;
|
|
|
36 |
/*
|
|
|
37 |
for(TCTConstIter it = ConTable.begin(); it != ConTable.end(); ++it )
|
|
|
38 |
{
|
|
|
39 |
ConnectionTableEntry cte = *it;
|
|
|
40 |
os << cte << endl;
|
|
|
41 |
}
|
|
|
42 |
*/
|
|
|
43 |
return os.str();
|
|
|
44 |
}
|
|
|
45 |
|
|
|
46 |
void ConnectionTable::insertNew(Flow* flow) {
|
|
|
47 |
Enter_Method("insertNew()");
|
|
|
48 |
this->insert(ConnectionTableEntry(flow));
|
|
|
49 |
}
|
|
|
50 |
|
|
|
51 |
void ConnectionTable::insertNew(Flow* flow, cGate* nIn, cGate* nOut) {
|
|
|
52 |
Enter_Method("insertNew()");
|
|
|
53 |
this->insert(ConnectionTableEntry(flow, nIn, nOut));
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
void ConnectionTable::insert(const ConnectionTableEntry& entry) {
|
|
|
57 |
Enter_Method("insert()");
|
|
|
58 |
ConTable.push_back(entry);
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
void ConnectionTable::remove() {
|
|
|
62 |
}
|
|
|
63 |
|
|
|
64 |
ConnectionTableEntry* ConnectionTable::findEntryByFlow(Flow* flow) {
|
|
|
65 |
for(TCTIter it = ConTable.begin(); it != ConTable.end(); ++it) {
|
|
|
66 |
//EV << "Comparing" << it->getFlowObject() << " and " << flow << endl;
|
|
|
67 |
//EV << "=========NOVY=========\n" << it->getFlowObject()->info() << endl;
|
|
|
68 |
//EV << "=========STARY=========\n" << flow->info() << endl;
|
|
|
69 |
if ( it->getFlowObject() == flow )
|
|
|
70 |
return &(*it);
|
|
|
71 |
}
|
|
|
72 |
return NULL;
|
|
|
73 |
}
|
|
|
74 |
|
|
|
75 |
bool ConnectionTable::setSouthGates(Flow* flow, cGate* sIn, cGate* sOut) {
|
|
|
76 |
ConnectionTableEntry* cte = this->findEntryByFlow(flow);
|
|
|
77 |
if (cte) {
|
|
|
78 |
cte->setSouthGateIn(sIn);
|
|
|
79 |
cte->setSouthGateOut(sOut);
|
|
|
80 |
return true;
|
|
|
81 |
}
|
|
|
82 |
else
|
|
|
83 |
return false;
|
|
|
84 |
}
|
|
|
85 |
|
|
|
86 |
bool ConnectionTable::setNorthGates(Flow* flow, cGate* nIn, cGate* nOut) {
|
|
|
87 |
ConnectionTableEntry* cte = this->findEntryByFlow(flow);
|
|
|
88 |
if (cte) {
|
|
|
89 |
cte->setNorthGateIn(nIn);
|
|
|
90 |
cte->setNorthGateOut(nOut);
|
|
|
91 |
return true;
|
|
|
92 |
}
|
|
|
93 |
else
|
|
|
94 |
return false;
|
|
|
95 |
}
|
|
|
96 |
|
|
|
97 |
bool ConnectionTable::setFa(Flow* flow, FABase* fa) {
|
|
|
98 |
ConnectionTableEntry* cte = this->findEntryByFlow(flow);
|
|
|
99 |
if (cte) {
|
|
|
100 |
cte->setFlowAlloc(fa);
|
|
|
101 |
return true;
|
|
|
102 |
}
|
|
|
103 |
else
|
|
|
104 |
return false;
|
|
|
105 |
}
|
|
|
106 |
|
|
|
107 |
cGate* ConnectionTable::findOutputGate(cGate* input) {
|
|
|
108 |
for(TCTIter it = ConTable.begin(); it != ConTable.end(); ++it) {
|
|
|
109 |
if ( it->getNorthGateIn() == input )
|
|
|
110 |
return it->getSouthGateOut();
|
|
|
111 |
if ( it->getSouthGateIn() == input )
|
|
|
112 |
return it->getNorthGateOut();
|
|
|
113 |
}
|
|
|
114 |
return NULL;
|
|
|
115 |
}
|
|
|
116 |
|
|
|
117 |
void ConnectionTable::handleMessage(cMessage *msg)
|
|
|
118 |
{
|
|
|
119 |
|
|
|
120 |
}
|
|
|
121 |
|
|
|
122 |
FABase* ConnectionTable::getFa(Flow* flow) {
|
|
|
123 |
ConnectionTableEntry* cte = this->findEntryByFlow(flow);
|
|
|
124 |
return cte ? cte->getFlowAlloc() : NULL;
|
|
|
125 |
}
|