StdAir Logo  1.00.13
C++ Standard Airline IT Object Library
Loading...
Searching...
No Matches
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
12namespace 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 // ////////////////////////////////////////////////////////////////////
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
#define STDAIR_LOG_DEBUG(iToBeLogged)
Definition Logger.hpp:32
Handle on the StdAir library context.
boost::posix_time::time_duration Time_T
const Duration_T DEFAULT_EPSILON_DURATION
virtual ~TimePeriod()
const Time_T & getTimeRangeStart() const
bool isDepartureTimeValid(const Time_T &) const
const std::string describeKey() const
const Time_T & getTimeRangeEnd() const
std::string toString() const
Key of time-period.