1.01.17
C++ Simulated Airline Travel Solution Provider (TSP) Library
Toggle main menu visibility
Loading...
Searching...
No Matches
SegmentPeriodHelper.cpp
Go to the documentation of this file.
1
// //////////////////////////////////////////////////////////////////////
2
// Import section
3
// //////////////////////////////////////////////////////////////////////
4
// STL
5
#include <cassert>
6
// StdAir
7
#include <stdair/basic/BasConst_General.hpp>
8
#include <stdair/bom/SegmentPeriod.hpp>
9
// AirTSP
10
#include <
airtsp/bom/SegmentPeriodHelper.hpp
>
11
12
namespace
AIRTSP
{
13
// ////////////////////////////////////////////////////////////////////
14
void
SegmentPeriodHelper::fill
(stdair::SegmentPeriod& ioSegmentPeriod,
15
const
SegmentStruct
& iSegmentStruct) {
16
// Browse the list of segment cabins and fill the cabin booking
17
// class map of the BOM segment period.
18
for
(SegmentCabinStructList_T::const_iterator itCabin =
19
iSegmentStruct.
_cabinList
.begin();
20
itCabin != iSegmentStruct.
_cabinList
.end(); ++itCabin) {
21
const
SegmentCabinStruct
& lSegmentCabinStruct = *itCabin;
22
ioSegmentPeriod.
23
addCabinBookingClassList (lSegmentCabinStruct.
_cabinCode
,
24
lSegmentCabinStruct.
_classes
);
25
}
26
}
27
28
// ////////////////////////////////////////////////////////////////////
29
void
SegmentPeriodHelper::fill
(stdair::SegmentPeriod& ioSegmentPeriod,
30
const
LegStructList_T
& iLegList) {
31
32
const
stdair::AirportCode_T& lBoardingPoint =
33
ioSegmentPeriod.getBoardingPoint ();
34
const
stdair::AirportCode_T& lOffPoint = ioSegmentPeriod.getOffPoint();
35
stdair::Duration_T lElapsedTime;
36
37
// Find the leg which has the same boarding point.
38
LegStructList_T::const_iterator itLeg = iLegList.begin ();
39
while
(itLeg != iLegList.end()) {
40
const
LegStruct
& lLeg = *itLeg;
41
if
(lLeg.
_boardingPoint
== lBoardingPoint) {
42
break
;
43
}
else
{
44
++itLeg;
45
}
46
}
47
assert (itLeg != iLegList.end());
48
const
LegStruct
& lFirstLeg = *itLeg;
49
stdair::AirportCode_T lCurrentOffPoint = lFirstLeg.
_offPoint
;
50
stdair::Duration_T lCurrentOffTime = lFirstLeg.
_offTime
;
51
52
// Update the elapsed time.
53
lElapsedTime += lFirstLeg.
_elapsed
;
54
55
// Find the last used leg.
56
while
(lCurrentOffPoint != lOffPoint) {
57
++itLeg;
58
assert (itLeg != iLegList.end());
59
60
const
LegStruct
& lCurrentLeg = *itLeg;
61
assert (lCurrentOffPoint == lCurrentLeg.
_boardingPoint
);
62
// As the boarding point of the current leg is the same as the off point
63
// of the previous leg (by construction), there is no time difference.
64
const
stdair::Duration_T lStopOverTime =
65
lCurrentLeg.
_boardingTime
- lCurrentOffTime;
66
lElapsedTime += lStopOverTime;
67
68
// Add the elapsed time of the current leg
69
lElapsedTime += lCurrentLeg.
_elapsed
;
70
71
lCurrentOffTime = lCurrentLeg.
_offTime
;
72
lCurrentOffPoint = lCurrentLeg.
_offPoint
;
73
}
74
const
LegStruct
& lLastLeg = *itLeg;
75
76
// Update the attributes of the segment-period.
77
ioSegmentPeriod.setBoardingTime (lFirstLeg.
_boardingTime
);
78
ioSegmentPeriod.setOffTime (lLastLeg.
_offTime
);
79
ioSegmentPeriod.setBoardingDateOffset (lFirstLeg.
_boardingDateOffset
);
80
ioSegmentPeriod.setOffDateOffset (lLastLeg.
_offDateOffset
);
81
ioSegmentPeriod.setElapsedTime (lElapsedTime);
82
}
83
84
}
SegmentPeriodHelper.hpp
AIRTSP::SegmentPeriodHelper::fill
static void fill(stdair::SegmentPeriod &, const SegmentStruct &)
Definition
SegmentPeriodHelper.cpp:14
AIRTSP
Definition
AIRTSP_Service.hpp:23
AIRTSP::LegStructList_T
std::vector< LegStruct > LegStructList_T
Definition
LegStruct.hpp:52
AIRTSP::LegStruct
Definition
LegStruct.hpp:24
AIRTSP::LegStruct::_boardingTime
stdair::Duration_T _boardingTime
Definition
LegStruct.hpp:30
AIRTSP::LegStruct::_boardingDateOffset
stdair::DateOffset_T _boardingDateOffset
Definition
LegStruct.hpp:29
AIRTSP::LegStruct::_boardingPoint
stdair::AirportCode_T _boardingPoint
Definition
LegStruct.hpp:28
AIRTSP::LegStruct::_offPoint
stdair::AirportCode_T _offPoint
Definition
LegStruct.hpp:31
AIRTSP::LegStruct::_offDateOffset
stdair::DateOffset_T _offDateOffset
Definition
LegStruct.hpp:32
AIRTSP::LegStruct::_elapsed
stdair::Duration_T _elapsed
Definition
LegStruct.hpp:34
AIRTSP::LegStruct::_offTime
stdair::Duration_T _offTime
Definition
LegStruct.hpp:33
AIRTSP::SegmentCabinStruct
Definition
SegmentCabinStruct.hpp:24
AIRTSP::SegmentCabinStruct::_cabinCode
stdair::CabinCode_T _cabinCode
Definition
SegmentCabinStruct.hpp:26
AIRTSP::SegmentCabinStruct::_classes
stdair::ClassList_String_T _classes
Definition
SegmentCabinStruct.hpp:27
AIRTSP::SegmentStruct
Definition
SegmentStruct.hpp:24
AIRTSP::SegmentStruct::_cabinList
SegmentCabinStructList_T _cabinList
Definition
SegmentStruct.hpp:33
Generated on
for AirTSP by
1.17.0