AirSched Logo  0.1.4
C++ Simulated Airline Schedule Manager Library
OnDPeriodStruct.cpp
Go to the documentation of this file.
00001 // //////////////////////////////////////////////////////////////////////
00002 // Import section
00003 // //////////////////////////////////////////////////////////////////////
00004 // STL
00005 #include <cassert>
00006 #include <iostream>
00007 // StdAir
00008 #include <stdair/basic/BasConst_Period_BOM.hpp>
00009 #include <stdair/basic/BasConst_General.hpp>
00010 #include <stdair/basic/BasConst_Inventory.hpp>
00011 #include <stdair/service/Logger.hpp>
00012 // AIRSCHED
00013 #include <airsched/bom/OnDPeriodStruct.hpp>
00014 
00015 namespace AIRSCHED {
00016   // //////////////////////////////////////////////////////////////////////
00017   OnDPeriodStruct::OnDPeriodStruct ()
00018     : _datePeriod (stdair::BOOST_DEFAULT_DATE_PERIOD),
00019       _timeRangeStart (stdair::NULL_BOOST_TIME_DURATION),
00020       _timeRangeEnd (stdair::NULL_BOOST_TIME_DURATION),
00021       _nbOfAirlines(stdair::DEFAULT_NBOFAIRLINES),
00022       _airlineCode (stdair::DEFAULT_NULL_AIRLINE_CODE),
00023       _classCode (stdair::DEFAULT_NULL_CLASS_CODE),
00024       _itSeconds (0) {
00025   }
00026 
00027   // //////////////////////////////////////////////////////////////////////
00028   stdair::Date_T OnDPeriodStruct::getDate() const {
00029     return stdair::Date_T (_itYear, _itMonth, _itDay);
00030   }
00031 
00032   // //////////////////////////////////////////////////////////////////////
00033   stdair::Duration_T OnDPeriodStruct::getTime() const {
00034     return boost::posix_time::hours (_itHours)
00035       + boost::posix_time::minutes (_itMinutes)
00036       + boost::posix_time::seconds (_itSeconds);
00037   }
00038 
00039   // //////////////////////////////////////////////////////////////////////
00040   const std::string OnDPeriodStruct::describe() const {
00041     std::ostringstream ostr;
00042     ostr << _origin << "-" << _destination << ", "
00043          << _datePeriod << ", between  "
00044          << boost::posix_time::to_simple_string(_timeRangeStart)
00045          << " to "
00046          << boost::posix_time::to_simple_string(_timeRangeEnd) << ", "
00047          << _classCode << ", "
00048          << _airlineCode << ", "
00049          << std::endl; 
00050       
00051     return ostr.str();
00052   }
00053 
00054   // //////////////////////////////////////////////////////////////////////
00055   const std::string OnDPeriodStruct::describeTSKey() const {
00056     std::ostringstream ostr;
00057     ostr << _origin << "-" << _destination << ", "
00058          << _airlineCode << ", " << _classCode << std::endl; 
00059       
00060     return ostr.str();
00061   }
00062 
00063   // //////////////////////////////////////////////////////////////////////
00064   const stdair::AirlineCode_T& OnDPeriodStruct::getFirstAirlineCode () const {
00065     assert (_airlineCodeList.size() > 0);
00066     stdair::AirlineCodeList_T::const_iterator itFirstAirlineCode =
00067       _airlineCodeList.begin();
00068     return *itFirstAirlineCode;
00069   }
00070 
00071 }