StdAir Logo  0.45.1
C++ Standard Airline IT Object Library
TimePeriod.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_General.hpp>
00009 #include <stdair/service/Logger.hpp>
00010 #include <stdair/bom/TimePeriod.hpp>
00011 
00012 namespace stdair {
00013 
00014   // ////////////////////////////////////////////////////////////////////
00015   TimePeriod::TimePeriod()
00016     : _key (DEFAULT_EPSILON_DURATION, DEFAULT_EPSILON_DURATION),
00017       _parent (NULL)  {
00018     // That constructor is used by the serialisation process
00019   }
00020 
00021   // ////////////////////////////////////////////////////////////////////
00022   TimePeriod::TimePeriod (const TimePeriod& iTimePeriod)
00023     : _key (iTimePeriod.getKey()), _parent (NULL)  {
00024     assert (false);
00025   }
00026 
00027   // ////////////////////////////////////////////////////////////////////
00028   TimePeriod::TimePeriod (const Key_T& iKey)
00029     : _key (iKey), _parent (NULL)  {
00030   }
00031 
00032   // ////////////////////////////////////////////////////////////////////
00033   TimePeriod::~TimePeriod () {
00034   }
00035   
00036   // ////////////////////////////////////////////////////////////////////
00037   std::string TimePeriod::toString() const {
00038     std::ostringstream oStr;
00039     oStr << describeKey();
00040     return oStr.str();
00041   }
00042   
00043   // ////////////////////////////////////////////////////////////////////
00044   bool TimePeriod::
00045   isDepartureTimeValid (const Time_T& iFlightTime) const {
00046 
00047     const Time_T& lTimeRangeStart = getTimeRangeStart();
00048     const Time_T& lTimeRangeEnd = getTimeRangeEnd();
00049     
00050     // Check if the departure time is within the time range.
00051     if (lTimeRangeStart >= iFlightTime) {
00052       // DEBUG
00053       STDAIR_LOG_DEBUG ("Time range begin: " << lTimeRangeStart << ", "
00054                         << "time: " << iFlightTime);
00055       return false;
00056     }
00057     if (lTimeRangeEnd <= iFlightTime) {
00058       // DEBUG
00059       STDAIR_LOG_DEBUG ("Time range end: " << lTimeRangeEnd << ", "
00060                         << "time: " << iFlightTime);
00061       return false;
00062     }
00063 
00064     return true;
00065   }
00066   
00067 }
00068 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines