RMOL Logo  1.00.13
C++ library of Revenue Management and Optimisation classes and functions
Loading...
Searching...
No Matches
SegmentSnapshotTableHelper.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_Inventory.hpp>
8#include <stdair/bom/BomManager.hpp>
9#include <stdair/bom/SegmentDate.hpp>
10#include <stdair/bom/SegmentCabin.hpp>
11#include <stdair/bom/BookingClass.hpp>
12#include <stdair/bom/SegmentSnapshotTable.hpp>
13#include <stdair/service/Logger.hpp>
14// RMOL
16
17namespace RMOL {
18 // ////////////////////////////////////////////////////////////////////
19 stdair::NbOfSegments_T SegmentSnapshotTableHelper::
20 getNbOfSegmentAlreadyPassedThisDTD (const stdair::SegmentSnapshotTable& iGB,
21 const stdair::DTD_T& iDTD,
22 const stdair::Date_T& iCurrentDate) {
23 stdair::NbOfSegments_T oNbOfSegments = 0;
24
25 // Browse the list of segments and check if it has passed the given DTD.
26 const stdair::SegmentCabinIndexMap_T& lSCMap=iGB.getSegmentCabinIndexMap();
27 for (stdair::SegmentCabinIndexMap_T::const_iterator itSC = lSCMap.begin();
28 itSC != lSCMap.end(); ++itSC) {
29 const stdair::SegmentCabin* lSC_ptr = itSC->first;
30 assert (lSC_ptr != NULL);
31
32 if (hasPassedThisDTD (*lSC_ptr, iDTD, iCurrentDate) == true) {
33 ++oNbOfSegments;
34 }
35 }
36
37 return oNbOfSegments;
38 }
39
40 // ////////////////////////////////////////////////////////////////////
42 hasPassedThisDTD (const stdair::SegmentCabin& iSegmentCabin,
43 const stdair::DTD_T& iDTD,
44 const stdair::Date_T& iCurrentDate) {
45 // Retrieve the boarding date.
46 const stdair::SegmentDate& lSegmentDate =
47 stdair::BomManager::getParent<stdair::SegmentDate> (iSegmentCabin);
48 const stdair::Date_T& lBoardingDate = lSegmentDate.getBoardingDate();
49
50 // Compare the date offset between the boarding date and the current date
51 // to the DTD.
52 stdair::DateOffset_T lDateOffset = lBoardingDate - iCurrentDate;
53 stdair::DTD_T lDateOffsetInDays = lDateOffset.days();
54 if (iDTD > lDateOffsetInDays) {
55 return true;
56 } else {
57 return false;
58 }
59 }
60}
static stdair::NbOfSegments_T getNbOfSegmentAlreadyPassedThisDTD(const stdair::SegmentSnapshotTable &, const stdair::DTD_T &, const stdair::Date_T &)
static bool hasPassedThisDTD(const stdair::SegmentCabin &, const stdair::DTD_T &, const stdair::Date_T &)