StdAir Logo  0.45.1
C++ Standard Airline IT Object Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BomDisplay.cpp
Go to the documentation of this file.
1 
5 // //////////////////////////////////////////////////////////////////////
6 // Import section
7 // //////////////////////////////////////////////////////////////////////
8 // STL
9 #include <cassert>
10 #include <ostream>
11 // StdAir
14 #include <stdair/bom/BomRoot.hpp>
16 #include <stdair/bom/Inventory.hpp>
18 #include <stdair/bom/LegDate.hpp>
20 #include <stdair/bom/LegCabin.hpp>
31 #include <stdair/bom/Bucket.hpp>
35 #include <stdair/bom/OnDDate.hpp>
36 
37 namespace stdair {
38 
44  struct FlagSaver {
45  public:
47  FlagSaver (std::ostream& oStream)
48  : _oStream (oStream), _streamFlags (oStream.flags()) {
49  }
50 
52  ~FlagSaver() {
53  // Reset formatting flags of the given output stream
54  _oStream.flags (_streamFlags);
55  }
56 
57  private:
59  std::ostream& _oStream;
61  std::ios::fmtflags _streamFlags;
62  };
63 
64  // ////////////////////////////////////////////////////////////////////
65  std::string BomDisplay::csvDisplay (const EventQueue& iEventQueue) {
66  std::ostringstream oStream;
67 
71  oStream << std::endl;
72  oStream << "==============================================================="
73  << std::endl;
74  oStream << "EventQueue: " << iEventQueue.describeKey() << std::endl;
75  oStream << "==============================================================="
76  << std::endl;
77 
78  return oStream.str();
79  }
80 
81  // ////////////////////////////////////////////////////////////////////
82  void BomDisplay::list (std::ostream& oStream, const BomRoot& iBomRoot,
83  const AirlineCode_T& iAirlineCode,
84  const FlightNumber_T& iFlightNumber) {
85  // Save the formatting flags for the given STL output stream
86  FlagSaver flagSaver (oStream);
87 
88  // Check whether there are Inventory objects
89  if (BomManager::hasList<Inventory> (iBomRoot) == false) {
90  return;
91  }
92 
93  // Browse the inventories
94  unsigned short invIdx = 1;
95  const InventoryList_T& lInventoryList =
96  BomManager::getList<Inventory> (iBomRoot);
97  for (InventoryList_T::const_iterator itInv = lInventoryList.begin();
98  itInv != lInventoryList.end(); ++itInv, ++invIdx) {
99  const Inventory* lInv_ptr = *itInv;
100  assert (lInv_ptr != NULL);
101 
102  // Retrieve the inventory key (airline code)
103  const AirlineCode_T& lAirlineCode = lInv_ptr->getAirlineCode();
104 
105  // Display only the requested inventories
106  if (iAirlineCode == "all" || iAirlineCode == lAirlineCode) {
107  // Get the list of flight-dates for that inventory
108  list (oStream, *lInv_ptr, invIdx, iFlightNumber);
109  }
110  }
111  }
112 
113  // ////////////////////////////////////////////////////////////////////
114  void BomDisplay::list (std::ostream& oStream, const Inventory& iInventory,
115  const unsigned short iInventoryIndex,
116  const FlightNumber_T& iFlightNumber) {
117  // Save the formatting flags for the given STL output stream
118  FlagSaver flagSaver (oStream);
119 
120  // Check whether there are FlightDate objects
121  if (BomManager::hasMap<FlightDate> (iInventory) == false) {
122  return;
123  }
124 
133  //
134  const AirlineCode_T& lAirlineCode = iInventory.getAirlineCode();
135  oStream << iInventoryIndex << ". " << lAirlineCode << std::endl;
136 
137  // Browse the flight-dates
138  unsigned short lCurrentFlightNumber = 0;
139  unsigned short flightNumberIdx = 0;
140  unsigned short departureDateIdx = 1;
141  const FlightDateMap_T& lFlightDateList =
142  BomManager::getMap<FlightDate> (iInventory);
143  for (FlightDateMap_T::const_iterator itFD = lFlightDateList.begin();
144  itFD != lFlightDateList.end(); ++itFD, ++departureDateIdx) {
145  const FlightDate* lFD_ptr = itFD->second;
146  assert (lFD_ptr != NULL);
147 
148  // Retrieve the key of the flight-date
149  const FlightNumber_T& lFlightNumber = lFD_ptr->getFlightNumber();
150  const Date_T& lFlightDateDate = lFD_ptr->getDepartureDate();
151 
152  // Display only the requested flight number
153  if (iFlightNumber == 0 || iFlightNumber == lFlightNumber) {
154  //
155  if (lCurrentFlightNumber != lFlightNumber) {
156  lCurrentFlightNumber = lFlightNumber;
157  ++flightNumberIdx; departureDateIdx = 1;
158  oStream << " " << iInventoryIndex << "." << flightNumberIdx << ". "
159  << lAirlineCode << lFlightNumber << std::endl;
160  }
161 
162  oStream << " " << iInventoryIndex << "." << flightNumberIdx
163  << "." << departureDateIdx << ". "
164  << lAirlineCode << lFlightNumber << " / " << lFlightDateDate
165  << std::endl;
166  }
167  }
168  }
169 
170  // ////////////////////////////////////////////////////////////////////
171  void BomDisplay::listAirportPairDateRange (std::ostream& oStream,
172  const BomRoot& iBomRoot) {
173  // Save the formatting flags for the given STL output stream
174  FlagSaver flagSaver (oStream);
175 
176  // Check whether there are AirportPair objects
177  if (BomManager::hasList<AirportPair> (iBomRoot) == false) {
178  return;
179  }
180 
181  const AirportPairList_T& lAirportPairList =
182  BomManager::getList<AirportPair> (iBomRoot);
183  for (AirportPairList_T::const_iterator itAir = lAirportPairList.begin();
184  itAir != lAirportPairList.end(); ++itAir ) {
185  const AirportPair* lAir_ptr = *itAir;
186  assert (lAir_ptr != NULL);
187 
188  // Check whether there are date-period objects
189  assert (BomManager::hasList<DatePeriod> (*lAir_ptr) == true);
190 
191  // Browse the date-period objects
192  const DatePeriodList_T& lDatePeriodList =
193  BomManager::getList<DatePeriod> (*lAir_ptr);
194 
195  for (DatePeriodList_T::const_iterator itDP = lDatePeriodList.begin();
196  itDP != lDatePeriodList.end(); ++itDP) {
197  const DatePeriod* lDP_ptr = *itDP;
198  assert (lDP_ptr != NULL);
199 
200  // Display the date-period object
201  oStream << lAir_ptr->describeKey()
202  <<" / " << lDP_ptr->describeKey() << std::endl;
203  }
204 
205  }
206  }
207 
208  // ////////////////////////////////////////////////////////////////////
209  void BomDisplay::csvDisplay (std::ostream& oStream,
210  const BomRoot& iBomRoot) {
211  // Save the formatting flags for the given STL output stream
212  FlagSaver flagSaver (oStream);
213 
217  oStream << std::endl;
218  oStream << "==============================================================="
219  << std::endl;
220  oStream << "BomRoot: " << iBomRoot.describeKey() << std::endl;
221  oStream << "==============================================================="
222  << std::endl;
223 
224  // Check whether there are Inventory objects
225  if (BomManager::hasList<Inventory> (iBomRoot) == false) {
226  return;
227  }
228 
229  // Browse the inventories
230  const InventoryList_T& lInventoryList =
231  BomManager::getList<Inventory> (iBomRoot);
232  for (InventoryList_T::const_iterator itInv = lInventoryList.begin();
233  itInv != lInventoryList.end(); ++itInv) {
234  const Inventory* lInv_ptr = *itInv;
235  assert (lInv_ptr != NULL);
236 
237  // Display the inventory
238  csvDisplay (oStream, *lInv_ptr);
239  }
240  }
241 
242  // ////////////////////////////////////////////////////////////////////
243  void BomDisplay::csvDisplay (std::ostream& oStream,
244  const Inventory& iInventory) {
245  // Save the formatting flags for the given STL output stream
246  FlagSaver flagSaver (oStream);
247 
251  oStream << "+++++++++++++++++++++++++++++++++++++++++++++++++" << std::endl;
252  oStream << "Inventory: " << iInventory.describeKey() << std::endl;
253  oStream << "+++++++++++++++++++++++++++++++++++++++++++++++++" << std::endl;
254 
255  // Check whether there are FlightDate objects
256  if (BomManager::hasList<FlightDate> (iInventory) == false) {
257  return;
258  }
259 
260  // Browse the flight-dates
261  const FlightDateList_T& lFlightDateList =
262  BomManager::getList<FlightDate> (iInventory);
263  for (FlightDateList_T::const_iterator itFD = lFlightDateList.begin();
264  itFD != lFlightDateList.end(); ++itFD) {
265  const FlightDate* lFD_ptr = *itFD;
266  assert (lFD_ptr != NULL);
267 
268  // Display the flight-date
269  csvDisplay (oStream, *lFD_ptr);
270  }
271 
272  // Check if the inventory contains a list of partners
273 
274  if (BomManager::hasList<Inventory> (iInventory)){
275 
276  // Browse the partner's inventories
277  const InventoryList_T& lPartnerInventoryList =
278  BomManager::getList<Inventory> (iInventory);
279 
280  for (InventoryList_T::const_iterator itInv = lPartnerInventoryList.begin();
281  itInv != lPartnerInventoryList.end(); ++itInv) {
282 
283  oStream << "-------------------------------------------------" << std::endl;
284  oStream << "Partner inventory:" << std::endl;
285  oStream << "-------------------------------------------------" << std::endl;
286  const Inventory* lInv_ptr = *itInv;
287  assert (lInv_ptr != NULL);
288 
289  // Display the inventory
290  csvDisplay (oStream, *lInv_ptr);
291  }
292  oStream << "******************************************" << std::endl;
293  oStream << std::endl;
294  }
295 
296  // Check if the inventory contains a list of O&D dates
297 
298  if (BomManager::hasList<OnDDate> (iInventory)){
299 
300  //Browse the O&Ds
301  const OnDDateList_T& lOnDDateList =
302  BomManager::getList<OnDDate> (iInventory);
303 
304  for (OnDDateList_T::const_iterator itOnD = lOnDDateList.begin();
305  itOnD != lOnDDateList.end(); ++itOnD) {
306  oStream << "******************************************" << std::endl;
307  oStream << "O&D-Date:" << std::endl;
308  oStream << "----------" << std::endl;
309  oStream << "Airline, Date, Origin-Destination, Segments, " << std::endl;
310 
311  const OnDDate* lOnDDate_ptr = *itOnD;
312  assert (lOnDDate_ptr != NULL);
313 
314  // Display the O&D date
315  csvDisplay (oStream, *lOnDDate_ptr);
316  }
317  oStream << "******************************************" << std::endl;
318  }
319  }
320 
321  // ////////////////////////////////////////////////////////////////////
322  void BomDisplay::csvDisplay (std::ostream& oStream,
323  const OnDDate& iOnDDate) {
324  // Save the formatting flags for the given STL output stream
325  FlagSaver flagSaver (oStream);
326 
330  const AirlineCode_T& lAirlineCode = iOnDDate.getAirlineCode();
331  const Date_T& lDate = iOnDDate.getDate();
332  const AirportCode_T& lOrigin = iOnDDate.getOrigin();
333  const AirportCode_T& lDestination = iOnDDate.getDestination();
334 
335  oStream << lAirlineCode <<", " << lDate << ", "<< lOrigin << "-"
336  << lDestination << ", " << iOnDDate.describeKey() << ", "
337  << std::endl;
338 
339  const StringDemandStructMap_T& lDemandInfoMap =
340  iOnDDate.getDemandInfoMap();
341 
342  // Check if the map contains information.
343  const bool isInfoMapEmpty = lDemandInfoMap.empty();
344  if (isInfoMapEmpty) {
345  return;
346  }
347  assert (lDemandInfoMap.empty() ==false);
348 
349  oStream << "----------" << std::endl;
350  oStream << "Cabin-Class path, Demand mean, Demand std dev, Yield, "
351  << std::endl;
352 
353  for (StringDemandStructMap_T::const_iterator itDI = lDemandInfoMap.begin();
354  itDI != lDemandInfoMap.end(); ++itDI) {
355 
356  const std::string& lCabinClassPath = itDI->first;
357  const YieldDemandPair_T lYieldDemandPair =
358  itDI->second;
359  const Yield_T lYield = lYieldDemandPair.first;
360  const MeanStdDevPair_T lMeanStdDevPair =
361  lYieldDemandPair.second;
362  const MeanValue_T lDemandMean = lMeanStdDevPair.first;
363  const StdDevValue_T lDemandStdDev = lMeanStdDevPair.second;
364 
365  oStream << lCabinClassPath << ", "
366  << lDemandMean << ", "
367  << lDemandStdDev << ", "
368  << lYield << ", "
369  << std::endl;
370  }
371 
372  }
373 
374  // ////////////////////////////////////////////////////////////////////
375  void BomDisplay::csvDisplay (std::ostream& oStream,
376  const FlightDate& iFlightDate) {
377  // Save the formatting flags for the given STL output stream
378  FlagSaver flagSaver (oStream);
379 
383  const AirlineCode_T& lAirlineCode = iFlightDate.getAirlineCode();
384  oStream << "******************************************" << std::endl;
385  oStream << "FlightDate: " << lAirlineCode << iFlightDate.describeKey()
386  << std::endl;
387  oStream << "******************************************" << std::endl;
388 
389  //
390  csvSegmentDateDisplay (oStream, iFlightDate);
391  //
392  csvLegDateDisplay (oStream, iFlightDate);
393 
394  //
395  csvLegCabinDisplay (oStream, iFlightDate);
396 
397  //
398  csvBucketDisplay (oStream, iFlightDate);
399 
400  //
401  csvFareFamilyDisplay (oStream, iFlightDate);
402 
403  //
404  csvBookingClassDisplay (oStream, iFlightDate);
405  }
406 
407  // ////////////////////////////////////////////////////////////////////
408  void BomDisplay::csvLegDateDisplay (std::ostream& oStream,
409  const FlightDate& iFlightDate) {
410  // Save the formatting flags for the given STL output stream
411  FlagSaver flagSaver (oStream);
412 
418  oStream << "******************************************" << std::endl;
419  oStream << "Leg-Dates:" << std::endl
420  << "----------" << std::endl;
421  oStream << "Flight, Leg, BoardDate, BoardTime, "
422  << "OffDate, OffTime, Date Offset, Time Offset, Elapsed, "
423  << "Distance, Capacity, " << std::endl;
424 
425  // Retrieve the key of the flight-date
426  const AirlineCode_T& lAirlineCode = iFlightDate.getAirlineCode();
427  const FlightNumber_T& lFlightNumber = iFlightDate.getFlightNumber();
428  const Date_T& lFlightDateDate = iFlightDate.getDepartureDate();
429 
430  // Check whether there are LegDate objects
431  if (BomManager::hasList<LegDate> (iFlightDate) == false) {
432  return;
433  }
434 
435  // Browse the leg-dates
436  const LegDateList_T& lLegDateList =
437  BomManager::getList<LegDate> (iFlightDate);
438  for (LegDateList_T::const_iterator itLD = lLegDateList.begin();
439  itLD != lLegDateList.end(); ++itLD) {
440  const LegDate* lLD_ptr = *itLD;
441  assert (lLD_ptr != NULL);
442 
443  oStream << lAirlineCode << lFlightNumber << " "
444  << lFlightDateDate << ", ";
445 
446  oStream << lLD_ptr->getBoardingPoint() << "-"
447  << lLD_ptr->getOffPoint() << ", "
448  << lLD_ptr->getBoardingDate() << ", "
449  << lLD_ptr->getBoardingTime() << ", "
450  << lLD_ptr->getOffDate() << ", "
451  << lLD_ptr->getOffTime() << ", "
452  << lLD_ptr->getElapsedTime() << ", "
453  << lLD_ptr->getDateOffset().days() << ", "
454  << lLD_ptr->getTimeOffset() << ", "
455  << lLD_ptr->getDistance() << ", "
456  << lLD_ptr->getCapacity() << ", " << std::endl;
457  }
458  oStream << "******************************************" << std::endl;
459  }
460 
461  // ////////////////////////////////////////////////////////////////////
462  void BomDisplay::csvSegmentDateDisplay (std::ostream& oStream,
463  const FlightDate& iFlightDate) {
464  // Save the formatting flags for the given STL output stream
465  FlagSaver flagSaver (oStream);
466 
470  oStream << "******************************************" << std::endl;
471  oStream << "SegmentDates:" << std::endl
472  << "----------" << std::endl;
473  oStream << "Flight, Segment, Date"
474  << std::endl;
475 
476  // Retrieve the key of the flight-date
477  const AirlineCode_T& lAirlineCode = iFlightDate.getAirlineCode();
478  const FlightNumber_T& lFlightNumber = iFlightDate.getFlightNumber();
479  const Date_T& lFlightDateDate = iFlightDate.getDepartureDate();
480 
481  // Check whether there are SegmentDate objects
482  if (BomManager::hasList<SegmentDate> (iFlightDate) == false) {
483  return;
484  }
485 
486  // Browse the segment-dates
487  const SegmentDateList_T& lSegmentDateList =
488  BomManager::getList<SegmentDate> (iFlightDate);
489  for (SegmentDateList_T::const_iterator itSD = lSegmentDateList.begin();
490  itSD != lSegmentDateList.end(); ++itSD) {
491  const SegmentDate* lSD_ptr = *itSD;
492  assert (lSD_ptr != NULL);
493 
494  // Retrieve the key of the segment-date, as well as its dates
495  const Date_T& lSegmentDateDate = lSD_ptr->getBoardingDate();
496  const AirportCode_T& lBoardPoint = lSD_ptr->getBoardingPoint();
497  const AirportCode_T& lOffPoint = lSD_ptr->getOffPoint();
498  oStream << lAirlineCode << lFlightNumber << " " << lFlightDateDate << ", "
499  << lBoardPoint << "-" << lOffPoint << ", " << lSegmentDateDate << std::endl;
500 
501  // Check if the current segment has corresponding marketing segments.
502  const bool isMarketingSDListEmpty = BomManager::hasList<SegmentDate>(*lSD_ptr);
503  if (isMarketingSDListEmpty == false) {
504  //
505  const SegmentDateList_T& lMarketingSDList = BomManager::getList<SegmentDate>(*lSD_ptr);
506 
507  oStream << " *** Marketed by ";
508  for (SegmentDateList_T::const_iterator itMarketingSD = lMarketingSDList.begin();
509  itMarketingSD != lMarketingSDList.end(); ++itMarketingSD) {
510  SegmentDate* lMarketingSD_ptr = *itMarketingSD;
511  FlightDate* lMarketingFD_ptr = BomManager::getParentPtr<FlightDate>(*lMarketingSD_ptr);
512  Inventory* lMarketingInv_ptr = BomManager::getParentPtr<Inventory>(*lMarketingFD_ptr);
513  oStream << lMarketingInv_ptr->toString() << lMarketingFD_ptr->toString() <<" * ";
514  }
515  }
516 
517  // Check if the current segment is operated by another segment date.
518  const SegmentDate* lOperatingSD_ptr = lSD_ptr->getOperatingSegmentDate ();
519  if (lOperatingSD_ptr != NULL) {
520 
521  const FlightDate* lOperatingFD_ptr = BomManager::getParentPtr<FlightDate>(*lOperatingSD_ptr);
522  const Inventory* lOperatingInv_ptr = BomManager::getParentPtr<Inventory>(*lOperatingFD_ptr);
523  oStream << " *** Operated by " << lOperatingInv_ptr->toString()
524  << lOperatingFD_ptr->toString() << std::endl;
525  }
526 
527  oStream << std::endl;
528  }
529  }
530 
531  // ////////////////////////////////////////////////////////////////////
532  void BomDisplay::csvLegCabinDisplay (std::ostream& oStream,
533  const FlightDate& iFlightDate) {
534  // Save the formatting flags for the given STL output stream
535  FlagSaver flagSaver (oStream);
536 
540  oStream << "******************************************" << std::endl;
541  oStream << "LegCabins:" << std::endl
542  << "----------" << std::endl;
543  oStream << "Flight, Leg, Cabin, "
544  << "OffedCAP, PhyCAP, RgdADJ, AU, UPR, SS, Staff, WL, Group, "
545  << "CommSpace, AvPool, Avl, NAV, GAV, ACP, ETB, BidPrice, "
546  << std::endl;
547 
548  // Retrieve the key of the flight-date
549  const AirlineCode_T& lAirlineCode = iFlightDate.getAirlineCode();
550  const FlightNumber_T& lFlightNumber = iFlightDate.getFlightNumber();
551  const Date_T& lFlightDateDate = iFlightDate.getDepartureDate();
552 
553  // Check whether there are LegDate objects
554  if (BomManager::hasList<LegDate> (iFlightDate) == false) {
555  return;
556  }
557 
558  // Browse the leg-dates
559  const LegDateList_T& lLegDateList =
560  BomManager::getList<LegDate> (iFlightDate);
561  for (LegDateList_T::const_iterator itLD = lLegDateList.begin();
562  itLD != lLegDateList.end(); ++itLD) {
563  const LegDate* lLD_ptr = *itLD;
564  assert (lLD_ptr != NULL);
565 
566  // Retrieve the key of the leg-date, as well as its off point
567  const Date_T& lLegDateDate = lLD_ptr->getBoardingDate();
568  const AirportCode_T& lBoardPoint = lLD_ptr->getBoardingPoint();
569  const AirportCode_T& lOffPoint = lLD_ptr->getOffPoint();
570 
571  // Browse the leg-cabins
572  const LegCabinList_T& lLegCabinList =
573  BomManager::getList<LegCabin> (*lLD_ptr);
574  for (LegCabinList_T::const_iterator itLC = lLegCabinList.begin();
575  itLC != lLegCabinList.end(); ++itLC) {
576  const LegCabin* lLC_ptr = *itLC;
577  assert (lLC_ptr != NULL);
578 
579  oStream << lAirlineCode << lFlightNumber << " "
580  << lFlightDateDate << ", ";
581 
582  oStream << lBoardPoint << "-" << lOffPoint
583  << " " << lLegDateDate << ", ";
584 
585  oStream << lLC_ptr->getCabinCode() << ", ";
586 
587  oStream << lLC_ptr->getOfferedCapacity() << ", "
588  << lLC_ptr->getPhysicalCapacity() << ", "
589  << lLC_ptr->getRegradeAdjustment() << ", "
590  << lLC_ptr->getAuthorizationLevel() << ", "
591  << lLC_ptr->getUPR() << ", "
592  << lLC_ptr->getSoldSeat() << ", "
593  << lLC_ptr->getStaffNbOfSeats() << ", "
594  << lLC_ptr->getWLNbOfSeats() << ", "
595  << lLC_ptr->getGroupNbOfSeats() << ", "
596  << lLC_ptr->getCommittedSpace() << ", "
597  << lLC_ptr->getAvailabilityPool() << ", "
598  << lLC_ptr->getAvailability() << ", "
599  << lLC_ptr->getNetAvailability() << ", "
600  << lLC_ptr->getGrossAvailability() << ", "
601  << lLC_ptr->getAvgCancellationPercentage() << ", "
602  << lLC_ptr->getETB() << ", "
603  << lLC_ptr->getCurrentBidPrice() << ", "
604  << std::endl;
605  }
606  }
607  oStream << "******************************************" << std::endl;
608  }
609 
610  // ////////////////////////////////////////////////////////////////////
611  void BomDisplay::csvSegmentCabinDisplay (std::ostream& oStream,
612  const FlightDate& iFlightDate) {
613  // Save the formatting flags for the given STL output stream
614  FlagSaver flagSaver (oStream);
615 
619  }
620 
621  // ////////////////////////////////////////////////////////////////////
622  void BomDisplay::csvFareFamilyDisplay (std::ostream& oStream,
623  const FlightDate& iFlightDate) {
624  // Save the formatting flags for the given STL output stream
625  FlagSaver flagSaver (oStream);
626 
631  oStream << "******************************************" << std::endl;
632  oStream << "SegmentCabins:" << std::endl
633  << "--------------" << std::endl;
634  oStream << "Flight, Segment, Cabin, FF, Bkgs, MIN, UPR, "
635  << "CommSpace, AvPool, BP, " << std::endl;
636 
637  // Retrieve the key of the flight-date
638  const AirlineCode_T& lAirlineCode = iFlightDate.getAirlineCode();
639  const FlightNumber_T& lFlightNumber = iFlightDate.getFlightNumber();
640  const Date_T& lFlightDateDate = iFlightDate.getDepartureDate();
641 
642  // Check whether there are SegmentDate objects
643  if (BomManager::hasList<SegmentDate> (iFlightDate) == false) {
644  return;
645  }
646 
647  // Browse the segment-dates
648  const SegmentDateList_T& lSegmentDateList =
649  BomManager::getList<SegmentDate> (iFlightDate);
650  for (SegmentDateList_T::const_iterator itSD = lSegmentDateList.begin();
651  itSD != lSegmentDateList.end(); ++itSD) {
652  const SegmentDate* lSD_ptr = *itSD;
653  assert (lSD_ptr != NULL);
654 
655  // Retrieve the key of the segment-date, as well as its dates
656  const Date_T& lSegmentDateDate = lSD_ptr->getBoardingDate();
657  const AirportCode_T& lBoardPoint = lSD_ptr->getBoardingPoint();
658  const AirportCode_T& lOffPoint = lSD_ptr->getOffPoint();
659 
660  // Browse the segment-cabins
661  const SegmentCabinList_T& lSegmentCabinList =
662  BomManager::getList<SegmentCabin> (*lSD_ptr);
663  for (SegmentCabinList_T::const_iterator itSC = lSegmentCabinList.begin();
664  itSC != lSegmentCabinList.end(); ++itSC) {
665  const SegmentCabin* lSC_ptr = *itSC;
666  assert (lSC_ptr != NULL);
667 
668  // Retrieve the key of the segment-cabin
669  const CabinCode_T& lCabinCode = lSC_ptr->getCabinCode();
670 
671  // Check whether there are fare family objects
672  if (BomManager::hasList<FareFamily> (*lSC_ptr) == false) {
673  continue;
674  }
675 
676  // Browse the fare families
677  const FareFamilyList_T& lFareFamilyList =
678  BomManager::getList<FareFamily> (*lSC_ptr);
679  for (FareFamilyList_T::const_iterator itFF = lFareFamilyList.begin();
680  itFF != lFareFamilyList.end(); ++itFF) {
681  const FareFamily* lFF_ptr = *itFF;
682  assert (lFF_ptr != NULL);
683 
684  oStream << lAirlineCode << lFlightNumber << " "
685  << lFlightDateDate << ", ";
686 
687  oStream << lBoardPoint << "-" << lOffPoint << " "
688  << lSegmentDateDate << ", ";
689 
690  oStream << lCabinCode << ", " << lFF_ptr->getFamilyCode() << ", ";
691 
692  oStream << lSC_ptr->getBookingCounter() << ", "
693  << lSC_ptr->getMIN() << ", "
694  << lSC_ptr->getUPR() << ", "
695  << lSC_ptr->getCommittedSpace() << ", "
696  << lSC_ptr->getAvailabilityPool() << ", "
697  << lSC_ptr->getCurrentBidPrice() << ", "
698  << std::endl;
699  }
700  }
701  }
702  oStream << "******************************************" << std::endl;
703  }
704 
705  // ////////////////////////////////////////////////////////////////////
706  void BomDisplay::csvBucketDisplay (std::ostream& oStream,
707  const FlightDate& iFlightDate) {
708  // Save the formatting flags for the given STL output stream
709  FlagSaver flagSaver (oStream);
710 
714  oStream << "******************************************" << std::endl;
715  oStream << "Buckets:" << std::endl
716  << "--------" << std::endl;
717  oStream << "Flight, Leg, Cabin, Yield, AU/SI, SS, AV, "
718  << std::endl;
719 
720  // Retrieve the key of the flight-date
721  const AirlineCode_T& lAirlineCode = iFlightDate.getAirlineCode();
722  const FlightNumber_T& lFlightNumber = iFlightDate.getFlightNumber();
723  const Date_T& lFlightDateDate = iFlightDate.getDepartureDate();
724 
725  // Check whether there are LegDate objects
726  if (BomManager::hasList<LegDate> (iFlightDate) == false) {
727  return;
728  }
729 
730  // Browse the leg-dates
731  const LegDateList_T& lLegDateList =
732  BomManager::getList<LegDate> (iFlightDate);
733  for (LegDateList_T::const_iterator itLD = lLegDateList.begin();
734  itLD != lLegDateList.end(); ++itLD) {
735  const LegDate* lLD_ptr = *itLD;
736  assert (lLD_ptr != NULL);
737 
738  // Retrieve the key of the leg-date, as well as its off point
739  const Date_T& lLegDateDate = lLD_ptr->getBoardingDate();
740  const AirportCode_T& lBoardPoint = lLD_ptr->getBoardingPoint();
741  const AirportCode_T& lOffPoint = lLD_ptr->getOffPoint();
742 
743  // Browse the leg-cabins
744  const LegCabinList_T& lLegCabinList =
745  BomManager::getList<LegCabin> (*lLD_ptr);
746  for (LegCabinList_T::const_iterator itLC = lLegCabinList.begin();
747  itLC != lLegCabinList.end(); ++itLC) {
748  const LegCabin* lLC_ptr = *itLC;
749  assert (lLC_ptr != NULL);
750 
751  // Check whether there are bucket objects
752  if (BomManager::hasList<Bucket> (*lLC_ptr) == false) {
753  continue;
754  }
755 
756  // Retrieve the key of the leg-cabin
757  const CabinCode_T& lCabinCode = lLC_ptr->getCabinCode();
758 
759  // Browse the buckets
760  const BucketList_T& lBucketList = BomManager::getList<Bucket> (*lLC_ptr);
761  for (BucketList_T::const_iterator itBuck = lBucketList.begin();
762  itBuck != lBucketList.end(); ++itBuck) {
763  const Bucket* lBucket_ptr = *itBuck;
764  assert (lBucket_ptr != NULL);
765 
766  oStream << lAirlineCode << lFlightNumber << " "
767  << lFlightDateDate << ", ";
768 
769  oStream << lBoardPoint << "-" << lOffPoint << " "
770  << lLegDateDate << ", " << lCabinCode << ", ";
771 
772  oStream << lBucket_ptr->getYieldRangeUpperValue() << ", "
773  << lBucket_ptr->getSeatIndex() << ", "
774  << lBucket_ptr->getSoldSeats() << ", "
775  << lBucket_ptr->getAvailability() << ", ";
776  oStream << std::endl;
777  }
778  }
779  }
780  oStream << "******************************************" << std::endl;
781  }
782 
783  // ////////////////////////////////////////////////////////////////////
784  void BomDisplay::csvBookingClassDisplay (std::ostream& oStream,
785  const BookingClass& iBookingClass,
786  const std::string& iLeadingString) {
787  // Save the formatting flags for the given STL output stream
788  FlagSaver flagSaver (oStream);
789 
796  oStream << iLeadingString << iBookingClass.getClassCode();
797 
798  if (iBookingClass.getSubclassCode() == 0) {
799  oStream << ", ";
800  } else {
801  oStream << iBookingClass.getSubclassCode() << ", ";
802  }
803  oStream << iBookingClass.getAuthorizationLevel() << " ("
804  << iBookingClass.getProtection() << "), "
805  << iBookingClass.getNegotiatedSpace() << ", "
806  << iBookingClass.getNoShowPercentage() << ", "
807  << iBookingClass.getCancellationPercentage() << ", "
808  << iBookingClass.getNbOfBookings() << ", "
809  << iBookingClass.getNbOfGroupBookings() << " ("
810  << iBookingClass.getNbOfPendingGroupBookings() << "), "
811  << iBookingClass.getNbOfStaffBookings() << ", "
812  << iBookingClass.getNbOfWLBookings() << ", "
813  << iBookingClass.getETB() << ", "
814  << iBookingClass.getNetClassAvailability() << ", "
815  << iBookingClass.getNetRevenueAvailability() << ", "
816  << iBookingClass.getSegmentAvailability() << ", "
817  << std::endl;
818  }
819 
820  // ////////////////////////////////////////////////////////////////////
821  void BomDisplay::csvBookingClassDisplay (std::ostream& oStream,
822  const FlightDate& iFlightDate) {
823  // Save the formatting flags for the given STL output stream
824  FlagSaver flagSaver (oStream);
825 
826  // Headers
827  oStream << "******************************************" << std::endl;
828  oStream << "Subclasses:" << std::endl
829  << "-----------" << std::endl;
830  oStream << "Flight, Segment, Cabin, FF, Subclass, MIN/AU (Prot), "
831  << "Nego, NS%, OB%, "
832  << "Bkgs, GrpBks (pdg), StfBkgs, WLBkgs, ETB, "
833  << "ClassAvl, RevAvl, SegAvl, "
834  << std::endl;
835 
836  // Retrieve the key of the flight-date
837  const AirlineCode_T& lAirlineCode = iFlightDate.getAirlineCode();
838  const FlightNumber_T& lFlightNumber = iFlightDate.getFlightNumber();
839  const Date_T& lFlightDateDate = iFlightDate.getDepartureDate();
840 
841  // Check whether there are SegmentDate objects
842  if (BomManager::hasList<SegmentDate> (iFlightDate) == false) {
843  return;
844  }
845 
846  // Browse the segment-dates
847  const SegmentDateList_T& lSegmentDateList =
848  BomManager::getList<SegmentDate> (iFlightDate);
849  for (SegmentDateList_T::const_iterator itSD = lSegmentDateList.begin();
850  itSD != lSegmentDateList.end(); ++itSD) {
851  const SegmentDate* lSD_ptr = *itSD;
852  assert (lSD_ptr != NULL);
853 
854  // Retrieve the key of the segment-date, as well as its dates
855  const Date_T& lSegmentDateDate = lSD_ptr->getBoardingDate();
856  const AirportCode_T& lBoardPoint = lSD_ptr->getBoardingPoint();
857  const AirportCode_T& lOffPoint = lSD_ptr->getOffPoint();
858 
859  // Browse the segment-cabins
860  const SegmentCabinList_T& lSegmentCabinList =
861  BomManager::getList<SegmentCabin> (*lSD_ptr);
862  for (SegmentCabinList_T::const_iterator itSC = lSegmentCabinList.begin();
863  itSC != lSegmentCabinList.end(); ++itSC) {
864  const SegmentCabin* lSC_ptr = *itSC;
865  assert (lSC_ptr != NULL);
866 
867  // Retrieve the key of the segment-cabin
868  const CabinCode_T& lCabinCode = lSC_ptr->getCabinCode();
869 
870  // Build the leading string to be displayed
871  std::ostringstream oSCLeadingStr;
872  oSCLeadingStr << lAirlineCode << lFlightNumber << " "
873  << lFlightDateDate << ", "
874  << lBoardPoint << "-" << lOffPoint << " "
875  << lSegmentDateDate << ", "
876  << lCabinCode << ", ";
877 
878  // Default Fare Family code, when there are no FF
879  FamilyCode_T lFamilyCode ("NoFF");
880 
881  // Check whether there are FareFamily objects
882  if (BomManager::hasList<FareFamily> (*lSC_ptr) == true) {
883 
884  // Browse the fare families
885  const FareFamilyList_T& lFareFamilyList =
886  BomManager::getList<FareFamily> (*lSC_ptr);
887  for (FareFamilyList_T::const_iterator itFF = lFareFamilyList.begin();
888  itFF != lFareFamilyList.end(); ++itFF) {
889  const FareFamily* lFF_ptr = *itFF;
890  assert (lFF_ptr != NULL);
891 
892  // Retrieve the key of the segment-cabin
893  lFamilyCode = lFF_ptr->getFamilyCode();
894 
895  // Complete the leading string to be displayed
896  std::ostringstream oFFLeadingStr;
897  oFFLeadingStr << oSCLeadingStr.str() << lFamilyCode << ", ";
898 
899  // Browse the booking-classes
900  const BookingClassList_T& lBookingClassList =
901  BomManager::getList<BookingClass> (*lFF_ptr);
902  for (BookingClassList_T::const_iterator itBC =
903  lBookingClassList.begin();
904  itBC != lBookingClassList.end(); ++itBC) {
905  const BookingClass* lBC_ptr = *itBC;
906  assert (lBC_ptr != NULL);
907 
908  //
909  csvBookingClassDisplay (oStream, *lBC_ptr, oFFLeadingStr.str());
910  }
911  }
912 
913  // Go on to the next segment-cabin
914  continue;
915  }
916  assert (BomManager::hasList<FareFamily> (*lSC_ptr) == false);
917 
918  // The fare family code is a fake one ('NoFF'), and therefore
919  // does not vary
920  std::ostringstream oFFLeadingStr;
921  oFFLeadingStr << oSCLeadingStr.str() << lFamilyCode << ", ";
922 
923  // Browse the booking-classes, directly from the segment-cabin object
924  const BookingClassList_T& lBookingClassList =
925  BomManager::getList<BookingClass> (*lSC_ptr);
926  for (BookingClassList_T::const_iterator itBC =
927  lBookingClassList.begin();
928  itBC != lBookingClassList.end(); ++itBC) {
929  const BookingClass* lBC_ptr = *itBC;
930  assert (lBC_ptr != NULL);
931 
932  //
933  csvBookingClassDisplay (oStream, *lBC_ptr, oFFLeadingStr.str());
934  }
935  }
936  }
937  oStream << "******************************************" << std::endl;
938  }
939 
940  // ////////////////////////////////////////////////////////////////////
941  void BomDisplay::
942  csvDisplay (std::ostream& oStream,
943  const TravelSolutionList_T& iTravelSolutionList) {
944 
945  // Save the formatting flags for the given STL output stream
946  FlagSaver flagSaver (oStream);
947 
948  oStream << "Travel solutions:";
949  unsigned short idx = 0;
950  for (TravelSolutionList_T::const_iterator itTS =
951  iTravelSolutionList.begin();
952  itTS != iTravelSolutionList.end(); ++itTS, ++idx) {
953  const TravelSolutionStruct& lTS = *itTS;
954 
955  oStream << std::endl;
956  oStream << " [" << idx << "] " << lTS.display();
957  }
958  }
959 
960  // ////////////////////////////////////////////////////////////////////
961  void BomDisplay::
962  csvDisplay (std::ostream& oStream,
963  const DatePeriodList_T& iDatePeriodList) {
964 
965  // Save the formatting flags for the given STL output stream
966  FlagSaver flagSaver (oStream);
967 
968  // Browse the date-period objects
969  for (DatePeriodList_T::const_iterator itDP = iDatePeriodList.begin();
970  itDP != iDatePeriodList.end(); ++itDP) {
971  const DatePeriod* lDP_ptr = *itDP;
972  assert (lDP_ptr != NULL);
973 
974  // Display the date-period object
975  csvDateDisplay (oStream, *lDP_ptr);
976  }
977  }
978 
979  // ////////////////////////////////////////////////////////////////////
980  void BomDisplay::csvSimFQTAirRACDisplay (std::ostream& oStream,
981  const BomRoot& iBomRoot) {
982  // Save the formatting flags for the given STL output stream
983  FlagSaver flagSaver (oStream);
984 
988  oStream << std::endl;
989  oStream << "==============================================================="
990  << std::endl;
991  oStream << "BomRoot: " << iBomRoot.describeKey() << std::endl;
992  oStream << "==============================================================="
993  << std::endl;
994 
995  // Check whether there are airport-pair objects
996  if (BomManager::hasList<AirportPair> (iBomRoot) == false) {
997  return;
998  }
999 
1000  // Browse the airport-pair objects
1001  const AirportPairList_T& lAirportPairList =
1002  BomManager::getList<AirportPair> (iBomRoot);
1003  for (AirportPairList_T::const_iterator itAir = lAirportPairList.begin();
1004  itAir != lAirportPairList.end(); ++itAir ) {
1005  const AirportPair* lAir_ptr = *itAir;
1006  assert (lAir_ptr != NULL);
1007 
1008  // Display the airport pair object
1009  csvAirportPairDisplay (oStream, *lAir_ptr);
1010  }
1011  }
1012 
1013  // ////////////////////////////////////////////////////////////////////
1014  void BomDisplay::csvAirportPairDisplay (std::ostream& oStream,
1015  const AirportPair& iAirportPair) {
1016  // Save the formatting flags for the given STL output stream
1017  FlagSaver flagSaver (oStream);
1018 
1022  oStream << "+++++++++++++++++++++++++++++++++++++++++++++++++" << std::endl;
1023  oStream << "AirportPair: " << iAirportPair.describeKey() << std::endl;
1024  oStream << "+++++++++++++++++++++++++++++++++++++++++++++++++" << std::endl;
1025 
1026  // Check whether there are date-period objects
1027  if (BomManager::hasList<DatePeriod> (iAirportPair) == false) {
1028  return;
1029  }
1030 
1031  // Browse the date-period objects
1032  const DatePeriodList_T& lDatePeriodList =
1033  BomManager::getList<DatePeriod> (iAirportPair);
1034  for (DatePeriodList_T::const_iterator itDP = lDatePeriodList.begin();
1035  itDP != lDatePeriodList.end(); ++itDP) {
1036  const DatePeriod* lDP_ptr = *itDP;
1037  assert (lDP_ptr != NULL);
1038 
1039  // Display the date-period object
1040  csvDateDisplay (oStream, *lDP_ptr);
1041  }
1042  }
1043 
1044  // ////////////////////////////////////////////////////////////////////
1045  void BomDisplay::csvDateDisplay (std::ostream& oStream,
1046  const DatePeriod& iDatePeriod) {
1047 
1048  // Save the formatting flags for the given STL output stream
1049  FlagSaver flagSaver (oStream);
1050 
1054  oStream << "------------------------------------------" << std::endl;
1055  oStream << "DatePeriod: " << iDatePeriod.describeKey() << std::endl;
1056  oStream << "------------------------------------------" << std::endl;
1057 
1058  // Check whether there are pos-channel objects
1059  if (BomManager::hasList<PosChannel> (iDatePeriod) == false) {
1060  return;
1061  }
1062 
1063  // Browse the pos-channel objects
1064  const PosChannelList_T& lPosChannelList =
1065  BomManager::getList<PosChannel> (iDatePeriod);
1066  for (PosChannelList_T::const_iterator itPC = lPosChannelList.begin();
1067  itPC != lPosChannelList.end(); ++itPC) {
1068  const PosChannel* lPC_ptr = *itPC;
1069  assert (lPC_ptr != NULL);
1070 
1071  // Display the pos-channel object
1072  csvPosChannelDisplay (oStream, *lPC_ptr);
1073  }
1074  }
1075 
1076  // ////////////////////////////////////////////////////////////////////
1077  void BomDisplay::csvPosChannelDisplay (std::ostream& oStream,
1078  const PosChannel& iPosChannel) {
1079  // Save the formatting flags for the given STL output stream
1080  FlagSaver flagSaver (oStream);
1081 
1085  oStream << "******************************************" << std::endl;
1086  oStream << "PosChannel: " << iPosChannel.describeKey() << std::endl;
1087  oStream << "******************************************" << std::endl;
1088 
1089  // Check whether there are time-period objects
1090  if (BomManager::hasList<TimePeriod> (iPosChannel) == false) {
1091  return;
1092  }
1093 
1094  // Browse the time-period objects
1095  const TimePeriodList_T& lTimePeriodList =
1096  BomManager::getList<TimePeriod> (iPosChannel);
1097  for (TimePeriodList_T::const_iterator itTP = lTimePeriodList.begin();
1098  itTP != lTimePeriodList.end(); ++itTP) {
1099  const TimePeriod* lTP_ptr = *itTP;
1100  assert (lTP_ptr != NULL);
1101 
1102  // Display the time-period object
1103  csvTimeDisplay (oStream, *lTP_ptr);
1104  }
1105  }
1106 
1107  // ////////////////////////////////////////////////////////////////////
1108  void BomDisplay::csvTimeDisplay (std::ostream& oStream,
1109  const TimePeriod& iTimePeriod) {
1110 
1111  // Save the formatting flags for the given STL output stream
1112  FlagSaver flagSaver (oStream);
1113 
1117  oStream << "----------------------------------------" << std::endl;
1118  oStream << "TimePeriod: " << iTimePeriod.describeKey() << std::endl;
1119  oStream << "----------------------------------------" << std::endl;
1120 
1121  // Only one of the fare/yield feature list exists. Each of the following
1122  // two methods will check for the existence of the list. So, only the
1123  // existing list will be actually displayed.
1124  csvFeatureListDisplay<FareFeatures> (oStream, iTimePeriod);
1125  csvFeatureListDisplay<YieldFeatures> (oStream, iTimePeriod);
1126  }
1127 
1128  // ////////////////////////////////////////////////////////////////////
1129  template <typename FEATURE_TYPE>
1130  void BomDisplay::csvFeatureListDisplay (std::ostream& oStream,
1131  const TimePeriod& iTimePeriod) {
1132 
1133  // Check whether there are fare/yield-feature objects
1134  if (BomManager::hasList<FEATURE_TYPE> (iTimePeriod) == false) {
1135  return;
1136  }
1137 
1138  // Browse the fare/yield-feature objects
1139  typedef typename BomHolder<FEATURE_TYPE>::BomList_T FeaturesList_T;
1140  const FeaturesList_T& lFeaturesList =
1141  BomManager::getList<FEATURE_TYPE> (iTimePeriod);
1142  for (typename FeaturesList_T::const_iterator itFF = lFeaturesList.begin();
1143  itFF != lFeaturesList.end(); ++itFF) {
1144  const FEATURE_TYPE* lFF_ptr = *itFF;
1145  assert (lFF_ptr != NULL);
1146 
1147  // Display the fare-features object
1148  csvFeaturesDisplay (oStream, *lFF_ptr);
1149  }
1150  }
1151 
1152  // ////////////////////////////////////////////////////////////////////
1153  template <typename FEATURE_TYPE>
1154  void BomDisplay::csvFeaturesDisplay (std::ostream& oStream,
1155  const FEATURE_TYPE& iFeatures) {
1156  // Save the formatting flags for the given STL output stream
1157  FlagSaver flagSaver (oStream);
1158 
1162  oStream << "--------------------------------------" << std::endl;
1163  oStream << "Fare/yield-Features: " << iFeatures.describeKey() << std::endl;
1164  oStream << "--------------------------------------" << std::endl;
1165 
1166  // Check whether there are airlineClassList objects
1167  if (BomManager::hasList<AirlineClassList> (iFeatures) == false) {
1168  return;
1169  }
1170 
1171  // Browse the airlineClassList objects
1172  const AirlineClassListList_T& lAirlineClassListList =
1173  BomManager::getList<AirlineClassList> (iFeatures);
1174  for (AirlineClassListList_T::const_iterator itACL =
1175  lAirlineClassListList.begin();
1176  itACL != lAirlineClassListList.end(); ++itACL) {
1177  const AirlineClassList* lACL_ptr = *itACL;
1178  assert (lACL_ptr != NULL);
1179 
1180  // Display the airlineClassList object
1181  csvAirlineClassDisplay(oStream, *lACL_ptr);
1182  }
1183  }
1184 
1185  // ////////////////////////////////////////////////////////////////////
1186  void BomDisplay::
1187  csvAirlineClassDisplay (std::ostream& oStream,
1188  const AirlineClassList& iAirlineClassList) {
1189  // Save the formatting flags for the given STL output stream
1190  FlagSaver flagSaver (oStream);
1191 
1195  oStream << "------------------------------------" << std::endl;
1196  oStream << "AirlineClassList: "
1197  << iAirlineClassList.describeKey() << std::endl;
1198  oStream << "------------------------------------" << std::endl;
1199  }
1200 
1201 }
1202