AirSched Logo  0.1.4
C++ Simulated Airline Schedule Manager Library
LegStruct.cpp
Go to the documentation of this file.
00001 // //////////////////////////////////////////////////////////////////////
00002 // Import section
00003 // //////////////////////////////////////////////////////////////////////
00004 // STL
00005 #include <cassert>
00006 #include <sstream>
00007 // STDAIR
00008 #include <stdair/basic/BasConst_Period_BOM.hpp>
00009 #include <stdair/bom/LegDate.hpp>
00010 // AIRSCHED
00011 #include <airsched/bom/LegStruct.hpp>
00012 
00013 namespace AIRSCHED {
00014 
00015   // //////////////////////////////////////////////////////////////////////
00016   LegStruct::LegStruct ()
00017     : _boardingDateOffset (stdair::DEFAULT_DATE_OFFSET),
00018       _offDateOffset (stdair::DEFAULT_DATE_OFFSET) {
00019   }
00020     
00021   // //////////////////////////////////////////////////////////////////////
00022   const std::string LegStruct::describe() const {
00023     std::ostringstream ostr;
00024     ostr << "    " << _boardingPoint << " / "
00025          << boost::posix_time::to_simple_string(_boardingTime);
00026     if (_boardingDateOffset.days() != 0) {
00027       ostr << " [" << _boardingDateOffset.days() << "]";
00028     }
00029     ostr << " -- " << _offPoint << " / "
00030          << boost::posix_time::to_simple_string(_offTime);
00031     if (_offDateOffset.days() != 0) {
00032       ostr << " [" << _offDateOffset.days() << "]";
00033     }
00034     ostr << " --> "
00035          << boost::posix_time::to_simple_string(_elapsed)
00036          << std::endl;
00037     for (LegCabinStructList_T::const_iterator itCabin = _cabinList.begin();
00038          itCabin != _cabinList.end(); itCabin++) {
00039       const LegCabinStruct& lCabin = *itCabin;
00040       ostr << lCabin.describe();
00041     }
00042     ostr << std::endl;
00043     
00044     return ostr.str();
00045   }
00046 
00047   // //////////////////////////////////////////////////////////////////////
00048   void LegStruct::fill (const stdair::Date_T& iRefDate,
00049                           stdair::LegDate& ioLegDate) const {
00050     // Set the Off Point
00051     ioLegDate.setOffPoint (_offPoint);
00052 
00053     // Set the Boarding Date
00054     ioLegDate.setBoardingDate (iRefDate + _boardingDateOffset);
00055 
00056     // Set the Boarding Time
00057     ioLegDate.setBoardingTime (_boardingTime);
00058       
00059     // Set the Off Date
00060     ioLegDate.setOffDate (iRefDate + _offDateOffset);
00061 
00062     // Set the Off Time
00063     ioLegDate.setOffTime (_offTime);
00064 
00065     // Set the Elapsed Time
00066     ioLegDate.setElapsedTime (_elapsed);
00067   }
00068 
00069 }