StdAir Logo  0.43.0
C++ Standard Airline IT Library
DatePeriod.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/service/Logger.hpp>
00010 #include <stdair/bom/DatePeriod.hpp>
00011 
00012 namespace stdair {
00013 
00014   // ////////////////////////////////////////////////////////////////////
00015   DatePeriod::DatePeriod()
00016     : _key (BOOST_DEFAULT_DATE_PERIOD),
00017       _parent (NULL)  {
00018     // That constructor is used by the serialisation process
00019   }
00020 
00021   // ////////////////////////////////////////////////////////////////////
00022   DatePeriod::DatePeriod (const DatePeriod& iDatePeriod)
00023     : _key (iDatePeriod.getKey()), _parent (NULL)  {
00024     assert (false);
00025   }
00026 
00027   // ////////////////////////////////////////////////////////////////////
00028   DatePeriod::DatePeriod (const Key_T& iKey)
00029     : _key (iKey), _parent (NULL)  {
00030   }
00031 
00032   // ////////////////////////////////////////////////////////////////////
00033   DatePeriod::~DatePeriod () {
00034   }
00035 
00036   // ////////////////////////////////////////////////////////////////////
00037   std::string DatePeriod::toString() const {
00038     std::ostringstream oStr;
00039     oStr << describeKey();
00040     return oStr.str();
00041   }
00042   
00043   // ////////////////////////////////////////////////////////////////////
00044   bool DatePeriod::
00045   isDepartureDateValid (const Date_T& iFlightDate) const {
00046 
00047     // Check if the departure date is within the date range.
00048     const DatePeriod_T& lPeriod = getDatePeriod ();
00049     if (lPeriod.contains (iFlightDate) == false) {
00050       return false;
00051     }
00052 
00053     return true;
00054   }
00055   
00056 }
00057