7 #include <boost/date_time/date_iterator.hpp>
9 #include <stdair/stdair_basic_types.hpp>
10 #include <stdair/basic/BasConst_Inventory.hpp>
11 #include <stdair/bom/BomManager.hpp>
12 #include <stdair/bom/BomRoot.hpp>
13 #include <stdair/bom/Inventory.hpp>
14 #include <stdair/bom/AirlineFeature.hpp>
15 #include <stdair/bom/FlightPeriod.hpp>
16 #include <stdair/bom/SegmentPeriod.hpp>
17 #include <stdair/factory/FacBomManager.hpp>
18 #include <stdair/service/Logger.hpp>
27 void InventoryGenerator::
28 createFlightPeriod (stdair::BomRoot& ioBomRoot,
29 const FlightPeriodStruct& iFlightPeriodStruct) {
31 const stdair::AirlineCode_T& lAirlineCode = iFlightPeriodStruct._airlineCode;
35 stdair::Inventory* lInventory_ptr = stdair::BomManager::
36 getObjectPtr<stdair::Inventory> (ioBomRoot, lAirlineCode);
37 if (lInventory_ptr == NULL) {
38 stdair::InventoryKey lKey (lAirlineCode);
42 stdair::FacBomManager::addToListAndMap (ioBomRoot, *lInventory_ptr);
43 stdair::FacBomManager::linkWithParent (ioBomRoot, *lInventory_ptr);
46 const stdair::AirlineFeatureKey lAirlineFeatureKey (lAirlineCode);
47 stdair::AirlineFeature& lAirlineFeature =
49 stdair::FacBomManager::setAirlineFeature (*lInventory_ptr,
51 stdair::FacBomManager::linkWithParent (*lInventory_ptr, lAirlineFeature);
53 stdair::FacBomManager::addToListAndMap (ioBomRoot, lAirlineFeature);
55 assert (lInventory_ptr != NULL);
58 const stdair::PeriodStruct lPeriod (iFlightPeriodStruct._dateRange,
59 iFlightPeriodStruct._dow);
60 const stdair::FlightPeriodKey
61 lFlightPeriodKey (iFlightPeriodStruct._flightNumber, lPeriod);
64 stdair::FlightPeriod* lFlightPeriod_ptr = stdair::BomManager::
65 getObjectPtr<stdair::FlightPeriod> (*lInventory_ptr,
66 lFlightPeriodKey.toString());
67 if (lFlightPeriod_ptr != NULL) {
68 throw stdair::ObjectCreationgDuplicationException (
"");
70 assert (lFlightPeriod_ptr == NULL);
74 instance().create (lFlightPeriodKey);
75 stdair::FacBomManager::addToListAndMap (*lInventory_ptr, *lFlightPeriod_ptr);
76 stdair::FacBomManager::linkWithParent (*lInventory_ptr, *lFlightPeriod_ptr);
79 createSegmentPeriods (*lFlightPeriod_ptr, iFlightPeriodStruct);
83 void InventoryGenerator::
84 createSegmentPeriods (stdair::FlightPeriod& ioFlightPeriod,
85 const FlightPeriodStruct& iFlightPeriodStruct) {
89 for (SegmentStructList_T::const_iterator itSegment = lSegmentList.begin();
90 itSegment != lSegmentList.end(); ++itSegment) {
92 const SegmentStruct& lSegment = *itSegment;
95 const stdair::AirportCode_T& lBoardingPoint = lSegment._boardingPoint;
96 const stdair::AirportCode_T& lOffPoint = lSegment._offPoint;
97 const stdair::SegmentPeriodKey lSegmentPeriodKey (lBoardingPoint,
101 stdair::SegmentPeriod& lSegmentPeriod =
stdair::
103 stdair::FacBomManager::addToListAndMap (ioFlightPeriod, lSegmentPeriod);
104 stdair::FacBomManager::linkWithParent (ioFlightPeriod, lSegmentPeriod);