StdAir Logo  1.00.3
C++ Standard Airline IT Object Library
TimePeriod.cpp
Go to the documentation of this file.
1 // //////////////////////////////////////////////////////////////////////
2 // Import section
3 // //////////////////////////////////////////////////////////////////////
4 // STL
5 #include <cassert>
6 #include <sstream>
7 // StdAir
11 
12 namespace stdair {
13 
14  // ////////////////////////////////////////////////////////////////////
15  TimePeriod::TimePeriod()
17  _parent (NULL) {
18  // That constructor is used by the serialisation process
19  }
20 
21  // ////////////////////////////////////////////////////////////////////
22  TimePeriod::TimePeriod (const TimePeriod& iTimePeriod)
23  : _key (iTimePeriod.getKey()), _parent (NULL) {
24  }
25 
26  // ////////////////////////////////////////////////////////////////////
27  TimePeriod::TimePeriod (const Key_T& iKey)
28  : _key (iKey), _parent (NULL) {
29  }
30 
31  // ////////////////////////////////////////////////////////////////////
33  }
34 
35  // ////////////////////////////////////////////////////////////////////
36  std::string TimePeriod::toString() const {
37  std::ostringstream oStr;
38  oStr << describeKey();
39  return oStr.str();
40  }
41 
42  // ////////////////////////////////////////////////////////////////////
43  bool TimePeriod::
44  isDepartureTimeValid (const Time_T& iFlightTime) const {
45 
46  const Time_T& lTimeRangeStart = getTimeRangeStart();
47  const Time_T& lTimeRangeEnd = getTimeRangeEnd();
48 
49  // Check if the departure time is within the time range.
50  if (lTimeRangeStart >= iFlightTime) {
51  // DEBUG
52  STDAIR_LOG_DEBUG ("Time range begin: " << lTimeRangeStart << ", "
53  << "time: " << iFlightTime);
54  return false;
55  }
56  if (lTimeRangeEnd <= iFlightTime) {
57  // DEBUG
58  STDAIR_LOG_DEBUG ("Time range end: " << lTimeRangeEnd << ", "
59  << "time: " << iFlightTime);
60  return false;
61  }
62 
63  return true;
64  }
65 
66 }
67 
const Time_T & getTimeRangeStart() const
Definition: TimePeriod.hpp:88
std::string toString() const
Definition: TimePeriod.cpp:36
Handle on the StdAir library context.
boost::posix_time::time_duration Time_T
virtual ~TimePeriod()
Definition: TimePeriod.cpp:32
const Time_T & getTimeRangeEnd() const
Definition: TimePeriod.hpp:95
const Duration_T DEFAULT_EPSILON_DURATION
Key of time-period.
bool isDepartureTimeValid(const Time_T &) const
Definition: TimePeriod.cpp:44
const std::string describeKey() const
Definition: TimePeriod.hpp:58
#define STDAIR_LOG_DEBUG(iToBeLogged)
Definition: Logger.hpp:32