StdAir Logo  1.00.3
C++ Standard Airline IT Object Library
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 
13 namespace 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  // ////////////////////////////////////////////////////////////////////
49  bool FareFeatures::
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  // ////////////////////////////////////////////////////////////////////
74  bool FareFeatures::
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  // ////////////////////////////////////////////////////////////////////
87  bool FareFeatures::
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 
boost::posix_time::ptime DateTime_T
std::string TripType_T
Handle on the StdAir library context.
bool isAdvancePurchaseValid(const DateTime_T &iBookingRequestDateTime, const DateTime_T &iFlightDateTime) const
const TripType_T TRIP_TYPE_OUTBOUND
Key of date-period.
std::string toString() const
const std::string describeKey() const
const DayDuration_T NO_STAY_DURATION
const DayDuration_T & getMinimumStay() const
const TripType_T TRIP_TYPE_INBOUND
const TripType_T & getTripType() const
const SaturdayStay_T SATURDAY_STAY
const TripType_T TRIP_TYPE_ONE_WAY
const NonRefundable_T NON_REFUNDABLE
const DayDuration_T NO_ADVANCE_PURCHASE
bool isStayDurationValid(const DayDuration_T &) const
boost::gregorian::date_duration DateOffset_T
const DayDuration_T & getAdvancePurchase() const
const ChangeFees_T CHANGE_FEES
const TripType_T TRIP_TYPE_ROUND_TRIP
bool isTripTypeValid(const TripType_T &) const