8 #include <stdair/basic/BasConst_Inventory.hpp>
9 #include <stdair/bom/BomManager.hpp>
10 #include <stdair/bom/BomRoot.hpp>
11 #include <stdair/bom/Inventory.hpp>
12 #include <stdair/bom/FlightPeriod.hpp>
13 #include <stdair/bom/SegmentPeriod.hpp>
14 #include <stdair/factory/FacBomManager.hpp>
15 #include <stdair/service/Logger.hpp>
29 const stdair::InventoryList_T& lInventoryList =
30 stdair::BomManager::getList<stdair::Inventory> (iBomRoot);
31 for (stdair::InventoryList_T::const_iterator itInv = lInventoryList.begin();
32 itInv != lInventoryList.end(); ++itInv) {
33 const stdair::Inventory* lCurrentInventory_ptr = *itInv;
34 assert (lCurrentInventory_ptr != NULL);
37 createSinglePaths (*lCurrentInventory_ptr);
42 for (stdair::NbOfSegments_T i = 2;
43 i <= stdair::MAXIMAL_NUMBER_OF_SEGMENTS_IN_OND; ++i) {
44 buildSegmentPathNetwork (iBomRoot, i);
49 void SegmentPathGenerator::
50 createSinglePaths (
const stdair::Inventory& iInventory) {
52 const stdair::FlightPeriodList_T& lFlightPeriodList =
53 stdair::BomManager::getList<stdair::FlightPeriod> (iInventory);
54 for (stdair::FlightPeriodList_T::const_iterator itFlightPeriod =
55 lFlightPeriodList.begin();
56 itFlightPeriod != lFlightPeriodList.end(); ++itFlightPeriod) {
57 const stdair::FlightPeriod* lCurrentFlightPeriod_ptr = *itFlightPeriod;
58 assert (lCurrentFlightPeriod_ptr != NULL);
61 createSinglePaths (*lCurrentFlightPeriod_ptr);
66 void SegmentPathGenerator::
67 createSinglePaths (
const stdair::FlightPeriod& iFlightPeriod) {
69 const stdair::SegmentPeriodList_T& lSegmentPeriodList =
70 stdair::BomManager::getList<stdair::SegmentPeriod> (iFlightPeriod);
71 for (stdair::SegmentPeriodList_T::const_iterator itSegmentPeriod =
72 lSegmentPeriodList.begin();
73 itSegmentPeriod != lSegmentPeriodList.end(); ++itSegmentPeriod) {
74 stdair::SegmentPeriod* lCurrentSegmentPeriod_ptr = *itSegmentPeriod;
75 assert (lCurrentSegmentPeriod_ptr != NULL);
78 createSinglePath (*lCurrentSegmentPeriod_ptr);
83 void SegmentPathGenerator::
84 createSinglePath (stdair::SegmentPeriod& ioSegmentPeriod) {
87 const stdair::AirportCode_T& lOrigin = ioSegmentPeriod.getBoardingPoint();
88 const stdair::FlightPeriod& lFlightPeriod =
89 stdair::BomManager::getParent<stdair::FlightPeriod> (ioSegmentPeriod);
90 const stdair::Inventory& lInventory =
91 stdair::BomManager::getParent<stdair::Inventory> (lFlightPeriod);
92 stdair::BomRoot& lBomRoot =
93 stdair::BomManager::getParent<stdair::BomRoot> (lInventory);
97 ReachableUniverse* lReachableUniverse_ptr =
98 stdair::BomManager::getObjectPtr<ReachableUniverse> (lBomRoot, lOrigin);
99 if (lReachableUniverse_ptr == NULL) {
100 ReachableUniverseKey lKey (lOrigin);
101 lReachableUniverse_ptr =
103 stdair::FacBomManager::addToListAndMap (lBomRoot, *lReachableUniverse_ptr);
104 stdair::FacBomManager::linkWithParent (lBomRoot, *lReachableUniverse_ptr);
106 assert (lReachableUniverse_ptr != NULL);
109 createSinglePath (*lReachableUniverse_ptr, ioSegmentPeriod);
113 void SegmentPathGenerator::
114 createSinglePath (ReachableUniverse& ioReachableUniverse,
115 stdair::SegmentPeriod& ioSegmentPeriod) {
117 const stdair::AirportCode_T& lDestination = ioSegmentPeriod.getOffPoint();
121 OriginDestinationSet* lOriginDestinationSet_ptr =
122 stdair::BomManager::getObjectPtr<OriginDestinationSet>(ioReachableUniverse,
124 if (lOriginDestinationSet_ptr == NULL) {
125 OriginDestinationSetKey lKey (lDestination);
127 lOriginDestinationSet_ptr =
129 stdair::FacBomManager::addToListAndMap (ioReachableUniverse,
130 *lOriginDestinationSet_ptr);
131 stdair::FacBomManager::linkWithParent (ioReachableUniverse,
132 *lOriginDestinationSet_ptr);
134 assert (lOriginDestinationSet_ptr != NULL);
138 const stdair::FlightPeriod& lFlightPeriod =
139 stdair::BomManager::getParent<stdair::FlightPeriod> (ioSegmentPeriod);
140 const stdair::PeriodStruct& lPeriodOfFlight = lFlightPeriod.getPeriod();
144 const stdair::DateOffset_T& lBoardingDateOffset =
145 ioSegmentPeriod.getBoardingDateOffset();
147 const stdair::PeriodStruct lPeriodOfSegment =
148 lPeriodOfFlight.addDateOffset (lBoardingDateOffset);
150 const stdair::Duration_T& lBoardingTime = ioSegmentPeriod.getBoardingTime();
151 const stdair::Duration_T& lElapsed = ioSegmentPeriod.getElapsedTime();
154 const stdair::DateOffset_T lFirstDateOffset (0);
155 lDateOffsetList.push_back (lFirstDateOffset);
157 const SegmentPathPeriodKey lSegmentPathKey (lPeriodOfSegment,
158 lBoardingTime, lElapsed,
161 SegmentPathPeriod& lSegmentPathPeriod =
170 addSegmentPathPeriod (ioReachableUniverse, lSegmentPathPeriod);
174 stdair::FacBomManager::addToList (*lOriginDestinationSet_ptr,
176 stdair::FacBomManager::linkWithParent (*lOriginDestinationSet_ptr,
181 stdair::FacBomManager::addToList (lSegmentPathPeriod,
186 void SegmentPathGenerator::
187 addSegmentPathPeriod (ReachableUniverse& ioReachableUniverse,
188 const SegmentPathPeriod& iSegmentPathPeriod) {
190 const stdair::NbOfSegments_T& lNbOfSegments =
191 iSegmentPathPeriod.getNbOfSegments();
193 assert (lNbOfSegments > 0
194 && lNbOfSegments <= stdair::MAXIMAL_NUMBER_OF_SEGMENTS_IN_OND);
200 ioReachableUniverse._segmentPathPeriodListList;
201 while (lSegmentPathPeriodListList.size() < lNbOfSegments) {
203 lSegmentPathPeriodListList.push_back (lSegmentPathPeriodList);
209 lSegmentPathPeriodListList.at (lNbOfSegments-1);
212 lSegmentPathPeriodList.push_back (&iSegmentPathPeriod);
216 void SegmentPathGenerator::
217 buildSegmentPathNetwork (
const stdair::BomRoot& iBomRoot,
218 const stdair::NbOfSegments_T& lNbOfSegments) {
226 stdair::BomManager::getList<ReachableUniverse> (iBomRoot);
227 for (ReachableUniverseList_T::const_iterator itReachableUniverse =
228 lReachableUniverseList.begin();
229 itReachableUniverse != lReachableUniverseList.end();
230 ++itReachableUniverse) {
231 ReachableUniverse* lReachableUniverse_ptr = *itReachableUniverse;
232 assert (lReachableUniverse_ptr != NULL);
235 buildSegmentPathNetwork (*lReachableUniverse_ptr, lNbOfSegments);
240 void SegmentPathGenerator::
241 buildSegmentPathNetwork (ReachableUniverse& ioReachableUniverse,
242 const stdair::NbOfSegments_T& iNbOfSegments) {
262 ioReachableUniverse.getSegmentPathPeriodListList();
263 const unsigned short lNbOfSegments_m1 = iNbOfSegments - 1;
264 assert (lNbOfSegments_m1 >= 0);
265 if (lSegmentPathPeriodListList.size() < lNbOfSegments_m1) {
280 lSegmentPathPeriodListList.at (iNbOfSegments-2);
289 for (SegmentPathPeriodLightList_T::const_iterator itSegmentPathPeriodList =
290 lSegmentPathPeriodLightList_im1.begin();
291 itSegmentPathPeriodList != lSegmentPathPeriodLightList_im1.end();
292 ++itSegmentPathPeriodList) {
293 const SegmentPathPeriod* lSegmentPathPeriod_im1_ptr =
294 *itSegmentPathPeriodList;
295 assert (lSegmentPathPeriod_im1_ptr != NULL);
299 const stdair::AirportCode_T& lDestination_im1 =
300 lSegmentPathPeriod_im1_ptr->getDestination();
301 const stdair::BomRoot& lBomRoot =
302 stdair::BomManager::getParent<stdair::BomRoot> (ioReachableUniverse);
303 const ReachableUniverse* lReachableUniverseFromDestination_im1_ptr =
304 stdair::BomManager::getObjectPtr<ReachableUniverse> (lBomRoot,
312 if (lReachableUniverseFromDestination_im1_ptr == NULL) {
315 assert (lReachableUniverseFromDestination_im1_ptr != NULL);
320 lSegmentPathPeriodListListFromDestination_im1 =
321 lReachableUniverseFromDestination_im1_ptr->
322 getSegmentPathPeriodListList();
323 assert (lSegmentPathPeriodListListFromDestination_im1.size() >= 1);
330 lSegmentPathPeriodListListFromDestination_im1.at (0);
332 for (SegmentPathPeriodLightList_T::const_iterator
333 itSegmentPathPeriodFromDestination_im1 =
334 lSingleSegmentPathPeriodLightListFromDestination_im1.begin();
335 itSegmentPathPeriodFromDestination_im1
336 != lSingleSegmentPathPeriodLightListFromDestination_im1.end();
337 ++itSegmentPathPeriodFromDestination_im1) {
338 const SegmentPathPeriod* lSingleSegmentPathPeriodFromDestination_im1_ptr=
339 *itSegmentPathPeriodFromDestination_im1;
340 assert (lSingleSegmentPathPeriodFromDestination_im1_ptr != NULL);
354 SegmentPathPeriodKey lSegmentPathPeriodKey_i =
355 lSegmentPathPeriod_im1_ptr->connectWithAnotherSegment (*lSingleSegmentPathPeriodFromDestination_im1_ptr);
357 if (lSegmentPathPeriodKey_i.isValid () ==
false) {
364 const stdair::AirportCode_T& lDestination_i =
365 lSingleSegmentPathPeriodFromDestination_im1_ptr->getDestination();
369 stdair::SegmentPeriod* lSegmentPeriod_1_ptr =
370 lSingleSegmentPathPeriodFromDestination_im1_ptr->getFirstSegmentPeriod();
371 assert (lSegmentPeriod_1_ptr != NULL);
375 const stdair::FlightPeriod& lFlightPeriod = stdair::BomManager::
376 getParent<stdair::FlightPeriod> (*lSegmentPeriod_1_ptr);
377 const stdair::Inventory& lInventory =
378 stdair::BomManager::getParent<stdair::Inventory> (lFlightPeriod);
379 const stdair::AirlineCode_T& lAirlineCode_1 =lInventory.getAirlineCode();
380 stdair::NbOfAirlines_T lNbOfAirlines_i =
381 lSegmentPathPeriod_im1_ptr->getNbOfAirlines();
382 if (lSegmentPathPeriod_im1_ptr->isAirlineFlown(lAirlineCode_1) ==
false){
385 lSegmentPathPeriodKey_i.setNbOfAirlines (lNbOfAirlines_i);
388 OriginDestinationSet* lOriginDestinationSet_ptr = stdair::BomManager::
389 getObjectPtr<OriginDestinationSet>(ioReachableUniverse,lDestination_i);
390 if (lOriginDestinationSet_ptr == NULL) {
391 OriginDestinationSetKey lKey (lDestination_i);
392 lOriginDestinationSet_ptr =
394 stdair::FacBomManager::addToListAndMap (ioReachableUniverse,
395 *lOriginDestinationSet_ptr);
396 stdair::FacBomManager::linkWithParent (ioReachableUniverse,
397 *lOriginDestinationSet_ptr);
399 assert (lOriginDestinationSet_ptr != NULL);
402 SegmentPathPeriod& lSegmentPathPeriod_i =
stdair::
404 stdair::FacBomManager::addToList (*lOriginDestinationSet_ptr,
405 lSegmentPathPeriod_i);
406 stdair::FacBomManager::linkWithParent (*lOriginDestinationSet_ptr,
407 lSegmentPathPeriod_i);
411 stdair::FacBomManager::
412 cloneHolder<stdair::SegmentPeriod> (lSegmentPathPeriod_i,
413 *lSegmentPathPeriod_im1_ptr);
421 stdair::FacBomManager::addToList (lSegmentPathPeriod_i,
422 *lSegmentPeriod_1_ptr);
431 addSegmentPathPeriod (ioReachableUniverse, lSegmentPathPeriod_i);