StdAir Logo  0.45.1
C++ Standard Airline IT Object Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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  assert (false);
26  }
27 
28  // ////////////////////////////////////////////////////////////////////
29  OnDDate::OnDDate (const Key_T& iKey)
30  : _key (iKey), _parent (NULL) {
31  }
32 
33  // ////////////////////////////////////////////////////////////////////
35  }
36 
37  // ////////////////////////////////////////////////////////////////////
38  std::string OnDDate::toString() const {
39  std::ostringstream oStr;
40  oStr << describeKey();
41  return oStr.str();
42  }
43 
44  // ////////////////////////////////////////////////////////////////////
46  const Inventory* lInventory_ptr =
47  static_cast<const Inventory*> (getParent());
48  assert (lInventory_ptr != NULL);
49  return lInventory_ptr->getAirlineCode();
50  }
51 
52  // ////////////////////////////////////////////////////////////////////
53  void OnDDate::
54  setDemandInformation (const CabinClassPairList_T& iCabinClassPairList,
55  const YieldDemandPair_T& iYieldDemandPair) {
56  std::ostringstream oStr;
57  for(CabinClassPairList_T::const_iterator itCCP = iCabinClassPairList.begin();
58  itCCP != iCabinClassPairList.end(); ++itCCP) {
59  oStr << itCCP->first << ":" << itCCP->second << ";";
60  }
61  std::string lCabinClassPath = oStr.str();
62  StringDemandStructMap_T::iterator it =
63  _classPathDemandMap.find(lCabinClassPath);
64  if (it == _classPathDemandMap.end()) {
65  const StringDemandStructPair_T lPairStringDemandChar (lCabinClassPath,
66  iYieldDemandPair);
67  _classPathDemandMap.insert (lPairStringDemandChar);
68  const StringCabinClassPair_T lStringCabinClassPair (lCabinClassPath,
69  iCabinClassPairList);
70  _stringCabinClassPairListMap.insert (lStringCabinClassPair);
71  } else {
72  it->second = iYieldDemandPair;
73  }
74  }
75 
76  // ////////////////////////////////////////////////////////////////////
77  void OnDDate::setTotalForecast (const CabinCode_T& iCabinCode,
78  const WTPDemandPair_T& iWTPDemandPair) {
79 
80  CabinForecastMap_T::iterator it =
81  _cabinForecastMap.find (iCabinCode);
82  if (it == _cabinForecastMap.end()) {
83  const CabinForecastPair_T lPairCabinForecastChar (iCabinCode,
84  iWTPDemandPair);
85  _cabinForecastMap.insert (lPairCabinForecastChar);
86  } else {
87  assert (false);
88  }
89  }
90 
91 }