Download this file

FAITableEntry.cc    122 lines (102 with data), 3.9 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see http://www.gnu.org/licenses/.
//
#include "FAITableEntry.h"
FAITableEntry::FAITableEntry() : fai(NULL), flow(NULL), allocStatus(this->UNKNOWN), timeCreated(0), timeLastActive(0) {
}
FAITableEntry::FAITableEntry(Flow* nflow): fai(NULL), allocStatus(this->UNKNOWN) {
this->flow = nflow;
this->timeCreated = simTime();
this->timeLastActive = simTime();
}
FAITableEntry::FAITableEntry(FAIBase* nfai): flow(NULL), allocStatus(this->UNKNOWN) {
this->fai = nfai;
this->timeCreated = simTime();
this->timeLastActive = simTime();
}
FAITableEntry::~FAITableEntry() {
this->fai = NULL;
this->flow = NULL;
allocStatus = this->UNKNOWN;
timeCreated = 0;
timeLastActive = 0;
}
std::string FAITableEntry::info() const {
std::ostringstream os;
os << "STATUS: " << this->getAllocateStatusString() << endl;
if ( this->getFai() )
os << "FAI> " << *(this->getFai()) << endl;
if ( this->getCFlow() ) {
os << this->getCFlow()->infoSource() << endl;
os << this->getCFlow()->infoDestination() << endl;
os << this->getCFlow()->infoOther() << endl;
os << this->getCFlow()->infoQoS() << endl;
}
os << "Created at: " << this->getTimeCreated()
<< "\tLast active at: " << this->getTimeLastActive() << endl;
return os.str();
}
std::ostream& operator <<(std::ostream& os, const FAITableEntry& fte) {
return os << fte.info();
}
FAIBase* FAITableEntry::getFai() const {
return fai;
}
const simtime_t& FAITableEntry::getTimeCreated() const {
return timeCreated;
}
const simtime_t& FAITableEntry::getTimeLastActive() const {
return timeLastActive;
}
std::string FAITableEntry::getAllocateStatusString() const {
switch(this->allocStatus)
{
case ALLOC_PEND: return "allocation pending";
case ALLOC_POSI: return "allocation positive";
case ALLOC_NEGA: return "allocation negative";
case ALLOC_ERR: return "allocation error";
case DEALLOC_PEND: return "deallocation pending";
case DEALLOCATED: return "deallocated";
case DEINST_PEND: return "deinstantiation pending";
case DEINSTANTIATED:return "deinstantiated";
case FORWARDED: return "allocation forwarded";
default: return "UNKNOWN";
}
// static std::string AllocateStatusStrings[] = {"Pending", "Allocation Positive", "Allocation Negative"};
// return AllocateStatusStrings[];
}
void FAITableEntry::setAllocateStatus(AllocateStatus allocateStatus) {
this->allocStatus = allocateStatus;
}
void FAITableEntry::setTimeLastActive(const simtime_t& timeLastActive) {
this->timeLastActive = timeLastActive;
}
void FAITableEntry::setFai(FAIBase* nfai) {
this->fai = nfai;
}
const Flow* FAITableEntry::getCFlow() const {
return flow;
}
bool FAITableEntry::operator ==(const FAITableEntry& other) const {
return this->fai == other.fai
&& this->flow == other.flow
&& this->allocStatus == other.allocStatus
&& this->timeCreated == other.timeCreated;
}
FAITableEntry::AllocateStatus FAITableEntry::getAllocateStatus() const {
return allocStatus;
}
Flow* FAITableEntry::getFlow() {
return flow;
}