StdAir Logo  1.00.3
C++ Standard Airline IT Object Library
OnDDate.cpp
Go to the documentation of this file.
1 // //////////////////////////////////////////////////////////////////////
2 // Import section
3 // //////////////////////////////////////////////////////////////////////
4 // STL
5 #include <cassert>
6 #include <sstream>
7 // StdAir
11 #include <stdair/bom/Inventory.hpp>
12 #include <stdair/bom/OnDDate.hpp>
13 
14 namespace stdair {
15 
16  // ////////////////////////////////////////////////////////////////////
17  OnDDate::OnDDate()
18  : _key (DEFAULT_OND_STRING_LIST), _parent (NULL) {
19  assert (false);
20  }
21 
22  // ////////////////////////////////////////////////////////////////////
23  OnDDate::OnDDate (const OnDDate& iOnDDate)
24  : _key (iOnDDate.getKey()), _parent (NULL) {
25  }
26 
27  // ////////////////////////////////////////////////////////////////////
28  OnDDate::OnDDate (const Key_T& iKey)
29  : _key (iKey), _parent (NULL) {
30  }
31 
32  // ////////////////////////////////////////////////////////////////////
34  }
35 
36  // ////////////////////////////////////////////////////////////////////
37  std::string OnDDate::toString() const {
38  std::ostringstream oStr;
39  oStr << describeKey();
40  return oStr.str();
41  }
42 
43  // ////////////////////////////////////////////////////////////////////
45  const Inventory* lInventory_ptr =
46  static_cast<const Inventory*> (getParent());
47  assert (lInventory_ptr != NULL);
48  return lInventory_ptr->getAirlineCode();
49  }
50 
51  // ////////////////////////////////////////////////////////////////////
52  void OnDDate::
53  setDemandInformation (const CabinClassPairList_T& iCabinClassPairList,
54  const YieldDemandPair_T& iYieldDemandPair) {
55  std::ostringstream oStr;
56  for(CabinClassPairList_T::const_iterator itCCP = iCabinClassPairList.begin();
57  itCCP != iCabinClassPairList.end(); ++itCCP) {
58  oStr << itCCP->first << ":" << itCCP->second << ";";
59  }
60  std::string lCabinClassPath = oStr.str();
61  StringDemandStructMap_T::iterator it =
62  _classPathDemandMap.find(lCabinClassPath);
63  if (it == _classPathDemandMap.end()) {
64  const StringDemandStructPair_T lPairStringDemandChar (lCabinClassPath,
65  iYieldDemandPair);
66  _classPathDemandMap.insert (lPairStringDemandChar);
67  const StringCabinClassPair_T lStringCabinClassPair (lCabinClassPath,
68  iCabinClassPairList);
69  _stringCabinClassPairListMap.insert (lStringCabinClassPair);
70  } else {
71  it->second = iYieldDemandPair;
72  }
73  }
74 
75  // ////////////////////////////////////////////////////////////////////
76  void OnDDate::setTotalForecast (const CabinCode_T& iCabinCode,
77  const WTPDemandPair_T& iWTPDemandPair) {
78 
79  CabinForecastMap_T::iterator it =
80  _cabinForecastMap.find (iCabinCode);
81  if (it == _cabinForecastMap.end()) {
82  const CabinForecastPair_T lPairCabinForecastChar (iCabinCode,
83  iWTPDemandPair);
84  _cabinForecastMap.insert (lPairCabinForecastChar);
85  } else {
86  assert (false);
87  }
88  }
89 
90 }
const AirlineCode_T & getAirlineCode() const
Definition: OnDDate.cpp:44
std::pair< std::string, CabinClassPairList_T > StringCabinClassPair_T
std::pair< CabinCode_T, WTPDemandPair_T > CabinForecastPair_T
std::string CabinCode_T
std::pair< Yield_T, MeanStdDevPair_T > YieldDemandPair_T
const std::string describeKey() const
Definition: OnDDate.hpp:167
Handle on the StdAir library context.
void setTotalForecast(const CabinCode_T &, const WTPDemandPair_T &)
Definition: OnDDate.cpp:76
std::list< CabinClassPair_T > CabinClassPairList_T
CabinForecastMap_T _cabinForecastMap
Definition: OnDDate.hpp:242
std::string AirlineCode_T
const AirlineCode_T & getAirlineCode() const
Definition: Inventory.hpp:56
std::pair< WTP_T, MeanStdDevPair_T > WTPDemandPair_T
StringCabinClassPairListMap_T _stringCabinClassPairListMap
Definition: OnDDate.hpp:237
Key of a given O&D-date, made of a list of OnD strings. a OnD string contains the airline code...
Definition: OnDDateKey.hpp:23
virtual ~OnDDate()
Definition: OnDDate.cpp:33
std::string toString() const
Definition: OnDDate.cpp:37
BomAbstract *const getParent() const
Definition: OnDDate.hpp:55
Class representing the actual attributes for an airline inventory.
Definition: Inventory.hpp:34
void setDemandInformation(const CabinClassPairList_T &, const YieldDemandPair_T &)
Definition: OnDDate.cpp:53
const OnDStringList_T DEFAULT_OND_STRING_LIST
Definition: BasConst.cpp:736
std::pair< std::string, YieldDemandPair_T > StringDemandStructPair_T
StringDemandStructMap_T _classPathDemandMap
Definition: OnDDate.hpp:232