RINASim  October 2016
Documentation of framework for OMNeT++
NM1FlowTable.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 "NM1FlowTable.h"
24 
26 
28 {
29  WATCH_LIST(flows);
30 }
31 
32 void NM1FlowTable::handleMessage(cMessage *msg)
33 {
34 
35 }
36 
38 {
39  flows.push_back(*entry);
40 }
41 
42 void NM1FlowTable::insert(Flow* flow, FABase* fa, RMTPort* port, std::string gateName)
43 {
44  NM1FlowTableItem entry = NM1FlowTableItem(flow, fa, port, gateName);
45  flows.push_back(entry);
46 }
47 
49 {
50  for(auto& item : flows)
51  {
52  if (item.getFlow() == flow)
53  {
54  return &item;
55  }
56  }
57  return nullptr;
58 }
59 
61  const std::string& qosId)
62 {
63  for (auto& item : flows)
64  {
65  if ((item.getFlow()->getDstApni().getApn().getName() == addr)
66  && !item.getFlow()->getConId().getQoSId().compare(qosId))
67  {
68  return &item;
69  }
70  }
71  return nullptr;
72 }
73 
75  const std::string& qosId)
76 {
77  for(auto& item : flows)
78  {
79  if ((item.getFlow()->getDstAddr().getApn().getName() == addr) &&
80  !item.getFlow()->getConId().getQoSId().compare(qosId) )
81  {
82  return &item;
83  }
84  }
85  return nullptr;
86 }
87 
89 {
90  FlTableIter i = flows.begin();
91  while (i != flows.end())
92  {
93  if (i->getFlow() == flow)
94  {
95  i = flows.erase(i);
96  }
97  else
98  {
99  ++i;
100  }
101  }
102 }
Class representing flow object with attributes from specs.
Definition: Flow.h:45
void insert(const NM1FlowTableItem *entry)
Definition: NM1FlowTable.cc:37
void remove(Flow *flow)
Definition: NM1FlowTable.cc:88
virtual void initialize()
Definition: NM1FlowTable.cc:27
NM1FlowTableItem * findFlowByDstAddr(const std::string &addr, const std::string &qosId)
Definition: NM1FlowTable.cc:74
Define_Module(NM1FlowTable)
NM1FlowTableItem * findFlowByDstApni(const std::string &addr, const std::string &qosId)
Definition: NM1FlowTable.cc:60
FlTable flows
Definition: NM1FlowTable.h:50
FlTable::iterator FlTableIter
Definition: NM1FlowTable.h:31
Definition: FABase.h:33
NM1FlowTableItem * lookup(Flow *flow)
Definition: NM1FlowTable.cc:48
virtual void handleMessage(cMessage *msg)
Definition: NM1FlowTable.cc:32