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