$treeview $search $mathjax
00001 // ////////////////////////////////////////////////////////////////////// 00002 // Import section 00003 // ////////////////////////////////////////////////////////////////////// 00004 // STL 00005 #include <cassert> 00006 #include <sstream> 00007 // StdAir 00008 #include <stdair/basic/BasConst_DefaultObject.hpp> 00009 #include <stdair/basic/BasConst_Request.hpp> 00010 #include <stdair/service/Logger.hpp> 00011 #include <stdair/bom/FareFeatures.hpp> 00012 00013 namespace stdair { 00014 00015 // //////////////////////////////////////////////////////////////////// 00016 FareFeatures::FareFeatures() 00017 : _key (TRIP_TYPE_ONE_WAY, 00018 NO_ADVANCE_PURCHASE, 00019 SATURDAY_STAY, 00020 CHANGE_FEES, 00021 NON_REFUNDABLE, 00022 NO_STAY_DURATION), 00023 _parent (NULL) { 00024 // That constructor is used by the serialisation process 00025 } 00026 00027 // //////////////////////////////////////////////////////////////////// 00028 FareFeatures::FareFeatures (const FareFeatures& iFeatures) 00029 : _key (iFeatures.getKey()), _parent (NULL) { 00030 } 00031 00032 // //////////////////////////////////////////////////////////////////// 00033 FareFeatures::FareFeatures (const Key_T& iKey) 00034 : _key (iKey), _parent (NULL) { 00035 } 00036 00037 // //////////////////////////////////////////////////////////////////// 00038 FareFeatures::~FareFeatures () { 00039 } 00040 00041 // //////////////////////////////////////////////////////////////////// 00042 std::string FareFeatures::toString() const { 00043 std::ostringstream oStr; 00044 oStr << describeKey(); 00045 return oStr.str(); 00046 } 00047 00048 // //////////////////////////////////////////////////////////////////// 00049 bool FareFeatures:: 00050 isTripTypeValid (const TripType_T& iBookingRequestTripType) const { 00051 bool oIsTripTypeValidFlag = true; 00052 00053 const TripType_T& lFareTripType = getTripType(); 00054 // Check whether the fare trip type is the same as the booking request 00055 // trip type 00056 if (iBookingRequestTripType == lFareTripType) { 00057 // One way case 00058 return oIsTripTypeValidFlag; 00059 } 00060 00061 if (iBookingRequestTripType == TRIP_TYPE_INBOUND 00062 || iBookingRequestTripType == TRIP_TYPE_OUTBOUND) { 00063 // Round trip case 00064 if (lFareTripType == TRIP_TYPE_ROUND_TRIP) { 00065 return oIsTripTypeValidFlag; 00066 } 00067 } 00068 00069 oIsTripTypeValidFlag = false; 00070 return oIsTripTypeValidFlag; 00071 } 00072 00073 // //////////////////////////////////////////////////////////////////// 00074 bool FareFeatures:: 00075 isStayDurationValid (const DayDuration_T& iStayDuration) const { 00076 00077 // Check if the stay duration is lower or equal to the minimum one. 00078 const DayDuration_T& lMinimumDayDuration = getMinimumStay(); 00079 if (lMinimumDayDuration > iStayDuration) { 00080 return false; 00081 } 00082 00083 return true; 00084 } 00085 00086 // //////////////////////////////////////////////////////////////////// 00087 bool FareFeatures:: 00088 isAdvancePurchaseValid (const DateTime_T& iBookingRequestDateTime, 00089 const DateTime_T& iFlightDateTime) const { 00090 bool oIsAdvancePurchaseValidFlag = true; 00091 00092 // Check whether the departure date is within the date range. 00093 const DayDuration_T& lAdvancedPurchase = getAdvancePurchase(); 00094 const DateOffset_T lMinimumAdvancedPurchase (lAdvancedPurchase); 00095 const DateTime_T lCriticalDate = iFlightDateTime - lMinimumAdvancedPurchase; 00096 00097 if (lCriticalDate < iBookingRequestDateTime) { 00098 oIsAdvancePurchaseValidFlag = false; 00099 return oIsAdvancePurchaseValidFlag; 00100 } 00101 00102 return true; 00103 } 00104 00105 } 00106