StdAir Logo  0.45.1
C++ Standard Airline IT Object Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
YieldFeatures.cpp
Go to the documentation of this file.
1 // //////////////////////////////////////////////////////////////////////
2 // Import section
3 // //////////////////////////////////////////////////////////////////////
4 // STL
5 #include <cassert>
6 #include <sstream>
7 // StdAir
11 
12 namespace stdair {
13 
14  // ////////////////////////////////////////////////////////////////////
15  YieldFeatures::YieldFeatures()
16  : _key (TRIP_TYPE_ONE_WAY,
18  _parent (NULL) {
19  // That constructor is used by the serialisation process
20  }
21 
22  // ////////////////////////////////////////////////////////////////////
23  YieldFeatures::YieldFeatures (const YieldFeatures& iFeatures)
24  : _key (iFeatures.getKey()), _parent (NULL) {
25  assert (false);
26  }
27 
28  // ////////////////////////////////////////////////////////////////////
29  YieldFeatures::YieldFeatures (const Key_T& iKey)
30  : _key (iKey), _parent (NULL) {
31  }
32 
33  // ////////////////////////////////////////////////////////////////////
35  }
36 
37  // ////////////////////////////////////////////////////////////////////
38  std::string YieldFeatures::toString() const {
39  std::ostringstream oStr;
40  oStr << describeKey();
41  return oStr.str();
42  }
43 
44  // ////////////////////////////////////////////////////////////////////
45  bool YieldFeatures::
46  isTripTypeValid (const TripType_T& iBookingRequestTripType) const {
47  bool oIsTripTypeValidFlag = true;
48 
49  // Check whether the yield trip type is the same as the booking request
50  // trip type
51  const TripType_T& lYieldTripType = getTripType();
52  if (iBookingRequestTripType == lYieldTripType) {
53  // One way case
54  return oIsTripTypeValidFlag;
55  }
56 
57  if (iBookingRequestTripType == TRIP_TYPE_INBOUND ||
58  iBookingRequestTripType == TRIP_TYPE_OUTBOUND) {
59  // Round trip case.
60  if (lYieldTripType == TRIP_TYPE_ROUND_TRIP) {
61  return oIsTripTypeValidFlag;
62  }
63  }
64 
65  oIsTripTypeValidFlag = false;
66  return false;
67  }
68 
69 }
70