RMOL Logo  0.25.3
C++ library of Revenue Management and Optimisation classes and functions
GuillotineBlockHelper.cpp
Go to the documentation of this file.
00001 // //////////////////////////////////////////////////////////////////////
00002 // Import section
00003 // //////////////////////////////////////////////////////////////////////
00004 // STL
00005 #include <cassert>
00006 // StdAir
00007 #include <stdair/basic/BasConst_Inventory.hpp>
00008 #include <stdair/bom/BomManager.hpp>
00009 #include <stdair/bom/SegmentDate.hpp>
00010 #include <stdair/bom/SegmentCabin.hpp>
00011 #include <stdair/bom/BookingClass.hpp>
00012 #include <stdair/bom/GuillotineBlock.hpp>
00013 #include <stdair/service/Logger.hpp>
00014 // RMOL
00015 #include <rmol/bom/GuillotineBlockHelper.hpp>
00016 
00017 namespace RMOL {
00018   // ////////////////////////////////////////////////////////////////////
00019   stdair::NbOfSegments_T GuillotineBlockHelper::
00020   getNbOfSegmentAlreadyPassedThisDTD (const stdair::GuillotineBlock& iGB,
00021                                       const stdair::DTD_T& iDTD,
00022                                       const stdair::Date_T& iCurrentDate) {
00023     stdair::NbOfSegments_T oNbOfSegments = 0;
00024 
00025     // Browse the list of segments and check if it has passed the given DTD.
00026     const stdair::SegmentCabinIndexMap_T& lSCMap=iGB.getSegmentCabinIndexMap();
00027     for (stdair::SegmentCabinIndexMap_T::const_iterator itSC = lSCMap.begin();
00028          itSC != lSCMap.end(); ++itSC) {
00029       const stdair::SegmentCabin* lSC_ptr = itSC->first;
00030       assert (lSC_ptr != NULL);
00031 
00032       if (hasPassedThisDTD (*lSC_ptr, iDTD, iCurrentDate) == true) {
00033         ++oNbOfSegments;
00034       }
00035     }
00036     
00037     return oNbOfSegments;
00038   }
00039   
00040   // ////////////////////////////////////////////////////////////////////
00041   bool GuillotineBlockHelper::
00042   hasPassedThisDTD (const stdair::SegmentCabin& iSegmentCabin,
00043                     const stdair::DTD_T& iDTD,
00044                     const stdair::Date_T& iCurrentDate) {
00045     // Retrieve the boarding date.
00046     const stdair::SegmentDate& lSegmentDate =
00047       stdair::BomManager::getParent<stdair::SegmentDate> (iSegmentCabin);
00048     const stdair::Date_T& lBoardingDate = lSegmentDate.getBoardingDate();
00049 
00050     // Compare the date offset between the boarding date and the current date
00051     // to the DTD.
00052     stdair::DateOffset_T lDateOffset = lBoardingDate - iCurrentDate;
00053     stdair::DTD_T lDateOffsetInDays = lDateOffset.days();
00054     if (iDTD < lDateOffsetInDays) {
00055       return false;
00056     } else {
00057       return true;
00058     }
00059   }
00060 }
 All Classes Namespaces Files Functions Variables Typedefs Friends Defines