Go to the documentation of this file.00001
00002
00003
00004
00005 #include <cassert>
00006
00007 #include <stdair/basic/BasConst_General.hpp>
00008 #include <stdair/bom/SegmentPeriod.hpp>
00009
00010 #include <airsched/bom/SegmentPeriodHelper.hpp>
00011
00012 namespace AIRSCHED {
00013
00014 void SegmentPeriodHelper::fill (stdair::SegmentPeriod& ioSegmentPeriod,
00015 const SegmentStruct& iSegmentStruct) {
00016
00017
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
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
00053 lElapsedTime += lFirstLeg._elapsed;
00054
00055
00056 while (lCurrentOffPoint != lOffPoint) {
00057 ++itLeg;
00058 assert (itLeg != iLegList.end());
00059
00060 const LegStruct& lCurrentLeg = *itLeg;
00061 assert (lCurrentOffPoint == lCurrentLeg._boardingPoint);
00062
00063
00064 const stdair::Duration_T lStopOverTime =
00065 lCurrentLeg._boardingTime - lCurrentOffTime;
00066 lElapsedTime += lStopOverTime;
00067
00068
00069 lElapsedTime += lCurrentLeg._elapsed;
00070
00071 lCurrentOffTime = lCurrentLeg._offTime;
00072 lCurrentOffPoint = lCurrentLeg._offPoint;
00073 }
00074 const LegStruct& lLastLeg = *itLeg;
00075
00076
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 }