StdAir Logo  1.00.12
C++ Standard Airline IT Object Library
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
14#include <stdair/bom/Policy.hpp>
15
16namespace 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 // ////////////////////////////////////////////////////////////////////
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 // ////////////////////////////////////////////////////////////////////
53 return BomManager::getList<BookingClass> (*this);
54 }
55
56 // ////////////////////////////////////////////////////////////////////
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}
Handle on the StdAir library context.
NbOfRequests_T NbOfBookings_T
std::list< BookingClass * > BookingClassList_T
double Revenue_T
const PolicyCode_T DEFAULT_POLICY_CODE
void addYieldDemand(const Yield_T &, const NbOfBookings_T &)
Definition: Policy.cpp:70
const BookingClassList_T & getBookingClassList() const
Definition: Policy.cpp:52
const std::string describeKey() const
Definition: Policy.hpp:136
virtual ~Policy()
Definition: Policy.cpp:35
const Revenue_T getTotalRevenue() const
Definition: Policy.cpp:57
std::string toString() const
Definition: Policy.cpp:39
Key of a given policy, made of a policy code.
Definition: PolicyKey.hpp:26