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/BomManager.hpp>
00009 #include <stdair/bom/SegmentDate.hpp>
00010 #include <stdair/bom/SegmentCabin.hpp>
00011 #include <stdair/bom/LegDate.hpp>
00012
00013 #include <airinv/bom/SegmentDateHelper.hpp>
00014 #include <airinv/bom/SegmentCabinHelper.hpp>
00015
00016 namespace AIRINV {
00017
00018 void SegmentDateHelper::fillFromRouting (stdair::SegmentDate& ioSegmentDate) {
00019
00020
00021
00022
00023
00024 stdair::SegmentDate* lOperatingSegmentDate_ptr =
00025 ioSegmentDate.getOperatingSegmentDate ();
00026 if (lOperatingSegmentDate_ptr != NULL) {
00027 fillFromRouting (*lOperatingSegmentDate_ptr);
00028 return;
00029 }
00030
00031
00032
00033 const stdair::LegDateList_T& lLegDateList =
00034 stdair::BomManager::getList<stdair::LegDate> (ioSegmentDate);
00035 stdair::LegDateList_T::const_iterator itFirstLeg = lLegDateList.begin();
00036 const stdair::LegDate* lFirstLeg_ptr = *itFirstLeg;
00037 assert (lFirstLeg_ptr != NULL);
00038 stdair::LegDateList_T::const_reverse_iterator itLastLeg =
00039 lLegDateList.rbegin();
00040 const stdair::LegDate* lLastLeg_ptr = *itLastLeg;
00041 assert (lLastLeg_ptr != NULL);
00042
00043
00044 const stdair::Date_T& lBoardingDate = lFirstLeg_ptr->getBoardingDate();
00045 ioSegmentDate.setBoardingDate (lBoardingDate);
00046
00047 const stdair::Duration_T& lBoardingTime = lFirstLeg_ptr->getBoardingTime();
00048 ioSegmentDate.setBoardingTime (lBoardingTime);
00049
00050 const stdair::Date_T& lOffDate = lLastLeg_ptr->getOffDate();
00051 ioSegmentDate.setOffDate (lOffDate);
00052
00053 const stdair::Duration_T& lOffTime = lLastLeg_ptr->getOffTime();
00054 ioSegmentDate.setOffTime (lOffTime);
00055
00056 updateElapsedTimeFromRouting (ioSegmentDate);
00057
00058
00059 const stdair::SegmentCabinList_T& lSegmentCabinList =
00060 stdair::BomManager::getList<stdair::SegmentCabin> (ioSegmentDate);
00061 for (stdair::SegmentCabinList_T::const_iterator itSC =
00062 lSegmentCabinList.begin(); itSC != lSegmentCabinList.end(); ++itSC) {
00063 stdair::SegmentCabin* lSC_ptr = *itSC;
00064 assert (lSC_ptr != NULL);
00065
00066
00067 SegmentCabinHelper::initialiseAU (*lSC_ptr);
00068 }
00069 }
00070
00071
00072 void SegmentDateHelper::
00073 updateElapsedTimeFromRouting (stdair::SegmentDate& ioSegmentDate) {
00074
00075 const stdair::LegDateList_T& lLegDateList =
00076 stdair::BomManager::getList<stdair::LegDate> (ioSegmentDate);
00077
00078 stdair::LegDateList_T::const_iterator itLegDate = lLegDateList.begin();
00079 const stdair::LegDate* lCurrentLegDate_ptr = *itLegDate;
00080 assert (lCurrentLegDate_ptr != NULL);
00081
00082
00083 stdair::Duration_T lElapsedTime = lCurrentLegDate_ptr->getElapsedTime();
00084
00085
00086
00087 ++itLegDate;
00088
00089 for (const stdair::LegDate* lPreviousLegDate_ptr = lCurrentLegDate_ptr;
00090 itLegDate != lLegDateList.end();
00091 ++itLegDate, lPreviousLegDate_ptr = lCurrentLegDate_ptr) {
00092 lCurrentLegDate_ptr = *itLegDate;
00093
00094
00095
00096 assert (lCurrentLegDate_ptr->getBoardingPoint()
00097 == lPreviousLegDate_ptr->getOffPoint());
00098 const stdair::Duration_T& lStopOverTime =
00099 lCurrentLegDate_ptr->getBoardingTime() - lPreviousLegDate_ptr->getOffTime();
00100 lElapsedTime += lStopOverTime;
00101
00102
00103 const stdair::Duration_T& currentElapsedTime =
00104 lCurrentLegDate_ptr->getElapsedTime();
00105 lElapsedTime += currentElapsedTime;
00106 }
00107
00108
00109 ioSegmentDate.setElapsedTime (lElapsedTime);
00110
00111 updateDistanceFromElapsedTime (ioSegmentDate);
00112 }
00113
00114
00115 void SegmentDateHelper::
00116 updateDistanceFromElapsedTime (stdair::SegmentDate& ioSegmentDate) {
00117 const stdair::Duration_T& lElapsedTime = ioSegmentDate.getElapsedTime();
00118 const double lElapseInHours=static_cast<const double>(lElapsedTime.hours());
00119 const long int lDistance =
00120 static_cast<const long int>(stdair::DEFAULT_FLIGHT_SPEED*lElapseInHours);
00121 ioSegmentDate.setDistance (lDistance);
00122 }
00123
00124 }