8 #include <boost/archive/text_iarchive.hpp>
9 #include <boost/archive/text_oarchive.hpp>
10 #include <boost/serialization/access.hpp>
12 #include <stdair/basic/BasConst_General.hpp>
13 #include <stdair/basic/BasConst_Inventory.hpp>
14 #include <stdair/basic/BasConst_Period_BOM.hpp>
15 #include <stdair/basic/BasConst_TravelSolution.hpp>
16 #include <stdair/bom/Inventory.hpp>
17 #include <stdair/bom/FlightPeriod.hpp>
18 #include <stdair/bom/SegmentPeriod.hpp>
19 #include <stdair/bom/BomManager.hpp>
26 SegmentPathPeriod::SegmentPathPeriod()
27 : _key (stdair::PeriodStruct (stdair::BOOST_DEFAULT_DATE_PERIOD,
28 stdair::DEFAULT_DOW_STRING),
29 stdair::NULL_BOOST_TIME_DURATION, stdair::NULL_BOOST_TIME_DURATION,
31 stdair::DEFAULT_NBOFAIRLINES),
37 SegmentPathPeriod::SegmentPathPeriod (
const SegmentPathPeriod& iSPP)
38 : _key (iSPP._key), _parent (NULL) {
43 SegmentPathPeriod::SegmentPathPeriod (
const Key_T& iKey)
44 : _key (iKey), _parent (NULL) {
53 std::ostringstream oStr;
59 void SegmentPathPeriod::serialisationImplementationExport()
const {
60 std::ostringstream oStr;
61 boost::archive::text_oarchive oa (oStr);
66 void SegmentPathPeriod::serialisationImplementationImport() {
67 std::istringstream iStr;
68 boost::archive::text_iarchive ia (iStr);
73 template<
class Archive>
75 const unsigned int iFileVersion) {
81 namespace ba = boost::archive;
83 void SegmentPathPeriod::serialize<ba::text_oarchive> (ba::text_oarchive&,
86 void SegmentPathPeriod::serialize<ba::text_iarchive> (ba::text_iarchive&,
93 const stdair::SegmentPeriodList_T& lSegmentPeriodList =
94 stdair::BomManager::getList<stdair::SegmentPeriod> (*this);
95 stdair::SegmentPeriodList_T::const_reverse_iterator itLastSegment =
96 lSegmentPeriodList.rbegin();
98 if (itLastSegment == lSegmentPeriodList.rend()) {
102 stdair::SegmentPeriod* oSegment_ptr = *itLastSegment;
103 assert (oSegment_ptr != NULL);
111 const stdair::SegmentPeriodList_T& lSegmentPeriodList =
112 stdair::BomManager::getList<stdair::SegmentPeriod> (*this);
113 stdair::SegmentPeriodList_T::const_iterator itFirstSegment =
114 lSegmentPeriodList.begin();
116 if (itFirstSegment == lSegmentPeriodList.end()) {
120 stdair::SegmentPeriod* oSegment_ptr = *itFirstSegment;
121 assert (oSegment_ptr != NULL);
129 assert (lLastSegment_ptr != NULL);
130 return lLastSegment_ptr->getOffPoint();
136 bool oAirlineFlown =
false;
138 const stdair::SegmentPeriodList_T& lSegmentPeriodList =
139 stdair::BomManager::getList<stdair::SegmentPeriod> (*this);
140 for (stdair::SegmentPeriodList_T::const_iterator itSegmentPeriod =
141 lSegmentPeriodList.begin();
142 itSegmentPeriod != lSegmentPeriodList.end(); ++itSegmentPeriod) {
143 const stdair::SegmentPeriod* lSegmentPeriod_ptr = *itSegmentPeriod;
144 assert (lSegmentPeriod_ptr != NULL);
146 const stdair::FlightPeriod& lFlightPeriod =
147 stdair::BomManager::getParent<stdair::FlightPeriod>(*lSegmentPeriod_ptr);
148 const stdair::Inventory& lInventory =
149 stdair::BomManager::getParent<stdair::Inventory> (lFlightPeriod);
150 const stdair::AirlineCode_T& lSegmentAirlineCode =
151 lInventory.getAirlineCode ();
152 if (lSegmentAirlineCode == iAirlineCode) {
153 oAirlineFlown =
true;
158 return oAirlineFlown;
167 const stdair::SegmentPeriod* lNextSegmentPeriod_ptr =
169 assert (lNextSegmentPeriod_ptr != NULL);
176 assert (lLastSegmentPeriod_ptr != NULL);
177 const stdair::FlightPeriod& lLastFlightPeriod = stdair::BomManager::
178 getParent<stdair::FlightPeriod> (*lLastSegmentPeriod_ptr);
179 const stdair::Inventory& lLastInventory =
180 stdair::BomManager::getParent<stdair::Inventory> (lLastFlightPeriod);
182 const stdair::FlightPeriod& lNextFlightPeriod = stdair::BomManager::
183 getParent<stdair::FlightPeriod> (*lNextSegmentPeriod_ptr);
184 const stdair::Inventory& lNextInventory =
185 stdair::BomManager::getParent<stdair::Inventory> (lNextFlightPeriod);
187 if (lLastFlightPeriod.getFlightNumber()==lNextFlightPeriod.getFlightNumber()
188 && lLastInventory.getAirlineCode() == lNextInventory.getAirlineCode()) {
189 return oSegmentPathPeriodKey;
193 const stdair::AirportCode_T& lDestination =
194 lNextSegmentPeriod_ptr->getOffPoint();
196 return oSegmentPathPeriodKey;
206 const stdair::PeriodStruct& lNextDeparturePeriod =
208 const stdair::Duration_T& lLastOffTime =
209 lLastSegmentPeriod_ptr->getOffTime();
210 const stdair::Duration_T& lNextBoardingTime =
211 lNextSegmentPeriod_ptr->getBoardingTime();
216 if (lNextBoardingTime >= lLastOffTime) {
217 const stdair::Duration_T lStopTime = lNextBoardingTime - lLastOffTime;
218 if (lStopTime < stdair::DEFAULT_MINIMAL_CONNECTION_TIME) {
219 return oSegmentPathPeriodKey;
225 const stdair::DateOffset_T& lLastBoardingDateOffset =
227 const stdair::DateOffset_T lNextBoardingDateOffset =
228 lLastBoardingDateOffset + lLastSegmentPeriod_ptr->getOffDateOffset()
229 - lLastSegmentPeriod_ptr->getBoardingDateOffset();
230 const stdair::DateOffset_T lNegativeNextBoardingDateOffset =
231 stdair::DateOffset_T (0) - lNextBoardingDateOffset;
235 const stdair::PeriodStruct lAdjustedNextDeparturePeriod =
236 lNextDeparturePeriod.addDateOffset (lNegativeNextBoardingDateOffset);
239 const stdair::PeriodStruct lNewDeparturePeriod =
240 lCurrentDeparturePeriod.intersection (lAdjustedNextDeparturePeriod);
242 lNextSegmentPeriod_ptr->getElapsedTime();
243 lBoardingDateOffsetList.push_back (lNextBoardingDateOffset);
244 oSegmentPathPeriodKey.
setPeriod (lNewDeparturePeriod);
248 const stdair::Duration_T lStopTime =
249 lNextBoardingTime - lLastOffTime + stdair::Duration_T (24, 0, 0);
250 if (lStopTime < stdair::DEFAULT_MINIMAL_CONNECTION_TIME) {
251 return oSegmentPathPeriodKey;
255 const stdair::DateOffset_T& lLastBoardingDateOffset =
257 const stdair::DateOffset_T lNextBoardingDateOffset =
258 lLastBoardingDateOffset + lLastSegmentPeriod_ptr->getOffDateOffset()
259 - lLastSegmentPeriod_ptr->getBoardingDateOffset() +
260 stdair::DateOffset_T (1);
261 const stdair::DateOffset_T lNegativeNextBoardingDateOffset =
262 stdair::DateOffset_T (0) - lNextBoardingDateOffset;
266 const stdair::PeriodStruct lAdjustedNextDeparturePeriod =
267 lNextDeparturePeriod.addDateOffset (lNegativeNextBoardingDateOffset);
270 const stdair::PeriodStruct lNewDeparturePeriod =
271 lCurrentDeparturePeriod.intersection (lAdjustedNextDeparturePeriod);
273 lNextSegmentPeriod_ptr->getElapsedTime();
274 lBoardingDateOffsetList.push_back (lNextBoardingDateOffset);
275 oSegmentPathPeriodKey.
setPeriod (lNewDeparturePeriod);
284 return oSegmentPathPeriodKey;
290 const stdair::SegmentPeriodList_T& lSegmentPeriodList =
291 stdair::BomManager::getList<stdair::SegmentPeriod> (*this);
292 for (stdair::SegmentPeriodList_T::const_iterator itSegment =
293 lSegmentPeriodList.begin();
294 itSegment != lSegmentPeriodList.end(); ++itSegment) {
295 const stdair::SegmentPeriod* lCurrentSegment_ptr = *itSegment;
296 assert (lCurrentSegment_ptr != NULL);
297 const stdair::AirlineCode_T& lCurrentBoardingPoint =
298 lCurrentSegment_ptr->getBoardingPoint();
299 if (lCurrentBoardingPoint == iDestination) {
312 const stdair::DatePeriod_T& lDeparturePeriod = lPeriod.getDateRange ();
313 if (lDeparturePeriod.contains (iDepartureDate) ==
false) {
319 const short lDay = iDepartureDate.day_of_week ();
320 const stdair::DoWStruct& lDoW = lPeriod.getDoW ();
321 if (lDoW.getStandardDayOfWeek (lDay) ==
false) {