RINASim  October 2016
Documentation of framework for OMNeT++
NFlowTableEntry.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 "NFlowTableEntry.h"
24 
26  fai(NULL), flow(NULL),
27  allocStatus(this->UNKNOWN),
28  timeCreated(0), timeDeleted(0)
29 {
30 }
31 
32 NFlowTableEntry::NFlowTableEntry(Flow* nflow): fai(NULL), allocStatus(this->UNKNOWN) {
33  this->flow = nflow;
34  this->timeCreated = simTime();
35  this->timeDeleted = 0;
36 }
37 
39  this->fai = NULL;
40  this->flow = NULL;
41  allocStatus = this->UNKNOWN;
42  timeCreated = 0;
43  timeDeleted = 0;
44 }
45 
46 std::string NFlowTableEntry::info() const {
47  std::ostringstream os;
48  os << "STATUS: " << this->getAllocateStatusString() << endl;
49  if ( this->getFai() )
50  os << "FAI> " << *(this->getFai()) << endl;
51  if ( this->getCFlow() ) {
52  os << this->getCFlow()->infoSource() << endl;
53  os << this->getCFlow()->infoDestination() << endl;
54  os << this->getCFlow()->infoOther() << endl;
55  os << this->getCFlow()->infoQoS() << endl;
56  }
57  os << "Created at: " << this->getTimeCreated() << ", invId: " << this->getCFlow()->getAllocInvokeId() << endl
58  << "Deleted at: " << this->getTimeDeleted() << ", invId: " << this->getCFlow()->getDeallocInvokeId() << endl;
59  return os.str();
60 }
61 
62 std::ostream& operator <<(std::ostream& os, const NFlowTableEntry& fte) {
63  return os << fte.info();
64 }
65 
67  return fai;
68 }
69 
70 const simtime_t& NFlowTableEntry::getTimeCreated() const {
71 return timeCreated;
72 }
73 
74 const simtime_t& NFlowTableEntry::getTimeDeleted() const {
75 return timeDeleted;
76 }
77 
79  switch(this->allocStatus)
80  {
81  case ALLOC_PEND: return "allocation pending";
82  case TRANSFER: return "allocation positive, transfer";
83  case ALLOC_NEGA: return "allocation negative";
84  case ALLOC_ERR: return "allocation error";
85  case DEALLOC_PEND: return "deallocation pending";
86  case DEALLOCATED: return "deallocated";
87  case DEINST_PEND: return "deinstantiation pending";
88  case DEINSTANTIATED: return "deinstantiated";
89  case FORWARDING: return "allocation forwarded";
90  case FORWARDED: return "allocation forwarded";
91  default: return "UNKNOWN";
92  }
93 // static std::string AllocateStatusStrings[] = {"Pending", "Allocation Positive", "Allocation Negative"};
94 // return AllocateStatusStrings[];
95 }
96 
98  this->allocStatus = allocateStatus;
99 }
100 
101 void NFlowTableEntry::setTimeDeleted(const simtime_t& timDel) {
102  this->timeDeleted = timDel;
103 }
104 
106  this->fai = nfai;
107 }
108 
110  return flow;
111 }
112 
114  return this->fai == other.fai
115  && this->flow == other.flow
116  && this->allocStatus == other.allocStatus
117  && this->timeCreated == other.timeCreated;
118 }
119 
121  return allocStatus;
122 }
123 
125  return flow;
126 }
Class representing flow object with attributes from specs.
Definition: Flow.h:45
NFlowTableEntry::EAllocateStatus getAllocateStatus() const
simtime_t timeCreated
FAIBase * getFai() const
NFlowTableEntry()
long getAllocInvokeId() const
Gets allocation InvokeId Used inside M_CREATE(_R)(flow) messages.
Definition: Flow.cc:277
const simtime_t & getTimeDeleted() const
Flow * flow
std::string getAllocateStatusString() const
void setFai(FAIBase *nfai)
virtual ~NFlowTableEntry()
const Flow * getCFlow() const
const simtime_t & getTimeCreated() const
Flow * getFlow()
std::string infoDestination() const
Prints Flow destination information as string Outputs destination APNI, address, neigbor-address, PortId, CEP-Id.
Definition: Flow.cc:239
EAllocateStatus allocStatus
void setTimeDeleted(const simtime_t &timDel)
EAllocateStatus
std::string infoSource() const
Prints Flow source information as string Outputs source APNI, address, neigbor-address, PortId, CEP-Id.
Definition: Flow.cc:229
void setAllocateStatus(NFlowTableEntry::EAllocateStatus allocateStatus)
bool operator==(const NFlowTableEntry &other) const
std::string infoOther() const
Prints Flow create flow information and hop-cpunt as string.
Definition: Flow.cc:249
std::string infoQoS() const
Prints RA's QoSCube-id that FA choosed during Flow allocation phase Accompanied QoSParameters could b...
Definition: Flow.cc:258
std::ostream & operator<<(std::ostream &os, const NFlowTableEntry &fte)
simtime_t timeDeleted
FAIBase * fai
std::string info() const
long getDeallocInvokeId() const
Gets deallocation InvokeId Used inside M_DELETE(_R)(flow) messages.
Definition: Flow.cc:285