AirInv Logo  0.1.2
C++ Simulated Airline Inventory Management System library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
InventoryManager.cpp
Go to the documentation of this file.
1 // //////////////////////////////////////////////////////////////////////
2 // Import section
3 // //////////////////////////////////////////////////////////////////////
4 // STL
5 #include <exception>
6 #include <algorithm> // To use min
7 // Boost
8 #include <boost/make_shared.hpp>
9 // StdAir
10 #include <stdair/basic/BasConst_Inventory.hpp>
11 #include <stdair/basic/BasConst_BomDisplay.hpp>
12 #include <stdair/bom/BomManager.hpp>
13 #include <stdair/bom/BomKeyManager.hpp>
14 #include <stdair/bom/BomRoot.hpp>
15 #include <stdair/bom/Inventory.hpp>
16 #include <stdair/bom/FlightDate.hpp>
17 #include <stdair/bom/SegmentDate.hpp>
18 #include <stdair/bom/SegmentCabin.hpp>
19 #include <stdair/bom/LegDate.hpp>
20 #include <stdair/bom/LegCabin.hpp>
21 #include <stdair/bom/FareFamily.hpp>
22 #include <stdair/bom/BookingClass.hpp>
23 #include <stdair/bom/GuillotineBlock.hpp>
24 #include <stdair/bom/TravelSolutionStruct.hpp>
25 #include <stdair/bom/FareOptionStruct.hpp>
26 #include <stdair/bom/EventStruct.hpp>
27 #include <stdair/bom/EventQueue.hpp>
28 #include <stdair/bom/SnapshotStruct.hpp>
29 #include <stdair/bom/RMEventStruct.hpp>
30 #include <stdair/factory/FacBomManager.hpp>
31 #include <stdair/factory/FacBom.hpp>
32 #include <stdair/service/Logger.hpp>
33 #include <stdair/bom/FareFamily.hpp> // Contains the definition of FareFamilyList_T
34 #include <stdair/bom/BookingClass.hpp> //
35 // AirInv
36 #include <airinv/AIRINV_Types.hpp>
41 
42 namespace AIRINV {
43 
44  // ////////////////////////////////////////////////////////////////////
45  void InventoryManager::
46  calculateAvailability (const stdair::BomRoot& iBomRoot,
47  stdair::TravelSolutionStruct& ioTravelSolution,
48  const stdair::PartnershipTechnique& iPartnershipTechnique) {
49 
50  const stdair::PartnershipTechnique::EN_PartnershipTechnique& lPartnershipTechnique =
51  iPartnershipTechnique.getTechnique();
52 
53  // Browse the list of segments and get the availability for the
54  // children classes.
55  const stdair::SegmentPath_T& lSegmentPath =
56  ioTravelSolution.getSegmentPath();
57  for (stdair::SegmentPath_T::const_iterator itSK = lSegmentPath.begin();
58  itSK != lSegmentPath.end(); ++itSK) {
59  const std::string& lSegmentKey = *itSK;
60  const stdair::InventoryKey lInvKey =
61  stdair::BomKeyManager::extractInventoryKey (lSegmentKey);
62  stdair::Inventory& lInventory =
63  stdair::BomManager::getObject<stdair::Inventory>(iBomRoot,
64  lInvKey.toString());
65 
66  switch (lPartnershipTechnique) {
67 
68  case stdair::PartnershipTechnique::NONE:{
69  InventoryHelper::calculateAvailability (lInventory, lSegmentKey,
70  ioTravelSolution);
71  break;
72  }
73  default:{
74  InventoryHelper::getYieldAndBidPrice (lInventory, lSegmentKey,
75  ioTravelSolution);
76  break;
77  }
78  }
79  }
80 
81  switch (lPartnershipTechnique) {
82  case stdair::PartnershipTechnique::NONE:{
83  // Compute the availabitliy for each fare option using the AU's.
84  calculateAvailabilityByAU (ioTravelSolution);
85  break;
86  }
87  case stdair::PartnershipTechnique::RAE_DA:
88  case stdair::PartnershipTechnique::RAE_YP:{
89  // 1. Compute the availability for each fare option using RAE
90  calculateAvailabilityByRAE (ioTravelSolution);
91  break;
92  }
93  case stdair::PartnershipTechnique::IBP_DA:
94  case stdair::PartnershipTechnique::IBP_YP:{
95  // 2. Compute the availability for each fare option using protective IBP
96  calculateAvailabilityByProtectiveIBP (ioTravelSolution);
97  break;
98  }
99  case stdair::PartnershipTechnique::IBP_YP_U:
100  case stdair::PartnershipTechnique::RMC:
101  case stdair::PartnershipTechnique::A_RMC:{
102  // 3. Compute the availability for each fare option using IBP
103  calculateAvailabilityByIBP (ioTravelSolution);
104  break;
105  }
106  default: {
107  assert (false);
108  break;
109  }
110  }
111  }
112 
113  // ////////////////////////////////////////////////////////////////////
114  void InventoryManager::
115  calculateAvailabilityByAU (stdair::TravelSolutionStruct& ioTravelSolution) {
116 
117  // MODIF: segment path string for availability display
118  std::ostringstream oStr;
119  const stdair::SegmentPath_T& lSP = ioTravelSolution.getSegmentPath();
120  for (stdair::SegmentPath_T::const_iterator itSP = lSP.begin();
121  itSP != lSP.end(); itSP++) {
122  oStr << *itSP << ";";
123  }
124 
125  // Browse the fare options
126  stdair::FareOptionList_T& lFOList = ioTravelSolution.getFareOptionListRef();
127  for (stdair::FareOptionList_T::iterator itFO = lFOList.begin();
128  itFO != lFOList.end(); ++itFO) {
129 
130  stdair::FareOptionStruct& lFO = *itFO;
131 
132  // Check the availability
133  const stdair::ClassList_StringList_T& lClassPath = lFO.getClassPath();
134 
135  const stdair::ClassAvailabilityMapHolder_T& lClassAvailabilityMapHolder =
136  ioTravelSolution.getClassAvailabilityMapHolder();
137 
138  // Initialise the flag stating whether the availability is enough
139  stdair::Availability_T lAvl =
140  std::numeric_limits<stdair::Availability_T>::max();
141 
142  // Sanity check: the travel solution must contain two lists,
143  // one for the booking class availabilities, the other for the
144  // fare options.
145  assert (lClassAvailabilityMapHolder.empty() == false
146  && lClassPath.empty() == false);
147 
148  // List of booking class availability maps (one map per segment)
149  stdair::ClassAvailabilityMapHolder_T::const_iterator itCAMH =
150  lClassAvailabilityMapHolder.begin();
151 
152  // List of fare options
153  stdair::ClassList_StringList_T::const_iterator itClassList =
154  lClassPath.begin();
155 
156  // Browse both lists at the same time, i.e., one element per segment
157  for (; itCAMH != lClassAvailabilityMapHolder.end()
158  && itClassList != lClassPath.end(); ++itCAMH, ++itClassList) {
159 
160  // Retrieve the booking class list for the current segment
161  const stdair::ClassList_String_T& lCurrentClassList = *itClassList;
162  assert (lCurrentClassList.size() > 0);
163 
164  // TODO: instead of just extracting the first booking class,
165  // perform a choice on the full list of classes.
166  // Extract one booking class key (class code)
167  stdair::ClassCode_T lFirstClass;
168  lFirstClass.append (lCurrentClassList, 0, 1);
169 
170  // Retrieve the booking class map for the current segment
171  const stdair::ClassAvailabilityMap_T& lClassAvlMap = *itCAMH;
172 
173  // Retrieve the availability of the chosen booking class
174  const stdair::ClassAvailabilityMap_T::const_iterator itClassAvl =
175  lClassAvlMap.find (lFirstClass);
176 
177  if (itClassAvl == lClassAvlMap.end()) {
178  // DEBUG
179  STDAIR_LOG_DEBUG ("No availability has been set up for the class '"
180  << lFirstClass << "'. Travel solution: "
181  << ioTravelSolution.display());
182  }
183  assert (itClassAvl != lClassAvlMap.end());
184 
185  const stdair::Availability_T& lCurrentAvl = itClassAvl->second;
186  if (lAvl > lCurrentAvl) {
187  lAvl = lCurrentAvl;
188  }
189  }
190 
191  lFO.setAvailability (lAvl);
192 
193  //MODIF: availability display
194  STDAIR_LOG_DEBUG ("Fare option " << lFO.describe() << ", "
195  << "Availability " << lFO.getAvailability() << ", "
196  << "Segment Path " << oStr.str());
197  }
198  }
199 
200  // \todo: the following code must be either re-written or removed.
201  // There is indeed a lot of code duplication.
202  // ////////////////////////////////////////////////////////////////////
203  void InventoryManager::
204  calculateAvailabilityByRAE (stdair::TravelSolutionStruct& ioTravelSolution) {
205 
206  std::ostringstream oStr;
207  const stdair::SegmentPath_T& lSP = ioTravelSolution.getSegmentPath();
208  for (stdair::SegmentPath_T::const_iterator itSP = lSP.begin();
209  itSP != lSP.end(); itSP++) {
210  oStr << *itSP << ";";
211  }
212 
213  //Retrieve bid price vector and yield maps
214  const stdair::ClassYieldMapHolder_T& lClassYieldMapHolder =
215  ioTravelSolution.getClassYieldMapHolder();
216  const stdair::ClassBpvMapHolder_T& lClassBpvMapHolder =
217  ioTravelSolution.getClassBpvMapHolder();
218 
219  //Retrieve the list of fare options and browse it
220  stdair::FareOptionList_T& lFOList = ioTravelSolution.getFareOptionListRef();
221  for (stdair::FareOptionList_T::iterator itFO = lFOList.begin();
222  itFO != lFOList.end(); ++itFO) {
223 
224  stdair::FareOptionStruct& lFO = *itFO;
225 
226  stdair::ClassYieldMapHolder_T::const_iterator itCYM =
227  lClassYieldMapHolder.begin();
228  stdair::ClassBpvMapHolder_T::const_iterator itCBPM =
229  lClassBpvMapHolder.begin();
230 
231  const stdair::ClassList_StringList_T& lClassPath = lFO.getClassPath();
232 
233 
234  // Sanity checks
235  assert (lClassPath.size() == lClassYieldMapHolder.size());
236  assert (lClassPath.size() == lClassBpvMapHolder.size());
237 
238  // Browse class path, class-yield maps, class-(bid price vector) maps.
239  // Each iteration corresponds to one segment.
240 
241  std::ostringstream oCPStr;
242  for (stdair::ClassList_StringList_T::const_iterator itCL =
243  lClassPath.begin();
244  itCL != lClassPath.end(); ++itCL, ++itCYM, ++itCBPM) {
245 
246  // Class path determination
247  if (itCL == lClassPath.begin()) {
248  oCPStr << *itCL;
249 
250  } else {
251  oCPStr << "-" << *itCL;
252  }
253 
254  const stdair::ClassList_String_T& lCL = *itCL;
255  stdair::ClassCode_T lCC;
256  lCC.append (lCL, 0, 1);
257 
258  const stdair::ClassYieldMap_T& lCYM = *itCYM;
259  stdair::ClassYieldMap_T::const_iterator itCCCYM = lCYM.find (lCC);
260  assert (itCCCYM != lCYM.end());
261 
262  const stdair::ClassBpvMap_T& lCBPM = *itCBPM;
263  stdair::ClassBpvMap_T::const_iterator itCCCBPM = lCBPM.find (lCC);
264  assert (itCCCBPM != lCBPM.end());
265 
266  const stdair::BidPriceVector_T* lBidPriceVector_ptr = itCCCBPM->second;
267  assert (lBidPriceVector_ptr != NULL);
268 
269  // Initialization of fare option availability
270  if (itCL == lClassPath.begin()) {
271  lFO.setAvailability (lBidPriceVector_ptr->size());
272  }
273 
274  // Availability update
275  if (lFO.getAvailability() > 0) {
276 
277  //Segment availability calculation
278  stdair::BidPriceVector_T lReverseBPV (lBidPriceVector_ptr->size());
279  std::reverse_copy (lBidPriceVector_ptr->begin(),
280  lBidPriceVector_ptr->end(),
281  lReverseBPV.begin());
282 
283  const stdair::YieldValue_T& lYield = itCCCYM->second;
284  stdair::BidPriceVector_T::const_iterator lBidPrice =
285  std::upper_bound (lReverseBPV.begin(), lReverseBPV.end(), lYield);
286 
287  const stdair::Availability_T lAvl = lBidPrice - lReverseBPV.begin();
288 
289  // Availability update
290  lFO.setAvailability (std::min (lFO.getAvailability(), lAvl));
291  }
292  }
293 
294  // DEBUG
295  STDAIR_LOG_DEBUG ("Fare option: " << lFO.describe() << ", "
296  << "Availability: " << lFO.getAvailability() << ", "
297  << "Segment Path: " << oStr.str() << ", ");
298  }
299  }
300 
301  // \todo: the following code must be either re-written or removed.
302  // There is indeed a lot of code duplication.
303  // ////////////////////////////////////////////////////////////////////
304  void InventoryManager::
305  calculateAvailabilityByIBP (stdair::TravelSolutionStruct& ioTravelSolution) {
306  std::ostringstream oStr;
307 
308  // Yield valuation coefficient for multi-segment travel solutions
309  double alpha = 1.0;
310 
311  const stdair::SegmentPath_T& lSP = ioTravelSolution.getSegmentPath();
312  for (stdair::SegmentPath_T::const_iterator itSP = lSP.begin();
313  itSP != lSP.end(); itSP++) {
314  oStr << *itSP << ";";
315  }
316 
317  //Retrieve bid price vector and yield maps
318  const stdair::ClassYieldMapHolder_T& lClassYieldMapHolder =
319  ioTravelSolution.getClassYieldMapHolder();
320  const stdair::ClassBpvMapHolder_T& lClassBpvMapHolder =
321  ioTravelSolution.getClassBpvMapHolder();
322 
323  // Retrieve the list of fare options and browse it
324  stdair::FareOptionList_T& lFOList = ioTravelSolution.getFareOptionListRef();
325  for (stdair::FareOptionList_T::iterator itFO = lFOList.begin();
326  itFO != lFOList.end(); ++itFO) {
327 
328  stdair::FareOptionStruct& lFO = *itFO;
329 
330  stdair::ClassYieldMapHolder_T::const_iterator itCYM =
331  lClassYieldMapHolder.begin();
332  stdair::ClassBpvMapHolder_T::const_iterator itCBPM =
333  lClassBpvMapHolder.begin();
334 
335  const stdair::ClassList_StringList_T& lClassPath = lFO.getClassPath();
336 
337  // Sanity checks
338  assert (lClassPath.size() == lClassYieldMapHolder.size());
339  assert (lClassPath.size() == lClassBpvMapHolder.size());
340 
341  // Yield is taken to be equal to fare (connecting flights)
342 
343  // \todo: take yield instead
344  stdair::YieldValue_T lTotalYield = lFO.getFare();
345  // Bid price initialisation
346  stdair::BidPrice_T lTotalBidPrice = 0;
347 
348  // Browse class path, class-yield maps, class-(bid price vector) maps.
349  // Each iteration corresponds to one segment.
350 
351  std::ostringstream oCPStr;
352  for (stdair::ClassList_StringList_T::const_iterator itCL =
353  lClassPath.begin();
354  itCL != lClassPath.end(); ++itCL, ++itCYM, ++itCBPM) {
355 
356  // Class path determination
357  if (itCL == lClassPath.begin()) {
358  oCPStr << *itCL;
359 
360  } else {
361  oCPStr << "-" << *itCL;
362  }
363 
364  const stdair::ClassList_String_T& lCL = *itCL;
365  stdair::ClassCode_T lCC;
366  lCC.append (lCL, 0, 1);
367 
368  const stdair::ClassYieldMap_T& lCYM = *itCYM;
369  stdair::ClassYieldMap_T::const_iterator itCCCYM = lCYM.find (lCC);
370  assert (itCCCYM != lCYM.end());
371 
372  const stdair::ClassBpvMap_T& lCBPM = *itCBPM;
373  stdair::ClassBpvMap_T::const_iterator itCCCBPM = lCBPM.find (lCC);
374  assert (itCCCBPM != lCBPM.end());
375 
376  const stdair::BidPriceVector_T* lBidPriceVector_ptr = itCCCBPM->second;
377  assert (lBidPriceVector_ptr != NULL);
378 
379  //Initialization of fare option availability
380  if (itCL == lClassPath.begin()) {
381  lFO.setAvailability (lBidPriceVector_ptr->size());
382  }
383 
384  // Availability update
385  if (lFO.getAvailability() > 0) {
386  //Segment availability calculation
387  stdair::BidPriceVector_T lReverseBPV (lBidPriceVector_ptr->size());
388  std::reverse_copy (lBidPriceVector_ptr->begin(),
389  lBidPriceVector_ptr->end(), lReverseBPV.begin());
390 
391  const stdair::YieldValue_T& lYield = itCCCYM->second;
392  stdair::BidPriceVector_T::const_iterator lBidPrice =
393  std::upper_bound (lReverseBPV.begin(), lReverseBPV.end(), lYield);
394 
395  const stdair::Availability_T lAvl = lBidPrice - lReverseBPV.begin();
396 
397  // Availability update
398  lFO.setAvailability (std::min(lFO.getAvailability(), lAvl));
399  }
400 
401  // Total bid price calculation
402  if (lBidPriceVector_ptr->size() > 0) {
403  lTotalBidPrice += lBidPriceVector_ptr->back();
404 
405  } else {
406  lTotalBidPrice = std::numeric_limits<stdair::BidPrice_T>::max();
407  }
408 
409  // Total yield calculation (has been replaced by total fare).
410  //lTotalYield += lYield;
411  }
412  // Multi-segment bid price control
413 
414  if (lClassPath.size() > 1) {
415  if (lFO.getAvailability() > 0) {
416  const stdair::Availability_T lAvl =
417  alpha * lTotalYield >= lTotalBidPrice;
418  lFO.setAvailability (lAvl * lFO.getAvailability());
419 
420  } else {
421  const stdair::Availability_T lAvl =
422  alpha * lTotalYield >= lTotalBidPrice;
423  lFO.setAvailability (lAvl);
424  }
425 
426  // DEBUG
427  STDAIR_LOG_DEBUG ("Class: " << oCPStr.str()
428  << ", " << "Yield: " << alpha*lTotalYield << ", "
429  << "Bid price: " << lTotalBidPrice << ", "
430  << "Remaining capacity: " << "Undefined" << " "
431  << "Segment date: " << oStr.str());
432  }
433 
434  // DEBUG
435  STDAIR_LOG_DEBUG ("Fare option " << lFO.describe() << ", "
436  << "Availability " << lFO.getAvailability() << ", "
437  << "Segment Path " << oStr.str() << ", ");
438  }
439  }
440 
441  // \todo: the following code must be either re-written or removed.
442  // There is indeed a lot of code duplication.
443  // ////////////////////////////////////////////////////////////////////
444  void InventoryManager::
445  calculateAvailabilityByProtectiveIBP (stdair::TravelSolutionStruct& ioTravelSolution) {
446  std::ostringstream oStr;
447 
448  // Yield valuation coefficient for multi-segment travel solutions
449  double alpha = 1.0;
450 
451  const stdair::SegmentPath_T& lSP = ioTravelSolution.getSegmentPath();
452  for (stdair::SegmentPath_T::const_iterator itSP = lSP.begin();
453  itSP != lSP.end(); itSP++) {
454  oStr << *itSP << ";";
455  }
456 
457  //Retrieve bid price vector and yield maps
458  const stdair::ClassYieldMapHolder_T& lClassYieldMapHolder =
459  ioTravelSolution.getClassYieldMapHolder();
460  const stdair::ClassBpvMapHolder_T& lClassBpvMapHolder =
461  ioTravelSolution.getClassBpvMapHolder();
462 
463  //Retrieve the list of fare options and browse it
464  stdair::FareOptionList_T& lFOList = ioTravelSolution.getFareOptionListRef();
465  for (stdair::FareOptionList_T::iterator itFO = lFOList.begin();
466  itFO != lFOList.end(); ++itFO) {
467 
468  stdair::FareOptionStruct& lFO = *itFO;
469 
470  stdair::ClassYieldMapHolder_T::const_iterator itCYM =
471  lClassYieldMapHolder.begin();
472  stdair::ClassBpvMapHolder_T::const_iterator itCBPM =
473  lClassBpvMapHolder.begin();
474 
475  const stdair::ClassList_StringList_T& lClassPath = lFO.getClassPath();
476 
477  // Sanity checks
478  assert (lClassPath.size() == lClassYieldMapHolder.size());
479  assert (lClassPath.size() == lClassBpvMapHolder.size());
480 
481  // Yield is taken to be equal to fare (connecting flights)
482  // TODO : take yield instead
483  stdair::YieldValue_T lTotalYield = lFO.getFare();
484  // Bid price initialisation
485  stdair::BidPrice_T lTotalBidPrice = 0;
486  // Maximal bid price initialisation
487  stdair::BidPrice_T lMaxBidPrice = 0;
488 
489  //Browse class path, class-yield maps, class-(bid price vector) maps.
490  //Each iteration corresponds to one segment.
491 
492  std::ostringstream oCPStr;
493  for (stdair::ClassList_StringList_T::const_iterator itCL =
494  lClassPath.begin();
495  itCL != lClassPath.end(); ++itCL, ++itCYM, ++itCBPM) {
496 
497  // Class path determination
498  if (itCL == lClassPath.begin()) {
499  oCPStr << *itCL;
500 
501  } else {
502  oCPStr << "-" << *itCL;
503  }
504 
505  const stdair::ClassList_String_T& lCL = *itCL;
506  stdair::ClassCode_T lCC;
507  lCC.append (lCL, 0, 1);
508 
509  const stdair::ClassYieldMap_T& lCYM = *itCYM;
510  stdair::ClassYieldMap_T::const_iterator itCCCYM = lCYM.find (lCC);
511  assert (itCCCYM != lCYM.end());
512 
513  const stdair::YieldValue_T& lYield = itCCCYM->second;
514  const stdair::ClassBpvMap_T& lCBPM = *itCBPM;
515  stdair::ClassBpvMap_T::const_iterator itCCCBPM = lCBPM.find (lCC);
516  assert (itCCCBPM != lCBPM.end());
517 
518  const stdair::BidPriceVector_T* lBidPriceVector_ptr = itCCCBPM->second;
519  assert (lBidPriceVector_ptr != NULL);
520 
521  // Initialization of fare option availability
522  if (itCL == lClassPath.begin()) {
523  lFO.setAvailability (lBidPriceVector_ptr->size());
524  }
525 
526  // Availability update
527  if (lFO.getAvailability() > 0) {
528 
529  //Segment availability calculation
530  stdair::BidPriceVector_T lReverseBPV (lBidPriceVector_ptr->size());
531  std::reverse_copy (lBidPriceVector_ptr->begin(),
532  lBidPriceVector_ptr->end(), lReverseBPV.begin());
533 
534  stdair::BidPriceVector_T::const_iterator lBidPrice =
535  std::upper_bound (lReverseBPV.begin(), lReverseBPV.end(), lYield);
536 
537  const stdair::Availability_T lAvl = lBidPrice - lReverseBPV.begin();
538 
539  // Availability update
540  lFO.setAvailability (std::min(lFO.getAvailability(), lAvl));
541 
542  }
543 
544  // Total bid price calculation
545  if (lBidPriceVector_ptr->size() > 0) {
546  lTotalBidPrice += lBidPriceVector_ptr->back();
547 
548  if (lMaxBidPrice < lBidPriceVector_ptr->back()) {
549  lMaxBidPrice = lBidPriceVector_ptr->back();
550  }
551 
552  } else {
553  lTotalBidPrice = std::numeric_limits<stdair::BidPrice_T>::max();
554  }
555 
556  // Total yield calculation (has been replaced by total fare).
557  //lTotalYield += lYield;
558  }
559  // Multi-segment bid price control
560 
561  // Protective IBP (maximin): guarantees the minimal yield for each airline
562  // Proration factors are all equal to 1/{number of partners}.
563 
564  lTotalBidPrice = std::max (lMaxBidPrice * lClassPath.size(),
565  lTotalBidPrice);
566 
567  if (lClassPath.size() > 1) {
568  if (lFO.getAvailability() > 0) {
569  const stdair::Availability_T lAvl =
570  alpha * lTotalYield >= lTotalBidPrice;
571  lFO.setAvailability (lAvl * lFO.getAvailability());
572 
573  } else {
574  const stdair::Availability_T lAvl =
575  alpha * lTotalYield >= lTotalBidPrice;
576  lFO.setAvailability (lAvl);
577  }
578 
579  // DEBUG
580  STDAIR_LOG_DEBUG ("Class: " << oCPStr.str()
581  << ", " << "Yield: " << alpha*lTotalYield << ", "
582  << "Bid price: " << lTotalBidPrice << ", "
583  << "Remaining capacity: " << "Undefined" << " "
584  << "Segment date: " << oStr.str());
585  }
586 
587  // DEBUG
588  STDAIR_LOG_DEBUG ("Fare option " << lFO.describe() << ", "
589  << "Availability " << lFO.getAvailability() << ", "
590  << "Segment Path " << oStr.str() << ", ");
591  }
592  }
593 
594  //MODIF
595  // ////////////////////////////////////////////////////////////////////
596  void InventoryManager::setDefaultBidPriceVector (stdair::BomRoot& ioBomRoot) {
597 
598  const stdair::InventoryList_T& lInvList =
599  stdair::BomManager::getList<stdair::Inventory> (ioBomRoot);
600  for (stdair::InventoryList_T::const_iterator itInv = lInvList.begin();
601  itInv != lInvList.end(); ++itInv) {
602  stdair::Inventory* lCurrentInv_ptr = *itInv;
603  assert (lCurrentInv_ptr != NULL);
604 
605  // Set the default bid price for own cabins.
606  setDefaultBidPriceVector (*lCurrentInv_ptr);
607 
608  // Check if the inventory contains images of partner inventories.
609  // If so, set the default bid price for their cabins.
610  if (stdair::BomManager::hasList<stdair::Inventory> (*lCurrentInv_ptr)) {
611  const stdair::InventoryList_T& lPartnerInvList =
612  stdair::BomManager::getList<stdair::Inventory> (*lCurrentInv_ptr);
613 
614  for (stdair::InventoryList_T::const_iterator itPartnerInv =
615  lPartnerInvList.begin();
616  itPartnerInv != lPartnerInvList.end(); ++itPartnerInv) {
617  stdair::Inventory* lCurrentPartnerInv_ptr = *itPartnerInv;
618  assert (lCurrentPartnerInv_ptr != NULL);
619 
620  setDefaultBidPriceVector (*lCurrentPartnerInv_ptr);
621  }
622  }
623  }
624  }
625 
626  // ////////////////////////////////////////////////////////////////////
627  void InventoryManager::
628  setDefaultBidPriceVector (stdair::Inventory& ioInventory) {
629 
630  const stdair::FlightDateList_T& lFlightDateList =
631  stdair::BomManager::getList<stdair::FlightDate> (ioInventory);
632  for (stdair::FlightDateList_T::const_iterator itFlightDate =
633  lFlightDateList.begin();
634  itFlightDate != lFlightDateList.end(); ++itFlightDate) {
635  stdair::FlightDate* lCurrentFlightDate_ptr = *itFlightDate;
636  assert (lCurrentFlightDate_ptr != NULL);
637 
638  // Check if the flight date holds a list of leg dates.
639  // If so retrieve it and initialise the bid price vectors of their cabins.
640  if (stdair::BomManager::hasList<stdair::LegDate> (*lCurrentFlightDate_ptr)) {
641  const stdair::LegDateList_T& lLegDateList =
642  stdair::BomManager::getList<stdair::LegDate> (*lCurrentFlightDate_ptr);
643  for (stdair::LegDateList_T::const_iterator itLegDate =
644  lLegDateList.begin();
645  itLegDate != lLegDateList.end(); ++itLegDate) {
646  stdair::LegDate* lCurrentLegDate_ptr = *itLegDate;
647  assert (lCurrentLegDate_ptr != NULL);
648 
649  const stdair::LegCabinList_T& lLegCabinList =
650  stdair::BomManager::getList<stdair::LegCabin> (*lCurrentLegDate_ptr);
651  for (stdair::LegCabinList_T::const_iterator itLegCabin =
652  lLegCabinList.begin();
653  itLegCabin != lLegCabinList.end(); ++itLegCabin) {
654  stdair::LegCabin* lCurrentLegCabin_ptr = *itLegCabin;
655  assert (lCurrentLegCabin_ptr != NULL);
656 
657  const stdair::CabinCapacity_T& lCabinCapacity =
658  lCurrentLegCabin_ptr->getPhysicalCapacity();
659  lCurrentLegCabin_ptr->emptyBidPriceVector();
660 
661  stdair::BidPriceVector_T& lBPV =
662  lCurrentLegCabin_ptr->getBidPriceVector();
663 
664  //for (stdair::CabinCapacity_T k = 0;k!=lCabinCapacity;k++) {lBPV.push_back(400 + 300/sqrt(k+1));}
665  for (stdair::CabinCapacity_T k = 0; k != lCabinCapacity; k++) {
666  lBPV.push_back (400);
667  }
668 
669  lCurrentLegCabin_ptr->setPreviousBidPrice (lBPV.back());
670  lCurrentLegCabin_ptr->setCurrentBidPrice (lBPV.back());
671  }
672  }
673  }
674  }
675  }
676 
677  // ////////////////////////////////////////////////////////////////////
678  bool InventoryManager::sell (stdair::Inventory& ioInventory,
679  const std::string& iSegmentDateKey,
680  const stdair::ClassCode_T& iClassCode,
681  const stdair::PartySize_T& iPartySize) {
682 
683  // Make the sale within the inventory.
684  return InventoryHelper::sell (ioInventory, iSegmentDateKey,
685  iClassCode, iPartySize);
686  }
687 
688  // ////////////////////////////////////////////////////////////////////
689  bool InventoryManager::cancel (stdair::Inventory& ioInventory,
690  const std::string& iSegmentDateKey,
691  const stdair::ClassCode_T& iClassCode,
692  const stdair::PartySize_T& iPartySize) {
693 
694  // Make the sale within the inventory.
695  return InventoryHelper::cancel (ioInventory, iSegmentDateKey,
696  iClassCode, iPartySize);
697  }
698 
699  // ////////////////////////////////////////////////////////////////////
700  void InventoryManager::
701  updateBookingControls (stdair::FlightDate& ioFlightDate) {
702 
703  // Forward the call to FlightDateHelper.
705  }
706 
707  // ////////////////////////////////////////////////////////////////////
708  void InventoryManager::takeSnapshots(const stdair::Inventory& iInventory,
709  const stdair::DateTime_T& iSnapshotTime){
710 
711  // Make the snapshots within the inventory
712  InventoryHelper::takeSnapshots (iInventory, iSnapshotTime);
713  }
714 
715  // ////////////////////////////////////////////////////////////////////
716  void InventoryManager::
717  createDirectAccesses (const stdair::BomRoot& iBomRoot) {
718 
719  // Browse the list of inventories and create direct accesses
720  // within each inventory.
721  const stdair::InventoryList_T& lInvList =
722  stdair::BomManager::getList<stdair::Inventory> (iBomRoot);
723  for (stdair::InventoryList_T::const_iterator itInv = lInvList.begin();
724  itInv != lInvList.end(); ++itInv) {
725  stdair::Inventory* lCurrentInv_ptr = *itInv;
726  assert (lCurrentInv_ptr != NULL);
727 
728  createDirectAccesses (*lCurrentInv_ptr);
729  }
730 
731  // Fill some attributes of segment-date with the routing legs.
733  }
734 
735  // ////////////////////////////////////////////////////////////////////
736  void InventoryManager::
737  createDirectAccesses (stdair::Inventory& ioInventory) {
738 
739  // Browse the list of flight-dates and create direct accesses
740  // within each flight-date.
741  const stdair::FlightDateList_T& lFlightDateList =
742  stdair::BomManager::getList<stdair::FlightDate> (ioInventory);
743  for (stdair::FlightDateList_T::const_iterator itFlightDate =
744  lFlightDateList.begin();
745  itFlightDate != lFlightDateList.end(); ++itFlightDate) {
746  stdair::FlightDate* lCurrentFlightDate_ptr = *itFlightDate;
747  assert (lCurrentFlightDate_ptr != NULL);
748 
749  createDirectAccesses (*lCurrentFlightDate_ptr);
750  }
751  }
752 
753  // ////////////////////////////////////////////////////////////////////
754  void InventoryManager::
755  createDirectAccesses (stdair::FlightDate& ioFlightDate) {
756 
757  // Browse the list of segment-dates and create direct accesses
758  // within each segment-date.
759  const stdair::SegmentDateList_T& lSegmentDateList =
760  stdair::BomManager::getList<stdair::SegmentDate> (ioFlightDate);
761  for (stdair::SegmentDateList_T::const_iterator itSegmentDate =
762  lSegmentDateList.begin();
763  itSegmentDate != lSegmentDateList.end(); ++itSegmentDate) {
764 
765  stdair::SegmentDate* lCurrentSegmentDate_ptr = *itSegmentDate;
766  assert (lCurrentSegmentDate_ptr != NULL);
767 
768  /*
769  * If the segment is just marketed by this carrier,
770  * retrieve the operating segment and call the createDirectAcces
771  * method on its parent (flight date).
772  */
773  const stdair::SegmentDate* lOperatingSegmentDate_ptr =
774  lCurrentSegmentDate_ptr->getOperatingSegmentDate ();
775  if (lOperatingSegmentDate_ptr != NULL) {
776  // Then get the (parent) flight date and create direct access.
777  stdair::FlightDate* lOperatingFlightDate_ptr =
778  stdair::BomManager::getParentPtr<stdair::FlightDate>(*lOperatingSegmentDate_ptr);
779  assert (lOperatingFlightDate_ptr != NULL);
780  createDirectAccesses (*lOperatingFlightDate_ptr);
781  } else {
782 
783  const stdair::AirportCode_T& lBoardingPoint =
784  lCurrentSegmentDate_ptr->getBoardingPoint();
785 
786  stdair::AirportCode_T currentBoardingPoint = lBoardingPoint;
787  const stdair::AirportCode_T& lOffPoint =
788  lCurrentSegmentDate_ptr->getOffPoint();
789 
790  // Add a sanity check so as to ensure that the loop stops. If
791  // there are more than MAXIMAL_NUMBER_OF_LEGS legs, there is
792  // an issue somewhere in the code (not in the parser, as the
793  // segments are derived from the legs thanks to the
794  // FlightPeriodStruct::buildSegments() method).
795  unsigned short i = 1;
796  while (currentBoardingPoint != lOffPoint
797  && i <= stdair::MAXIMAL_NUMBER_OF_LEGS_IN_FLIGHT) {
798  // Retrieve the (unique) LegDate getting that Boarding Point
799  stdair::LegDate& lLegDate = stdair::BomManager::
800  getObject<stdair::LegDate> (ioFlightDate, currentBoardingPoint);
801 
802  // Link the SegmentDate and LegDate together
803  stdair::FacBomManager::addToListAndMap (*lCurrentSegmentDate_ptr,
804  lLegDate);
805  stdair::FacBomManager::addToListAndMap (lLegDate,
806  *lCurrentSegmentDate_ptr);
807 
808  // Prepare the next iteration
809  currentBoardingPoint = lLegDate.getOffPoint();
810  ++i;
811  }
812  assert (i <= stdair::MAXIMAL_NUMBER_OF_LEGS_IN_FLIGHT);
813 
814  // Create the routing for the leg- and segment-cabins.
815  // At the same time, set the SegmentDate attributes derived from
816  // its routing legs (e.g., boarding and off dates).
817  createDirectAccesses (*lCurrentSegmentDate_ptr);
818  }
819  }
820  }
821 
822  // ////////////////////////////////////////////////////////////////////
823  void InventoryManager::
824  createDirectAccesses (stdair::SegmentDate& ioSegmentDate) {
825 
826  // Browse the list of segment-cabins and create direct accesses
827  // within each segment-cabin.
828  const stdair::SegmentCabinList_T& lSegmentCabinList =
829  stdair::BomManager::getList<stdair::SegmentCabin> (ioSegmentDate);
830  for (stdair::SegmentCabinList_T::const_iterator itSegmentCabin =
831  lSegmentCabinList.begin();
832  itSegmentCabin != lSegmentCabinList.end(); ++itSegmentCabin) {
833 
834  //
835  stdair::SegmentCabin* lCurrentSegmentCabin_ptr = *itSegmentCabin;
836  assert (lCurrentSegmentCabin_ptr != NULL);
837 
838  //
839  const stdair::CabinCode_T& lCabinCode =
840  lCurrentSegmentCabin_ptr->getCabinCode();
841 
842  // Iterate on the routing legs
843  const stdair::LegDateList_T& lLegDateList =
844  stdair::BomManager::getList<stdair::LegDate> (ioSegmentDate);
845  for (stdair::LegDateList_T::const_iterator itLegDate =
846  lLegDateList.begin();
847  itLegDate != lLegDateList.end(); ++itLegDate) {
848 
849  const stdair::LegDate* lCurrentLegDate_ptr = *itLegDate;
850  assert (lCurrentLegDate_ptr != NULL);
851 
852  // Retrieve the LegCabin getting the same class of service
853  // (cabin code) as the SegmentCabin.
854  stdair::LegCabin& lLegCabin = stdair::BomManager::
855  getObject<stdair::LegCabin> (*lCurrentLegDate_ptr, lCabinCode);
856 
867  stdair::FacBomManager::addToListAndMap (*lCurrentSegmentCabin_ptr,
868  lLegCabin,
869  lLegCabin.getFullerKey());
870 
881  stdair::FacBomManager::
882  addToListAndMap (lLegCabin, *lCurrentSegmentCabin_ptr,
883  lCurrentSegmentCabin_ptr->getFullerKey());
884  }
885  }
886  }
887 
888  // ////////////////////////////////////////////////////////////////////
889  void InventoryManager::
890  buildSimilarSegmentCabinSets (const stdair::BomRoot& iBomRoot) {
891  // Browse the list of inventories and create direct accesses
892  // within each inventory.
893  const stdair::InventoryList_T& lInvList =
894  stdair::BomManager::getList<stdair::Inventory> (iBomRoot);
895  for (stdair::InventoryList_T::const_iterator itInv = lInvList.begin();
896  itInv != lInvList.end(); ++itInv) {
897  stdair::Inventory* lCurrentInv_ptr = *itInv;
898  assert (lCurrentInv_ptr != NULL);
899 
900  buildSimilarSegmentCabinSets (*lCurrentInv_ptr);
901  }
902  }
903 
904  // ////////////////////////////////////////////////////////////////////
905  void InventoryManager::
906  buildSimilarSegmentCabinSets (stdair::Inventory& ioInventory) {
907  // For instance, we consider two flight-dates are
908  // similar if they have the same flight number and the same
909  // day-of-the-week departure.
910 
911  // Browse the segment-cabin list and build the sets of segment-cabin
912  // which have the same flight number and origin-destination
914 
915  // Browsing the flight-date list
916  const stdair::FlightDateList_T& lFlightDateList =
917  stdair::BomManager::getList<stdair::FlightDate> (ioInventory);
918  for (stdair::FlightDateList_T::const_iterator itFD= lFlightDateList.begin();
919  itFD != lFlightDateList.end(); ++itFD) {
920  const stdair::FlightDate* lFD_ptr = *itFD;
921  assert (lFD_ptr != NULL);
922  const stdair::FlightNumber_T& lFlightNumber = lFD_ptr->getFlightNumber();
923 
924  // Browsing the segment-date list and retrieve the departure
925  // date, the origine and the destination of the segment
926  const stdair::SegmentDateList_T& lSegmentDateList =
927  stdair::BomManager::getList<stdair::SegmentDate> (*lFD_ptr);
928  for (stdair::SegmentDateList_T::const_iterator itSD =
929  lSegmentDateList.begin(); itSD != lSegmentDateList.end(); ++itSD) {
930  const stdair::SegmentDate* lSD_ptr = *itSD;
931  assert (lSD_ptr != NULL);
932 
933  const stdair::Date_T& lDepartureDate = lSD_ptr->getBoardingDate();
934  const stdair::AirportCode_T& lOrigin = lSD_ptr->getBoardingPoint();
935  const stdair::AirportCode_T& lDestination = lSD_ptr->getOffPoint();
936 
937  // Browsing the segment-cabin list and retrieve the cabin code and
938  // build the corresponding key map.
939  const stdair::SegmentCabinList_T& lSegmentCabinList =
940  stdair::BomManager::getList<stdair::SegmentCabin> (*lSD_ptr);
941  for (stdair::SegmentCabinList_T::const_iterator itSC =
942  lSegmentCabinList.begin();
943  itSC != lSegmentCabinList.end(); ++itSC) {
944  stdair::SegmentCabin* lSC_ptr = *itSC;
945  assert (lSC_ptr != NULL);
946 
947  std::ostringstream oStr;
948  oStr << lFlightNumber << lDepartureDate.day_of_week()
949  << lOrigin << lDestination << lSC_ptr->getCabinCode();
950  const std::string lMapKey = oStr.str();
951 
952  // Add the segment cabin to the similar segment cabin set map.
953  SimilarSegmentCabinSetMap_T::iterator itSSCS = lSSCSM.find (lMapKey);
954  if (itSSCS == lSSCSM.end()) {
956  lDDSCMap.insert (DepartureDateSegmentCabinMap_T::
957  value_type (lDepartureDate, lSC_ptr));
958  lSSCSM.insert (SimilarSegmentCabinSetMap_T::
959  value_type (lMapKey, lDDSCMap));
960  } else {
961  DepartureDateSegmentCabinMap_T& lDDSCMap = itSSCS->second;
962  lDDSCMap.insert (DepartureDateSegmentCabinMap_T::
963  value_type (lDepartureDate, lSC_ptr));
964  }
965  }
966  }
967  }
968 
969  // Initialise the guillotine blocks.
970  stdair::GuillotineNumber_T lGuillotineNumber = 1;
971  for (SimilarSegmentCabinSetMap_T::const_iterator itSSCS = lSSCSM.begin();
972  itSSCS != lSSCSM.end(); ++itSSCS, ++lGuillotineNumber) {
973  const DepartureDateSegmentCabinMap_T& lDDSCMap = itSSCS->second;
974 
975  buildGuillotineBlock (ioInventory, lGuillotineNumber, lDDSCMap);
976  }
977  }
978 
979  // ////////////////////////////////////////////////////////////////////
980  void InventoryManager::
981  buildGuillotineBlock (stdair::Inventory& ioInventory,
982  const stdair::GuillotineNumber_T& iGuillotineNumber,
983  const DepartureDateSegmentCabinMap_T& iDDSCMap) {
984  // Build an empty guillotine block.
985  const stdair::GuillotineBlockKey lKey (iGuillotineNumber);
986  stdair::GuillotineBlock& lGuillotineBlock =
987  stdair::FacBom<stdair::GuillotineBlock>::instance().create (lKey);
988  stdair::FacBomManager::addToListAndMap (ioInventory, lGuillotineBlock);
989 
990  // Build the value type index map.
991  DepartureDateSegmentCabinMap_T::const_iterator itDDSC = iDDSCMap.begin();
992  assert (itDDSC != iDDSCMap.end());
993  const stdair::SegmentCabin* lSegmentCabin_ptr = itDDSC->second;
994 
995  // Browse the booking class list and build the value type for the classes
996  // as well as for the cabin (Q-equivalent).
997  stdair::ValueTypeIndexMap_T lValueTypeIndexMap;
998  stdair::BlockIndex_T lBlockIndex = 0;
999  std::ostringstream lSCMapKey;
1000  lSCMapKey << stdair::DEFAULT_SEGMENT_CABIN_VALUE_TYPE
1001  << lSegmentCabin_ptr->describeKey();
1002  lValueTypeIndexMap.insert (stdair::ValueTypeIndexMap_T::
1003  value_type (lSCMapKey.str(), lBlockIndex));
1004  ++lBlockIndex;
1005 
1006  // Browse the booking class list
1007  const stdair::BookingClassList_T& lBCList =
1008  stdair::BomManager::getList<stdair::BookingClass>(*lSegmentCabin_ptr);
1009  for (stdair::BookingClassList_T::const_iterator itBC= lBCList.begin();
1010  itBC != lBCList.end(); ++itBC) {
1011  const stdair::BookingClass* lBookingClass_ptr = *itBC;
1012  assert (lBookingClass_ptr != NULL);
1013  lValueTypeIndexMap.
1014  insert (stdair::ValueTypeIndexMap_T::
1015  value_type(lBookingClass_ptr->describeKey(),lBlockIndex));
1016  ++lBlockIndex;
1017  }
1018 
1019  // Build the segment-cabin index map
1020  stdair::SegmentCabinIndexMap_T lSegmentCabinIndexMap;
1021  stdair::BlockNumber_T lBlockNumber = 0;
1022  for (; itDDSC != iDDSCMap.end(); ++itDDSC, ++lBlockNumber) {
1023  stdair::SegmentCabin* lCurrentSC_ptr = itDDSC->second;
1024  assert (lCurrentSC_ptr != NULL);
1025  lSegmentCabinIndexMap.
1026  insert (stdair::SegmentCabinIndexMap_T::value_type (lCurrentSC_ptr,
1027  lBlockNumber));
1028 
1029  // Added the guillotine to the segment-cabin.
1030  lCurrentSC_ptr->setGuillotineBlock (lGuillotineBlock);
1031  }
1032 
1033  // Initialise the guillotine block.
1034  lGuillotineBlock.initSnapshotBlocks(lSegmentCabinIndexMap,
1035  lValueTypeIndexMap);
1036  }
1037 
1038  // ////////////////////////////////////////////////////////////////////
1039  void InventoryManager::initSnapshotEvents (const stdair::Date_T& iStartDate,
1040  const stdair::Date_T& iEndDate,
1041  stdair::EventQueue& ioQueue) {
1042  const stdair::Duration_T lTimeZero (0, 0, 0);
1043  const stdair::Duration_T lOneDayDuration (24, 0, 0);
1044  const stdair::DateTime_T lBeginSnapshotTime (iStartDate, lTimeZero);
1045  const stdair::DateTime_T lEndSnapshotTime (iEndDate, lTimeZero);
1046 
1047  // TODO: remove the defaut airline code.
1048  stdair::NbOfEvents_T lNbOfSnapshots = 0.0;
1049  for (stdair::DateTime_T lSnapshotTime = lBeginSnapshotTime;
1050  lSnapshotTime < lEndSnapshotTime; lSnapshotTime += lOneDayDuration) {
1051  // Create the snapshot event structure
1052  stdair::SnapshotPtr_T lSnapshotStruct =
1053  boost::make_shared<stdair::SnapshotStruct>(stdair::DEFAULT_AIRLINE_CODE,
1054  lSnapshotTime);
1055  // Create the event structure
1056  stdair::EventStruct lEventStruct (stdair::EventType::SNAPSHOT,
1057  lSnapshotStruct);
1058 
1066  ioQueue.addEvent (lEventStruct);
1067  ++lNbOfSnapshots;
1068  }
1069 
1070  ioQueue.addStatus (stdair::EventType::SNAPSHOT, lNbOfSnapshots);
1071  }
1072 
1073  // ////////////////////////////////////////////////////////////////////
1074  void InventoryManager::
1075  initRMEvents (const stdair::Inventory& iInventory,
1076  stdair::RMEventList_T& ioRMEventList,
1077  const stdair::Date_T& iStartDate,
1078  const stdair::Date_T& iEndDate) {
1079  const stdair::Duration_T lTimeZero (0, 0, 0);
1080  const stdair::Duration_T lTime (0, 0, 10);
1081  const stdair::Duration_T lOneDayDuration (24, 0, 0);
1082  const stdair::DateTime_T lEarliestEventTime (iStartDate, lTimeZero);
1083  const stdair::DateTime_T lLatestEventTime (iEndDate, lTimeZero);
1084 
1085  const stdair::AirlineCode_T& lAirlineCode = iInventory.getAirlineCode();
1086 
1087  // Browse the list of flight-dates and initialise the RM events for
1088  // each flight-date.
1089  const stdair::FlightDateList_T& lFDList =
1090  stdair::BomManager::getList<stdair::FlightDate> (iInventory);
1091  for (stdair::FlightDateList_T::const_iterator itFD = lFDList.begin();
1092  itFD != lFDList.end(); ++itFD) {
1093  const stdair::FlightDate* lFD_ptr = *itFD;
1094  assert (lFD_ptr != NULL);
1095 
1096  // Retrive the departure date and initialise the RM events with
1097  // the data collection points of the inventory.
1098  const stdair::Date_T& lDepartureDate = lFD_ptr->getDepartureDate();
1099  const stdair::DateTime_T lDepatureDateTime (lDepartureDate, lTime);
1100  for (stdair::DCPList_T::const_iterator itDCP =
1101  stdair::DEFAULT_DCP_LIST.begin();
1102  itDCP != stdair::DEFAULT_DCP_LIST.end(); ++itDCP) {
1103  const stdair::DCP_T& lDCP = *itDCP;
1104 
1105  // Create the event time and check if it is in the validate interval
1106  const stdair::DateTime_T lEventTime =
1107  lDepatureDateTime - lOneDayDuration * lDCP;
1108  if (lEventTime >= lEarliestEventTime && lEventTime <= lLatestEventTime){
1109  const stdair::KeyDescription_T lKeyDes = lFD_ptr->describeKey();
1110  stdair::RMEventStruct lRMEvent (lAirlineCode, lKeyDes, lEventTime);
1111  ioRMEventList.push_back (lRMEvent);
1112  }
1113  }
1114  }
1115  }
1116 
1117  // ////////////////////////////////////////////////////////////////////
1118  void InventoryManager::
1119  addRMEventsToEventQueue (stdair::EventQueue& ioQueue,
1120  stdair::RMEventList_T& ioRMEventList) {
1121  // Browse the RM event list and add them to the queue.
1122  for (stdair::RMEventList_T::iterator itRMEvent = ioRMEventList.begin();
1123  itRMEvent != ioRMEventList.end(); ++itRMEvent) {
1124  stdair::RMEventStruct& lRMEvent = *itRMEvent;
1125  stdair::RMEventPtr_T lRMEventPtr =
1126  boost::make_shared<stdair::RMEventStruct> (lRMEvent);
1127  stdair::EventStruct lEventStruct (stdair::EventType::RM, lRMEventPtr);
1128  ioQueue.addEvent (lEventStruct);
1129  }
1130 
1131  // Update the status of RM events within the event queue.
1132  ioQueue.updateStatus (stdair::EventType::RM, ioRMEventList.size());
1133  }
1134 }