AirInv Logo  1.00.0
C++ Simulated Airline Inventory Management System library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FlightDateHelper.cpp
Go to the documentation of this file.
1 // //////////////////////////////////////////////////////////////////////
2 // Import section
3 // //////////////////////////////////////////////////////////////////////
4 // STL
5 #include <cassert>
6 // STDAIR
7 #include <stdair/basic/BasConst_Inventory.hpp>
8 #include <stdair/bom/BomManager.hpp>
9 #include <stdair/bom/FlightDate.hpp>
10 #include <stdair/bom/SegmentDate.hpp>
11 #include <stdair/bom/SegmentCabin.hpp>
12 #include <stdair/bom/LegCabin.hpp>
13 // AIRINV
17 
18 namespace AIRINV {
19 
20  // ////////////////////////////////////////////////////////////////////
22  updateBookingControls (stdair::FlightDate& ioFlightDate) {
23 
24  // Parse the segment-cabin list and build the pseudo bid price vector.
25  const stdair::SegmentDateList_T& lSDList =
26  stdair::BomManager::getList<stdair::SegmentDate> (ioFlightDate);
27  for (stdair::SegmentDateList_T::const_iterator itSD = lSDList.begin();
28  itSD != lSDList.end(); ++itSD) {
29  const stdair::SegmentDate* lSD_ptr = *itSD;
30  assert (lSD_ptr != NULL);
31 
32  //
33  const stdair::SegmentCabinList_T& lSCList =
34  stdair::BomManager::getList<stdair::SegmentCabin> (*lSD_ptr);
35  for (stdair::SegmentCabinList_T::const_iterator itSC = lSCList.begin();
36  itSC != lSCList.end(); ++itSC) {
37  stdair::SegmentCabin* lSC_ptr = *itSC;
38  assert (lSC_ptr != NULL);
39 
40  // Build the pseudo bid price vector for the segment-cabin.
42 
43  // Update the booking controls using the pseudo bid price vector.
46  }
47  }
48  }
49 
50  // ////////////////////////////////////////////////////////////////////
51  void FlightDateHelper::fillFromRouting(const stdair::FlightDate& iFlightDate){
52  const stdair::SegmentDateList_T& lSegmentDateList =
53  stdair::BomManager::getList<stdair::SegmentDate> (iFlightDate);
54 
55  // Browse the list of segment-dates and update each segment-date.
56  for (stdair::SegmentDateList_T::const_iterator itSegmentDate =
57  lSegmentDateList.begin();
58  itSegmentDate != lSegmentDateList.end(); ++itSegmentDate) {
59  stdair::SegmentDate* lCurrentSegmentDate_ptr = *itSegmentDate;
60  assert (lCurrentSegmentDate_ptr != NULL);
61  SegmentDateHelper::fillFromRouting (*lCurrentSegmentDate_ptr);
62  }
63  }
64 
65  // ////////////////////////////////////////////////////////////////////
67  updateAvailability (const stdair::FlightDate& iFlightDate,
68  const stdair::SegmentCabin& iSegmentCabin,
69  const stdair::PartySize_T& iNbOfBookings) {
70  // Update the commited space of the member leg-cabins.
71  const stdair::LegCabinList_T& lLegCabinList =
72  stdair::BomManager::getList<stdair::LegCabin> (iSegmentCabin);
73  for (stdair::LegCabinList_T::const_iterator itLegCabin =
74  lLegCabinList.begin();
75  itLegCabin != lLegCabinList.end(); ++itLegCabin) {
76  stdair::LegCabin* lLegCabin_ptr = *itLegCabin;
77  assert (lLegCabin_ptr != NULL);
78  lLegCabin_ptr->updateFromReservation (iNbOfBookings);
79  }
80 
81  // Update the availability pool of all the segment-cabin which belong to the
82  // same flight-date.
83  const stdair::CabinCode_T& lCabinCode = iSegmentCabin.getCabinCode();
84  FlightDateHelper::updateAvailabilityPool (iFlightDate, lCabinCode);
85 
86  // Recaculate the availability of all classes of the given cabin (code).
87  FlightDateHelper::recalculateAvailability (iFlightDate, lCabinCode);
88  }
89 
90  // ////////////////////////////////////////////////////////////////////
92  updateAvailabilityPool (const stdair::FlightDate& iFlightDate,
93  const stdair::CabinCode_T& iCabinCode){
94  const stdair::SegmentDateList_T& lSegmentDateList =
95  stdair::BomManager::getList<stdair::SegmentDate> (iFlightDate);
96  for (stdair::SegmentDateList_T::const_iterator itSegmentDate =
97  lSegmentDateList.begin(); itSegmentDate != lSegmentDateList.end();
98  ++itSegmentDate) {
99  const stdair::SegmentDate* lSegmentDate_ptr = *itSegmentDate;
100  assert (lSegmentDate_ptr != NULL);
101  stdair::SegmentCabin& lSegmentCabin =
102  stdair::BomManager::getObject<stdair::SegmentCabin> (*lSegmentDate_ptr,
103  iCabinCode);
104 
105  // Update the availability pool of the segment-cabin to the minimal
106  // availability pool of the member leg-cabins.
107  const stdair::LegCabinList_T& lLegCabinList =
108  stdair::BomManager::getList<stdair::LegCabin> (lSegmentCabin);
109  stdair::Availability_T lAvailabilityPool = stdair::MAXIMAL_AVAILABILITY;
110  for (stdair::LegCabinList_T::const_iterator itLegCabin =
111  lLegCabinList.begin();
112  itLegCabin != lLegCabinList.end(); ++itLegCabin) {
113  const stdair::LegCabin* lLegCabin_ptr = *itLegCabin;
114  assert (lLegCabin_ptr != NULL);
115  const stdair::Availability_T& lLegCabinAvailabilityPool =
116  lLegCabin_ptr->getAvailabilityPool();
117  if (lAvailabilityPool > lLegCabinAvailabilityPool) {
118  lAvailabilityPool = lLegCabinAvailabilityPool;
119  }
120  }
121  lSegmentCabin.setAvailabilityPool (lAvailabilityPool);
122  }
123  }
124 
125  // ////////////////////////////////////////////////////////////////////
126  void FlightDateHelper::
127  recalculateAvailability (const stdair::FlightDate& iFlightDate,
128  const stdair::CabinCode_T& iCabinCode){
129  const stdair::SegmentDateList_T& lSegmentDateList =
130  stdair::BomManager::getList<stdair::SegmentDate> (iFlightDate);
131  for (stdair::SegmentDateList_T::const_iterator itSegmentDate =
132  lSegmentDateList.begin(); itSegmentDate != lSegmentDateList.end();
133  ++itSegmentDate) {
134  const stdair::SegmentDate* lSegmentDate_ptr = *itSegmentDate;
135  assert (lSegmentDate_ptr != NULL);
136  stdair::SegmentCabin& lSegmentCabin =
137  stdair::BomManager::getObject<stdair::SegmentCabin> (*lSegmentDate_ptr,
138  iCabinCode);
140  }
141  }
142 
143  // ////////////////////////////////////////////////////////////////////
144  void FlightDateHelper::
145  recalculateAvailability (const stdair::FlightDate& iFlightDate) {
146  const stdair::SegmentDateList_T& lSegmentDateList =
147  stdair::BomManager::getList<stdair::SegmentDate> (iFlightDate);
148  for (stdair::SegmentDateList_T::const_iterator itSegmentDate =
149  lSegmentDateList.begin(); itSegmentDate != lSegmentDateList.end();
150  ++itSegmentDate) {
151  const stdair::SegmentDate* lSegmentDate_ptr = *itSegmentDate;
152  assert (lSegmentDate_ptr != NULL);
153  const stdair::SegmentCabinList_T& lSegmentCabinList =
154  stdair::BomManager::getList<stdair::SegmentCabin> (*lSegmentDate_ptr);
155  for (stdair::SegmentCabinList_T::const_iterator itSegmentCabin =
156  lSegmentCabinList.begin();
157  itSegmentCabin != lSegmentCabinList.end(); ++itSegmentCabin) {
158  const stdair::SegmentCabin* lSegmentCabin_ptr = *itSegmentCabin;
159  assert (lSegmentCabin_ptr != NULL);
160  SegmentCabinHelper::updateAvailabilities (*lSegmentCabin_ptr);
161  }
162  }
163  }
164 
165 }