1.00.10
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
8
#include <
stdair/basic/BasConst_General.hpp
>
9
#include <
stdair/service/Logger.hpp
>
10
#include <
stdair/bom/TimePeriod.hpp
>
11
12
namespace
stdair
{
13
14
// ////////////////////////////////////////////////////////////////////
15
TimePeriod::TimePeriod()
16
: _key (
DEFAULT_EPSILON_DURATION
,
DEFAULT_EPSILON_DURATION
),
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
// ////////////////////////////////////////////////////////////////////
32
TimePeriod::~TimePeriod
() {
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
stdair::TimePeriod::toString
std::string toString() const
Definition:
TimePeriod.cpp:36
stdair::TimePeriod::getTimeRangeStart
const Time_T & getTimeRangeStart() const
Definition:
TimePeriod.hpp:88
Logger.hpp
stdair::Time_T
boost::posix_time::time_duration Time_T
Definition:
stdair_date_time_types.hpp:23
TimePeriod.hpp
stdair::TimePeriod::isDepartureTimeValid
bool isDepartureTimeValid(const Time_T &) const
Definition:
TimePeriod.cpp:44
stdair::TimePeriod::describeKey
const std::string describeKey() const
Definition:
TimePeriod.hpp:58
stdair
Handle on the StdAir library context.
Definition:
BasChronometer.cpp:9
stdair::TimePeriodKey
Key of time-period.
Definition:
TimePeriodKey.hpp:15
stdair::TimePeriod::getTimeRangeEnd
const Time_T & getTimeRangeEnd() const
Definition:
TimePeriod.hpp:95
STDAIR_LOG_DEBUG
#define STDAIR_LOG_DEBUG(iToBeLogged)
Definition:
Logger.hpp:32
stdair::TimePeriod::~TimePeriod
virtual ~TimePeriod()
Definition:
TimePeriod.cpp:32
stdair::DEFAULT_EPSILON_DURATION
const Duration_T DEFAULT_EPSILON_DURATION
BasConst_General.hpp
Generated for StdAir by
1.8.18