7 #include <boost/date_time/date_iterator.hpp>
9 #include <stdair/basic/BasConst_BookingClass.hpp>
10 #include <stdair/basic/BasConst_Yield.hpp>
11 #include <stdair/basic/BasConst_Inventory.hpp>
12 #include <stdair/bom/BomManager.hpp>
13 #include <stdair/bom/BomRoot.hpp>
14 #include <stdair/bom/Inventory.hpp>
15 #include <stdair/bom/AirlineFeature.hpp>
16 #include <stdair/bom/FlightDate.hpp>
17 #include <stdair/bom/SegmentDate.hpp>
18 #include <stdair/bom/SegmentCabin.hpp>
19 #include <stdair/bom/FareFamily.hpp>
20 #include <stdair/bom/BookingClass.hpp>
21 #include <stdair/bom/LegDate.hpp>
22 #include <stdair/bom/LegCabin.hpp>
23 #include <stdair/bom/Bucket.hpp>
24 #include <stdair/bom/BomKeyManager.hpp>
25 #include <stdair/bom/ParsedKey.hpp>
26 #include <stdair/bom/BomRetriever.hpp>
27 #include <stdair/command/CmdCloneBomManager.hpp>
28 #include <stdair/factory/FacBom.hpp>
29 #include <stdair/factory/FacBomManager.hpp>
30 #include <stdair/service/Logger.hpp>
39 void InventoryBuilder::
40 buildInventory (stdair::BomRoot& ioBomRoot,
41 const FlightDateStruct& iFlightDateStruct) {
42 const stdair::AirlineCode_T& lAirlineCode = iFlightDateStruct._airlineCode;
46 stdair::Inventory* lInventory_ptr = stdair::BomManager::
47 getObjectPtr<stdair::Inventory> (ioBomRoot, lAirlineCode);
48 if (lInventory_ptr == NULL) {
49 stdair::InventoryKey lKey (lAirlineCode);
51 &stdair::FacBom<stdair::Inventory>::instance().create (lKey);
52 stdair::FacBomManager::addToListAndMap (ioBomRoot, *lInventory_ptr);
53 stdair::FacBomManager::linkWithParent (ioBomRoot, *lInventory_ptr);
56 const stdair::AirlineFeatureKey lAirlineFeatureKey (lAirlineCode);
57 stdair::AirlineFeature& lAirlineFeature =
58 stdair::FacBom<stdair::AirlineFeature>::instance().create (lAirlineFeatureKey);
59 stdair::FacBomManager::setAirlineFeature (*lInventory_ptr,
61 stdair::FacBomManager::linkWithParent (*lInventory_ptr, lAirlineFeature);
63 stdair::FacBomManager::addToListAndMap (ioBomRoot, lAirlineFeature);
65 assert (lInventory_ptr != NULL);
68 buildFlightDate (*lInventory_ptr, iFlightDateStruct);
72 void InventoryBuilder::
73 buildFlightDate (stdair::Inventory& ioInventory,
74 const FlightDateStruct& iFlightDateStruct) {
76 const stdair::FlightDateKey lFlightDateKey (iFlightDateStruct._flightNumber,
77 iFlightDateStruct._flightDate);
82 stdair::FlightDate* lFlightDate_ptr = stdair::BomManager::
83 getObjectPtr<stdair::FlightDate> (ioInventory, lFlightDateKey.toString());
84 if (lFlightDate_ptr == NULL) {
88 &stdair::FacBom<stdair::FlightDate>::instance().create (lFlightDateKey);
89 stdair::FacBomManager::addToListAndMap (ioInventory, *lFlightDate_ptr);
90 stdair::FacBomManager::linkWithParent (ioInventory, *lFlightDate_ptr);
92 assert (lFlightDate_ptr != NULL);
98 for (LegStructList_T::const_iterator itLegDate =
99 iFlightDateStruct._legList.begin();
100 itLegDate != iFlightDateStruct._legList.end(); ++itLegDate) {
101 const LegStruct& lCurrentLegDateStruct = *itLegDate;
102 buildLegDate (*lFlightDate_ptr, lCurrentLegDateStruct);
105 for (SegmentStructList_T::const_iterator itSegmentDate =
106 iFlightDateStruct._segmentList.begin();
107 itSegmentDate != iFlightDateStruct._segmentList.end();
109 const SegmentStruct& lCurrentSegmentDateStruct = *itSegmentDate;
110 buildSegmentDate (*lFlightDate_ptr, lCurrentSegmentDateStruct);
113 buildRoutingLegKey (*lFlightDate_ptr);
117 void InventoryBuilder::
118 buildLegDate (stdair::FlightDate& ioFlightDate,
119 const LegStruct& iLegDateStruct) {
123 stdair::LegDate* lLegDate_ptr = stdair::BomManager::
124 getObjectPtr<stdair::LegDate>(ioFlightDate, iLegDateStruct._boardingPoint);
126 if (lLegDate_ptr == NULL) {
128 stdair::LegDateKey lKey (iLegDateStruct._boardingPoint);
129 lLegDate_ptr = &stdair::FacBom<stdair::LegDate>::instance().create (lKey);
130 stdair::FacBomManager::addToListAndMap (ioFlightDate, *lLegDate_ptr);
131 stdair::FacBomManager::linkWithParent (ioFlightDate, *lLegDate_ptr);
133 assert (lLegDate_ptr != NULL);
136 iLegDateStruct.fill (*lLegDate_ptr);
139 for (LegCabinStructList_T::const_iterator itLegCabin =
140 iLegDateStruct._cabinList.begin();
141 itLegCabin != iLegDateStruct._cabinList.end(); ++itLegCabin) {
142 const LegCabinStruct& lCurrentLegCabinStruct = *itLegCabin;
143 buildLegCabin (*lLegDate_ptr, lCurrentLegCabinStruct);
148 void InventoryBuilder::
149 buildRoutingLegKey (stdair::FlightDate& ioFlightDate) {
153 const stdair::SegmentDateList_T& lSegmentDateList =
154 stdair::BomManager::getList<stdair::SegmentDate> (ioFlightDate);
155 for (stdair::SegmentDateList_T::const_iterator itSegmentDate =
156 lSegmentDateList.begin();
157 itSegmentDate != lSegmentDateList.end(); ++itSegmentDate) {
159 stdair::SegmentDate* lCurrentSegmentDate_ptr = *itSegmentDate;
160 assert (lCurrentSegmentDate_ptr != NULL);
167 const stdair::SegmentDate* lOperatingSegmentDate_ptr =
168 lCurrentSegmentDate_ptr->getOperatingSegmentDate ();
169 if (lOperatingSegmentDate_ptr == NULL) {
171 const stdair::AirportCode_T& lBoardingPoint =
172 lCurrentSegmentDate_ptr->getBoardingPoint();
174 stdair::AirportCode_T currentBoardingPoint = lBoardingPoint;
175 const stdair::AirportCode_T& lOffPoint =
176 lCurrentSegmentDate_ptr->getOffPoint();
183 unsigned short i = 1;
184 while (currentBoardingPoint != lOffPoint
185 && i <= stdair::MAXIMAL_NUMBER_OF_LEGS_IN_FLIGHT) {
187 stdair::LegDate& lLegDate = stdair::BomManager::
188 getObject<stdair::LegDate> (ioFlightDate, currentBoardingPoint);
191 const std::string& lRoutingKeyStr = lLegDate.describeRoutingKey();
192 lCurrentSegmentDate_ptr->addLegKey(lRoutingKeyStr);
195 currentBoardingPoint = lLegDate.getOffPoint();
198 assert (i <= stdair::MAXIMAL_NUMBER_OF_LEGS_IN_FLIGHT);
204 void InventoryBuilder::
205 buildLegCabin (stdair::LegDate& ioLegDate,
206 const LegCabinStruct& iLegCabinStruct) {
210 stdair::LegCabin* lLegCabin_ptr = stdair::BomManager::
211 getObjectPtr<stdair::LegCabin> (ioLegDate, iLegCabinStruct._cabinCode);
212 if (lLegCabin_ptr == NULL) {
214 stdair::LegCabinKey lKey (iLegCabinStruct._cabinCode);
215 lLegCabin_ptr = &stdair::FacBom<stdair::LegCabin>::instance().create(lKey);
216 stdair::FacBomManager::addToListAndMap (ioLegDate, *lLegCabin_ptr);
217 stdair::FacBomManager::linkWithParent (ioLegDate, *lLegCabin_ptr);
219 assert (lLegCabin_ptr != NULL);
223 iLegCabinStruct.fill (*lLegCabin_ptr);
226 for (BucketStructList_T::const_iterator itBucket =
227 iLegCabinStruct._bucketList.begin();
228 itBucket != iLegCabinStruct._bucketList.end(); ++itBucket) {
229 const BucketStruct& lCurrentBucketStruct = *itBucket;
230 buildBucket (*lLegCabin_ptr, lCurrentBucketStruct);
235 void InventoryBuilder::buildBucket (stdair::LegCabin& ioLegCabin,
236 const BucketStruct& iBucketStruct) {
238 const stdair::BucketKey lBucketKey (iBucketStruct._seatIndex);
243 stdair::Bucket* lBucket_ptr = stdair::BomManager::
244 getObjectPtr<stdair::Bucket> (ioLegCabin, lBucketKey.toString());
245 if (lBucket_ptr == NULL) {
247 stdair::BucketKey lKey (iBucketStruct._seatIndex);
248 lBucket_ptr = &stdair::FacBom<stdair::Bucket>::instance().create (lKey);
249 stdair::FacBomManager::addToListAndMap (ioLegCabin, *lBucket_ptr);
250 stdair::FacBomManager::linkWithParent (ioLegCabin, *lBucket_ptr);
252 assert (lBucket_ptr != NULL);
255 iBucketStruct.fill (*lBucket_ptr);
259 void InventoryBuilder::
260 buildSegmentDate (stdair::FlightDate& ioFlightDate,
261 const SegmentStruct& iSegmentDateStruct) {
265 const stdair::SegmentDateKey
266 lSegmentDateKey (iSegmentDateStruct._boardingPoint,
267 iSegmentDateStruct._offPoint);
268 stdair::SegmentDate* lSegmentDate_ptr = stdair::BomManager::
269 getObjectPtr<stdair::SegmentDate>(ioFlightDate,lSegmentDateKey.toString());
270 if (lSegmentDate_ptr == NULL) {
273 lSegmentDate_ptr = &stdair::FacBom<stdair::SegmentDate>::
274 instance().create (lSegmentDateKey);
275 stdair::FacBomManager::addToListAndMap (ioFlightDate, *lSegmentDate_ptr);
276 stdair::FacBomManager::linkWithParent (ioFlightDate, *lSegmentDate_ptr);
278 assert (lSegmentDate_ptr != NULL);
282 iSegmentDateStruct.fill (*lSegmentDate_ptr);
285 for (SegmentCabinStructList_T::const_iterator itSegmentCabin =
286 iSegmentDateStruct._cabinList.begin();
287 itSegmentCabin != iSegmentDateStruct._cabinList.end();
289 const SegmentCabinStruct& lCurrentSegmentCabinStruct = *itSegmentCabin;
290 buildSegmentCabin (*lSegmentDate_ptr, lCurrentSegmentCabinStruct);
295 void InventoryBuilder::
296 buildSegmentCabin (stdair::SegmentDate& ioSegmentDate,
297 const SegmentCabinStruct& iSegmentCabinStruct) {
301 stdair::SegmentCabin* lSegmentCabin_ptr = stdair::BomManager::
302 getObjectPtr<stdair::SegmentCabin> (ioSegmentDate,
303 iSegmentCabinStruct._cabinCode);
304 if (lSegmentCabin_ptr == NULL) {
306 stdair::SegmentCabinKey lKey (iSegmentCabinStruct._cabinCode);
308 &stdair::FacBom<stdair::SegmentCabin>::instance().create (lKey);
311 stdair::FacBomManager::addToListAndMap (ioSegmentDate, *lSegmentCabin_ptr);
312 stdair::FacBomManager::linkWithParent (ioSegmentDate, *lSegmentCabin_ptr);
314 assert (lSegmentCabin_ptr != NULL);
318 iSegmentCabinStruct.fill (*lSegmentCabin_ptr);
321 for (FareFamilyStructList_T::const_iterator itFareFamily =
322 iSegmentCabinStruct._fareFamilies.begin();
323 itFareFamily != iSegmentCabinStruct._fareFamilies.end();
325 const FareFamilyStruct& lCurrentFareFamilyStruct = *itFareFamily;
326 buildFareFamily (*lSegmentCabin_ptr, lCurrentFareFamilyStruct);
331 void InventoryBuilder::
332 buildFareFamily (stdair::SegmentCabin& ioSegmentCabin,
333 const FareFamilyStruct& iFareFamilyStruct) {
338 stdair::FareFamily* lFareFamily_ptr = stdair::BomManager::
339 getObjectPtr<stdair::FareFamily> (ioSegmentCabin,
340 iFareFamilyStruct._familyCode);
341 if (lFareFamily_ptr == NULL) {
343 const stdair::FareFamilyKey lFFKey (iFareFamilyStruct._familyCode);
345 &stdair::FacBom<stdair::FareFamily>::instance().create (lFFKey);
348 stdair::FacBomManager::addToListAndMap (ioSegmentCabin, *lFareFamily_ptr);
349 stdair::FacBomManager::linkWithParent (ioSegmentCabin, *lFareFamily_ptr);
351 assert (lFareFamily_ptr != NULL);
355 iFareFamilyStruct.fill (*lFareFamily_ptr);
358 for (BookingClassStructList_T::const_iterator itBookingClass =
359 iFareFamilyStruct._classList.begin();
360 itBookingClass != iFareFamilyStruct._classList.end();
362 const BookingClassStruct& lCurrentBookingClassStruct = *itBookingClass;
363 buildBookingClass (*lFareFamily_ptr, lCurrentBookingClassStruct);
368 void InventoryBuilder::
369 buildBookingClass (stdair::FareFamily& ioFareFamily,
370 const BookingClassStruct& iBookingClassStruct) {
375 stdair::BookingClass* lBookingClass_ptr = stdair::BomManager::
376 getObjectPtr<stdair::BookingClass> (ioFareFamily,
377 iBookingClassStruct._classCode);
378 if (lBookingClass_ptr == NULL) {
380 const stdair::BookingClassKey lClassKey (iBookingClassStruct._classCode);
382 &stdair::FacBom<stdair::BookingClass>::instance().create (lClassKey);
385 stdair::FacBomManager::addToListAndMap (ioFareFamily, *lBookingClass_ptr);
386 stdair::FacBomManager::linkWithParent (ioFareFamily, *lBookingClass_ptr);
389 stdair::SegmentCabin& lSegmentCabin =
390 stdair::BomManager::getParent<stdair::SegmentCabin> (ioFareFamily);
391 stdair::FacBomManager::addToListAndMap (lSegmentCabin, *lBookingClass_ptr);
394 stdair::SegmentDate& lSegmentDate =
395 stdair::BomManager::getParent<stdair::SegmentDate> (lSegmentCabin);
396 stdair::FacBomManager::addToListAndMap (lSegmentDate, *lBookingClass_ptr);
398 assert (lBookingClass_ptr != NULL);
402 iBookingClassStruct.fill (*lBookingClass_ptr);
406 void InventoryBuilder::buildPartnerInventories (stdair::BomRoot& ioBomRoot) {
410 const stdair::InventoryList_T& lInvList =
411 stdair::BomManager::getList<stdair::Inventory> (ioBomRoot);
412 for (stdair::InventoryList_T::const_iterator itInv = lInvList.begin();
413 itInv != lInvList.end(); ++itInv) {
414 stdair::Inventory* lCurrentInv_ptr = *itInv;
415 assert (lCurrentInv_ptr != NULL);
417 buildPartnerInventories (ioBomRoot, *lCurrentInv_ptr);
422 void InventoryBuilder::buildPartnerInventories (stdair::BomRoot& ioBomRoot,
423 stdair::Inventory& ioInventory) {
426 const stdair::FlightDateList_T& lFlightDateList =
427 stdair::BomManager::getList<stdair::FlightDate> (ioInventory);
428 for (stdair::FlightDateList_T::const_iterator itFlightDate =
429 lFlightDateList.begin();
430 itFlightDate != lFlightDateList.end(); ++itFlightDate) {
431 stdair::FlightDate* lCurrentFlightDate_ptr = *itFlightDate;
432 assert (lCurrentFlightDate_ptr != NULL);
434 buildPartnerInventories (ioBomRoot, ioInventory, *lCurrentFlightDate_ptr);
440 void InventoryBuilder::buildPartnerInventories (stdair::BomRoot& ioBomRoot,
441 stdair::Inventory& ioInventory,
442 stdair::FlightDate& iFlightDate) {
445 const stdair::SegmentDateList_T& lSegmentDateList =
446 stdair::BomManager::getList<stdair::SegmentDate> (iFlightDate);
447 for (stdair::SegmentDateList_T::const_iterator itSegmentDate =
448 lSegmentDateList.begin();
449 itSegmentDate != lSegmentDateList.end(); ++itSegmentDate) {
451 stdair::SegmentDate* lCurrentSegmentDate_ptr = *itSegmentDate;
452 assert (lCurrentSegmentDate_ptr != NULL);
454 const stdair::RoutingLegKeyList_T& lRoutingLegKeyList =
455 lCurrentSegmentDate_ptr->getLegKeyList ();
458 for (stdair::RoutingLegKeyList_T::const_iterator itRoutingLegKey =
459 lRoutingLegKeyList.begin();
460 itRoutingLegKey != lRoutingLegKeyList.end(); ++itRoutingLegKey) {
463 const stdair::ParsedKey& lParsedKey =
464 stdair::BomKeyManager::extractKeys (*itRoutingLegKey);
465 const stdair::InventoryKey& lInventoryKey =
466 lParsedKey.getInventoryKey();
467 const stdair::AirlineCode_T lOperatingAirlineCode =
468 lInventoryKey.getAirlineCode();
471 const stdair::AirlineCode_T lAirlineCode =
472 iFlightDate.getAirlineCode();
475 if (lOperatingAirlineCode != lAirlineCode) {
478 stdair::Inventory* lInventory_ptr =
479 stdair::BomRetriever::
480 retrieveInventoryFromKey (ioBomRoot, lOperatingAirlineCode);
483 std::ostringstream lRoutingSegment;
484 lRoutingSegment << iFlightDate.getAirlineCode() <<
";"
485 << iFlightDate.describeKey() <<
";"
486 << lCurrentSegmentDate_ptr->getBoardingPoint() <<
";"
487 << lCurrentSegmentDate_ptr->getOffPoint();
490 if (lInventory_ptr == NULL) {
491 std::ostringstream oMessage;
492 oMessage <<
"The input file does not contain information about "
493 <<
"the '" << *itRoutingLegKey <<
"' leg date needed by "
494 <<
"the '" << lRoutingSegment.str() <<
"' segment.";
495 STDAIR_LOG_ERROR (oMessage.str());
496 throw MissingPartnerFlightDateWithinScheduleFile (oMessage.str());
498 assert (lInventory_ptr != NULL);
501 buildInventory (ioBomRoot, ioInventory, *itRoutingLegKey);
504 buildInventory (ioBomRoot, *lInventory_ptr, lRoutingSegment.str());
511 void InventoryBuilder::
512 buildInventory (stdair::BomRoot& ioBomRoot,
513 stdair::Inventory& ioInventory,
514 const std::string& iFullKeyStr) {
520 stdair::Inventory* lInventory_ptr =
521 stdair::BomRetriever::retrieveInventoryFromLongKey (ioInventory,
523 if (lInventory_ptr == NULL) {
526 stdair::Inventory* lOperatingInventory_ptr =
527 stdair::BomRetriever::retrieveInventoryFromLongKey (ioBomRoot,
529 assert (lOperatingInventory_ptr != NULL);
531 &stdair::FacBom<stdair::Inventory>::instance().create (*lOperatingInventory_ptr);
532 stdair::FacBomManager::addToListAndMap (ioInventory, *lInventory_ptr);
533 stdair::FacBomManager::linkWithParent (ioInventory, *lInventory_ptr);
535 assert (lInventory_ptr != NULL);
538 buildFlightDate (ioBomRoot, *lInventory_ptr, iFullKeyStr);
542 void InventoryBuilder::
543 buildFlightDate (stdair::BomRoot& ioBomRoot,
544 stdair::Inventory& ioInventory,
545 const std::string& iFullKeyStr) {
550 stdair::FlightDate* lFlightDate_ptr =
551 stdair::BomRetriever::retrieveFlightDateFromLongKey (ioInventory,
553 if (lFlightDate_ptr == NULL) {
556 stdair::FlightDate* lOperatingFlightDate_ptr =
557 stdair::BomRetriever::retrieveFlightDateFromLongKey (ioBomRoot,
559 assert (lOperatingFlightDate_ptr != NULL);
560 stdair::FlightDate& lFlightDate =
561 cloneFlightDate (*lOperatingFlightDate_ptr);
562 stdair::FacBomManager::addToListAndMap (ioInventory, lFlightDate);
563 stdair::FacBomManager::linkWithParent (ioInventory, lFlightDate);
568 stdair::FlightDate& InventoryBuilder::
569 cloneFlightDate (
const stdair::FlightDate& iFlightDate) {
574 stdair::FlightDate& lCloneFlightDate =
575 stdair::FacBom<stdair::FlightDate>::instance().create (iFlightDate);
578 const bool hasLegDateList = stdair::BomManager::hasList<stdair::LegDate> (iFlightDate);
579 if (hasLegDateList ==
true) {
582 const stdair::LegDateList_T& lLegDateList =
583 stdair::BomManager::getList<stdair::LegDate> (iFlightDate);
584 for (stdair::LegDateList_T::const_iterator itLD = lLegDateList.begin();
585 itLD != lLegDateList.end(); ++itLD) {
586 const stdair::LegDate* lLD_ptr = *itLD;
587 assert (lLD_ptr != NULL);
590 stdair::LegDate& lCloneLegDate = cloneLegDate (*lLD_ptr);
591 stdair::FacBomManager::addToListAndMap (lCloneFlightDate, lCloneLegDate);
592 stdair::FacBomManager::linkWithParent (lCloneFlightDate, lCloneLegDate);
597 const bool hasSegmentDateList =
598 stdair::BomManager::hasList<stdair::SegmentDate> (iFlightDate);
599 if (hasSegmentDateList ==
true) {
602 const stdair::SegmentDateList_T& lSegmentDateList =
603 stdair::BomManager::getList<stdair::SegmentDate> (iFlightDate);
604 for (stdair::SegmentDateList_T::const_iterator itSD = lSegmentDateList.begin();
605 itSD != lSegmentDateList.end(); ++itSD) {
606 const stdair::SegmentDate* lSD_ptr = *itSD;
607 assert (lSD_ptr != NULL);
610 stdair::SegmentDate& lCloneSegmentDate = cloneSegmentDate (*lSD_ptr);
611 stdair::FacBomManager::addToListAndMap (lCloneFlightDate, lCloneSegmentDate);
612 stdair::FacBomManager::linkWithParent (lCloneFlightDate, lCloneSegmentDate);
617 return lCloneFlightDate;
621 stdair::LegDate& InventoryBuilder::cloneLegDate (
const stdair::LegDate& iLegDate) {
626 stdair::LegDate& lCloneLegDate =
627 stdair::FacBom<stdair::LegDate>::instance().create (iLegDate);
630 const bool hasLegCabinList = stdair::BomManager::hasList<stdair::LegCabin> (iLegDate);
631 if (hasLegCabinList ==
true) {
633 const stdair::LegCabinList_T& lLegCabinList =
634 stdair::BomManager::getList<stdair::LegCabin> (iLegDate);
635 for (stdair::LegCabinList_T::const_iterator itLC = lLegCabinList.begin();
636 itLC != lLegCabinList.end(); ++itLC) {
637 const stdair::LegCabin* lLC_ptr = *itLC;
638 assert (lLC_ptr != NULL);
641 stdair::LegCabin& lCloneLegCabin = cloneLegCabin (*lLC_ptr);
642 stdair::FacBomManager::addToListAndMap (lCloneLegDate, lCloneLegCabin);
643 stdair::FacBomManager::linkWithParent (lCloneLegDate, lCloneLegCabin);
647 return lCloneLegDate;
651 stdair::LegCabin& InventoryBuilder::cloneLegCabin (
const stdair::LegCabin& iLegCabin) {
656 stdair::LegCabin& lCloneLegCabin =
657 stdair::FacBom<stdair::LegCabin>::instance().create (iLegCabin);
660 const bool hasBucketList = stdair::BomManager::hasList<stdair::Bucket> (iLegCabin);
661 if (hasBucketList ==
true) {
663 const stdair::BucketList_T& lBucketList =
664 stdair::BomManager::getList<stdair::Bucket> (iLegCabin);
665 for (stdair::BucketList_T::const_iterator itBucket = lBucketList.begin();
666 itBucket != lBucketList.end(); ++itBucket) {
667 const stdair::Bucket* lBucket_ptr = *itBucket;
668 assert (lBucket_ptr != NULL);
671 stdair::Bucket& lCloneBucket = cloneBucket (*lBucket_ptr);
672 stdair::FacBomManager::addToListAndMap (lCloneLegCabin, lCloneBucket);
673 stdair::FacBomManager::linkWithParent (lCloneLegCabin, lCloneBucket);
677 return lCloneLegCabin;
681 stdair::Bucket& InventoryBuilder::cloneBucket (
const stdair::Bucket& iBucket) {
686 stdair::Bucket& lCloneBucket =
687 stdair::FacBom<stdair::Bucket>::instance().create (iBucket);
693 stdair::SegmentDate& InventoryBuilder::
694 cloneSegmentDate (
const stdair::SegmentDate& iSegmentDate) {
699 stdair::SegmentDate& lCloneSegmentDate =
700 stdair::FacBom<stdair::SegmentDate>::instance().create (iSegmentDate);
703 const bool hasSegmentCabinList =
704 stdair::BomManager::hasList<stdair::SegmentCabin> (iSegmentDate);
705 if (hasSegmentCabinList ==
true) {
707 const stdair::SegmentCabinList_T& lSegmentCabinList =
708 stdair::BomManager::getList<stdair::SegmentCabin> (iSegmentDate);
709 for (stdair::SegmentCabinList_T::const_iterator itSC = lSegmentCabinList.begin();
710 itSC != lSegmentCabinList.end(); ++itSC) {
711 const stdair::SegmentCabin* lSC_ptr = *itSC;
712 assert (lSC_ptr != NULL);
715 stdair::SegmentCabin& lCloneSegmentCabin = cloneSegmentCabin (*lSC_ptr);
716 stdair::FacBomManager::addToListAndMap (lCloneSegmentDate, lCloneSegmentCabin);
717 stdair::FacBomManager::linkWithParent (lCloneSegmentDate, lCloneSegmentCabin);
719 linkBookingClassesWithSegment (lCloneSegmentDate,
724 return lCloneSegmentDate;
728 void InventoryBuilder::
729 linkBookingClassesWithSegment (stdair::SegmentDate& iCloneSegmentDate,
730 stdair::SegmentCabin& iCloneSegmentCabin) {
734 const bool hasFareFamilyList =
735 stdair::BomManager::hasList<stdair::FareFamily> (iCloneSegmentCabin);
736 if (hasFareFamilyList ==
true) {
737 const stdair::FareFamilyList_T& lCloneFFList =
738 stdair::BomManager::getList<stdair::FareFamily> (iCloneSegmentCabin);
739 for (stdair::FareFamilyList_T::const_iterator itCloneFF = lCloneFFList.begin();
740 itCloneFF != lCloneFFList.end(); ++itCloneFF) {
741 const stdair::FareFamily* lCloneFF_ptr = *itCloneFF;
742 assert (lCloneFF_ptr != NULL);
745 const bool hasBookingClasslist =
746 stdair::BomManager::hasList<stdair::BookingClass> (*lCloneFF_ptr);
747 if (hasBookingClasslist ==
true) {
748 const stdair::BookingClassList_T& lCloneBCList =
749 stdair::BomManager::getList<stdair::BookingClass> (*lCloneFF_ptr);
750 for (stdair::BookingClassList_T::const_iterator itCloneBC =
751 lCloneBCList.begin();
752 itCloneBC != lCloneBCList.end(); ++itCloneBC) {
753 const stdair::BookingClass* lCloneBC_ptr = *itCloneBC;
754 assert (lCloneBC_ptr != NULL);
757 stdair::FacBomManager::addToListAndMap (iCloneSegmentCabin,
761 stdair::FacBomManager::addToListAndMap (iCloneSegmentDate,
770 stdair::SegmentCabin& InventoryBuilder::
771 cloneSegmentCabin (
const stdair::SegmentCabin& iSegmentCabin) {
776 stdair::SegmentCabin& lCloneSegmentCabin =
777 stdair::FacBom<stdair::SegmentCabin>::instance().create (iSegmentCabin);
780 const bool hasFareFamilyList =
781 stdair::BomManager::hasList<stdair::FareFamily> (iSegmentCabin);
782 if (hasFareFamilyList ==
true) {
784 const stdair::FareFamilyList_T& lFareFamilyList =
785 stdair::BomManager::getList<stdair::FareFamily> (iSegmentCabin);
786 for (stdair::FareFamilyList_T::const_iterator itFF = lFareFamilyList.begin();
787 itFF != lFareFamilyList.end(); ++itFF) {
788 const stdair::FareFamily* lFF_ptr = *itFF;
789 assert (lFF_ptr != NULL);
792 stdair::FareFamily& lCloneFareFamily = cloneFareFamily (*lFF_ptr);
793 stdair::FacBomManager::addToListAndMap (lCloneSegmentCabin, lCloneFareFamily);
794 stdair::FacBomManager::linkWithParent (lCloneSegmentCabin, lCloneFareFamily);
798 return lCloneSegmentCabin;
802 stdair::FareFamily& InventoryBuilder::
803 cloneFareFamily (
const stdair::FareFamily& iFareFamily) {
807 stdair::FareFamily& lCloneFareFamily =
808 stdair::FacBom<stdair::FareFamily>::instance().create (iFareFamily);
811 const bool hasBookingClassList =
812 stdair::BomManager::hasList<stdair::BookingClass> (iFareFamily);
813 if (hasBookingClassList ==
true) {
815 const stdair::BookingClassList_T& lBookingClassList =
816 stdair::BomManager::getList<stdair::BookingClass> (iFareFamily);
817 for (stdair::BookingClassList_T::const_iterator itBookingClass =
818 lBookingClassList.begin();
819 itBookingClass != lBookingClassList.end(); ++itBookingClass) {
820 const stdair::BookingClass* lBC_ptr = *itBookingClass;
821 assert (lBC_ptr != NULL);
824 stdair::BookingClass& lCloneBookingClass = cloneBookingClass (*lBC_ptr);
825 stdair::FacBomManager::addToListAndMap (lCloneFareFamily, lCloneBookingClass);
826 stdair::FacBomManager::linkWithParent (lCloneFareFamily, lCloneBookingClass);
830 return lCloneFareFamily;
834 stdair::BookingClass& InventoryBuilder::
835 cloneBookingClass (
const stdair::BookingClass& iBookingClass) {
840 stdair::BookingClass& lCloneBookingClass =
841 stdair::FacBom<stdair::BookingClass>::instance().create (iBookingClass);
843 return lCloneBookingClass;