$treeview $search $mathjax
00001 // ////////////////////////////////////////////////////////////////////// 00002 // Import section 00003 // ////////////////////////////////////////////////////////////////////// 00004 // STL 00005 #include <cassert> 00006 // StdAir 00007 #include <stdair/basic/BasConst_General.hpp> 00008 #include <stdair/bom/SegmentPeriod.hpp> 00009 // AirTSP 00010 #include <airtsp/bom/SegmentPeriodHelper.hpp> 00011 00012 namespace AIRTSP { 00013 // //////////////////////////////////////////////////////////////////// 00014 void SegmentPeriodHelper::fill (stdair::SegmentPeriod& ioSegmentPeriod, 00015 const SegmentStruct& iSegmentStruct) { 00016 // Browse the list of segment cabins and fill the cabin booking 00017 // class map of the BOM segment period. 00018 for (SegmentCabinStructList_T::const_iterator itCabin = 00019 iSegmentStruct._cabinList.begin(); 00020 itCabin != iSegmentStruct._cabinList.end(); ++itCabin) { 00021 const SegmentCabinStruct& lSegmentCabinStruct = *itCabin; 00022 ioSegmentPeriod. 00023 addCabinBookingClassList (lSegmentCabinStruct._cabinCode, 00024 lSegmentCabinStruct._classes); 00025 } 00026 } 00027 00028 // //////////////////////////////////////////////////////////////////// 00029 void SegmentPeriodHelper::fill (stdair::SegmentPeriod& ioSegmentPeriod, 00030 const LegStructList_T& iLegList) { 00031 00032 const stdair::AirportCode_T& lBoardingPoint = 00033 ioSegmentPeriod.getBoardingPoint (); 00034 const stdair::AirportCode_T& lOffPoint = ioSegmentPeriod.getOffPoint(); 00035 stdair::Duration_T lElapsedTime; 00036 00037 // Find the leg which has the same boarding point. 00038 LegStructList_T::const_iterator itLeg = iLegList.begin (); 00039 while (itLeg != iLegList.end()) { 00040 const LegStruct& lLeg = *itLeg; 00041 if (lLeg._boardingPoint == lBoardingPoint) { 00042 break; 00043 } else { 00044 ++itLeg; 00045 } 00046 } 00047 assert (itLeg != iLegList.end()); 00048 const LegStruct& lFirstLeg = *itLeg; 00049 stdair::AirportCode_T lCurrentOffPoint = lFirstLeg._offPoint; 00050 stdair::Duration_T lCurrentOffTime = lFirstLeg._offTime; 00051 00052 // Update the elapsed time. 00053 lElapsedTime += lFirstLeg._elapsed; 00054 00055 // Find the last used leg. 00056 while (lCurrentOffPoint != lOffPoint) { 00057 ++itLeg; 00058 assert (itLeg != iLegList.end()); 00059 00060 const LegStruct& lCurrentLeg = *itLeg; 00061 assert (lCurrentOffPoint == lCurrentLeg._boardingPoint); 00062 // As the boarding point of the current leg is the same as the off point 00063 // of the previous leg (by construction), there is no time difference. 00064 const stdair::Duration_T lStopOverTime = 00065 lCurrentLeg._boardingTime - lCurrentOffTime; 00066 lElapsedTime += lStopOverTime; 00067 00068 // Add the elapsed time of the current leg 00069 lElapsedTime += lCurrentLeg._elapsed; 00070 00071 lCurrentOffTime = lCurrentLeg._offTime; 00072 lCurrentOffPoint = lCurrentLeg._offPoint; 00073 } 00074 const LegStruct& lLastLeg = *itLeg; 00075 00076 // Update the attributes of the segment-period. 00077 ioSegmentPeriod.setBoardingTime (lFirstLeg._boardingTime); 00078 ioSegmentPeriod.setOffTime (lLastLeg._offTime); 00079 ioSegmentPeriod.setBoardingDateOffset (lFirstLeg._boardingDateOffset); 00080 ioSegmentPeriod.setOffDateOffset (lLastLeg._offDateOffset); 00081 ioSegmentPeriod.setElapsedTime (lElapsedTime); 00082 } 00083 00084 }