1.00.26
C++ Standard Airline IT Object Library
Toggle main menu visibility
Loading...
Searching...
No Matches
Policy.cpp
Go to the documentation of this file.
1
// //////////////////////////////////////////////////////////////////////
2
// Import section
3
// //////////////////////////////////////////////////////////////////////
4
// STL
5
#include <sstream>
6
#include <cassert>
7
#include <iomanip>
8
#include <iostream>
9
//STDAIR
10
#include <
stdair/basic/BasConst_Inventory.hpp
>
11
#include <
stdair/bom/BomManager.hpp
>
12
#include <
stdair/bom/BookingClass.hpp
>
13
#include <
stdair/bom/BookingClassTypes.hpp
>
14
#include <
stdair/bom/Policy.hpp
>
15
16
namespace
stdair
{
17
18
// ////////////////////////////////////////////////////////////////////
19
Policy::Policy
() :
20
_key (
DEFAULT_POLICY_CODE
), _parent (NULL) {
21
assert (
false
);
22
}
23
24
// ////////////////////////////////////////////////////////////////////
25
Policy::Policy (
const
Policy& iPolicy)
26
: _key (
DEFAULT_POLICY_CODE
), _parent (NULL) {
27
assert (
false
);
28
}
29
30
// ////////////////////////////////////////////////////////////////////
31
Policy::Policy
(
const
Key_T
& iKey) : _key (iKey), _parent (NULL) {
32
}
33
34
// ////////////////////////////////////////////////////////////////////
35
Policy::~Policy
() {
36
}
37
38
// ////////////////////////////////////////////////////////////////////
39
std::string
Policy::toString
()
const
{
40
std::ostringstream oStr;
41
oStr <<
describeKey
();
42
43
oStr << std::fixed << std::setprecision (2)
44
<<
"; "
<< _demand
45
<<
"; "
<< _stdDev
46
<<
"; "
<< _yield << std::endl;
47
48
return
oStr.str();
49
}
50
51
// ////////////////////////////////////////////////////////////////////
52
const
BookingClassList_T
&
Policy::getBookingClassList
()
const
{
53
return
BomManager::getList<BookingClass>
(*
this
);
54
}
55
56
// ////////////////////////////////////////////////////////////////////
57
const
Revenue_T
Policy::getTotalRevenue
()
const
{
58
Revenue_T
oTotalRevenue = 0.0;
59
for
(YieldDemandMap_T::const_iterator itYD = _yieldDemandMap.begin();
60
itYD != _yieldDemandMap.end(); ++itYD) {
61
const
Yield_T
& lYield = itYD->first;
62
const
double
& lDemand = itYD->second;
63
oTotalRevenue += lYield*lDemand;
64
}
65
66
return
oTotalRevenue;
67
}
68
69
// ////////////////////////////////////////////////////////////////////
70
void
Policy::addYieldDemand
(
const
Yield_T
& iYield,
71
const
NbOfBookings_T
& iDemand) {
72
YieldDemandMap_T::iterator itYD = _yieldDemandMap.find (iYield);
73
if
(itYD == _yieldDemandMap.end()) {
74
bool
insert = _yieldDemandMap.insert (YieldDemandMap_T::value_type
75
(iYield, iDemand)).second;
76
assert (insert ==
true
);
77
}
else
{
78
NbOfBookings_T
& lDemand = itYD->second;
79
lDemand += iDemand;
80
}
81
}
82
83
}
BasConst_Inventory.hpp
BomManager.hpp
BookingClass.hpp
BookingClassTypes.hpp
Policy.hpp
stdair
Handle on the StdAir library context.
Definition
BasChronometer.cpp:9
stdair::NbOfBookings_T
NbOfRequests_T NbOfBookings_T
Definition
stdair_basic_types.hpp:104
stdair::BookingClassList_T
std::list< BookingClass * > BookingClassList_T
Definition
BookingClassTypes.hpp:20
stdair::Yield_T
double Yield_T
Definition
stdair_inventory_types.hpp:113
stdair::Revenue_T
double Revenue_T
Definition
stdair_basic_types.hpp:85
stdair::DEFAULT_POLICY_CODE
const PolicyCode_T DEFAULT_POLICY_CODE
stdair::BomManager::getList
static const BomHolder< OBJECT2 >::BomList_T & getList(const OBJECT1 &)
Definition
BomManager.hpp:140
stdair::Policy::addYieldDemand
void addYieldDemand(const Yield_T &, const NbOfBookings_T &)
Definition
Policy.cpp:70
stdair::Policy::getBookingClassList
const BookingClassList_T & getBookingClassList() const
Definition
Policy.cpp:52
stdair::Policy::Policy
Policy(const Key_T &)
Definition
Policy.cpp:31
stdair::Policy::describeKey
const std::string describeKey() const
Definition
Policy.hpp:136
stdair::Policy::~Policy
virtual ~Policy()
Definition
Policy.cpp:35
stdair::Policy::getTotalRevenue
const Revenue_T getTotalRevenue() const
Definition
Policy.cpp:57
stdair::Policy::toString
std::string toString() const
Definition
Policy.cpp:39
stdair::Policy::Key_T
PolicyKey Key_T
Definition
Policy.hpp:40
Generated for StdAir by
1.17.0