StdAir Logo  1.00.13
C++ Standard Airline IT Object Library
Loading...
Searching...
No Matches
FareFeatures.cpp
Go to the documentation of this file.
1// //////////////////////////////////////////////////////////////////////
2// Import section
3// //////////////////////////////////////////////////////////////////////
4// STL
5#include <cassert>
6#include <sstream>
7// StdAir
12
13namespace stdair {
14
15 // ////////////////////////////////////////////////////////////////////
16 FareFeatures::FareFeatures()
17 : _key (TRIP_TYPE_ONE_WAY,
23 _parent (NULL) {
24 // That constructor is used by the serialisation process
25 }
26
27 // ////////////////////////////////////////////////////////////////////
28 FareFeatures::FareFeatures (const FareFeatures& iFeatures)
29 : _key (iFeatures.getKey()), _parent (NULL) {
30 }
31
32 // ////////////////////////////////////////////////////////////////////
33 FareFeatures::FareFeatures (const Key_T& iKey)
34 : _key (iKey), _parent (NULL) {
35 }
36
37 // ////////////////////////////////////////////////////////////////////
39 }
40
41 // ////////////////////////////////////////////////////////////////////
42 std::string FareFeatures::toString() const {
43 std::ostringstream oStr;
44 oStr << describeKey();
45 return oStr.str();
46 }
47
48 // ////////////////////////////////////////////////////////////////////
50 isTripTypeValid (const TripType_T& iBookingRequestTripType) const {
51 bool oIsTripTypeValidFlag = true;
52
53 const TripType_T& lFareTripType = getTripType();
54 // Check whether the fare trip type is the same as the booking request
55 // trip type
56 if (iBookingRequestTripType == lFareTripType) {
57 // One way case
58 return oIsTripTypeValidFlag;
59 }
60
61 if (iBookingRequestTripType == TRIP_TYPE_INBOUND
62 || iBookingRequestTripType == TRIP_TYPE_OUTBOUND) {
63 // Round trip case
64 if (lFareTripType == TRIP_TYPE_ROUND_TRIP) {
65 return oIsTripTypeValidFlag;
66 }
67 }
68
69 oIsTripTypeValidFlag = false;
70 return oIsTripTypeValidFlag;
71 }
72
73 // ////////////////////////////////////////////////////////////////////
75 isStayDurationValid (const DayDuration_T& iStayDuration) const {
76
77 // Check if the stay duration is lower or equal to the minimum one.
78 const DayDuration_T& lMinimumDayDuration = getMinimumStay();
79 if (lMinimumDayDuration > iStayDuration) {
80 return false;
81 }
82
83 return true;
84 }
85
86 // ////////////////////////////////////////////////////////////////////
88 isAdvancePurchaseValid (const DateTime_T& iBookingRequestDateTime,
89 const DateTime_T& iFlightDateTime) const {
90 bool oIsAdvancePurchaseValidFlag = true;
91
92 // Check whether the departure date is within the date range.
93 const DayDuration_T& lAdvancedPurchase = getAdvancePurchase();
94 const DateOffset_T lMinimumAdvancedPurchase (lAdvancedPurchase);
95 const DateTime_T lCriticalDate = iFlightDateTime - lMinimumAdvancedPurchase;
96
97 if (lCriticalDate < iBookingRequestDateTime) {
98 oIsAdvancePurchaseValidFlag = false;
99 return oIsAdvancePurchaseValidFlag;
100 }
101
102 return true;
103 }
104
105}
106
Handle on the StdAir library context.
const ChangeFees_T CHANGE_FEES
boost::posix_time::ptime DateTime_T
const SaturdayStay_T SATURDAY_STAY
boost::gregorian::date_duration DateOffset_T
std::string TripType_T
const TripType_T TRIP_TYPE_INBOUND
const TripType_T TRIP_TYPE_ROUND_TRIP
const NonRefundable_T NON_REFUNDABLE
const DayDuration_T NO_STAY_DURATION
const TripType_T TRIP_TYPE_OUTBOUND
const TripType_T TRIP_TYPE_ONE_WAY
const DayDuration_T NO_ADVANCE_PURCHASE
std::string toString() const
bool isTripTypeValid(const TripType_T &) const
const std::string describeKey() const
bool isStayDurationValid(const DayDuration_T &) const
bool isAdvancePurchaseValid(const DateTime_T &iBookingRequestDateTime, const DateTime_T &iFlightDateTime) const
const TripType_T & getTripType() const
const DayDuration_T & getMinimumStay() const
const DayDuration_T & getAdvancePurchase() const
Key of date-period.