00001 // ////////////////////////////////////////////////////////////////////// 00002 // Import section 00003 // ////////////////////////////////////////////////////////////////////// 00004 // STL 00005 #include <cassert> 00006 #include <sstream> 00007 // StdAir 00008 #include <stdair/basic/BasConst_Request.hpp> 00009 #include <stdair/service/Logger.hpp> 00010 #include <stdair/bom/YieldFeatures.hpp> 00011 00012 namespace stdair { 00013 00014 // //////////////////////////////////////////////////////////////////// 00015 YieldFeatures::YieldFeatures() 00016 : _key (TRIP_TYPE_ONE_WAY, 00017 DEFAULT_PREFERRED_CABIN), 00018 _parent (NULL) { 00019 // That constructor is used by the serialisation process 00020 } 00021 00022 // //////////////////////////////////////////////////////////////////// 00023 YieldFeatures::YieldFeatures (const YieldFeatures& iFeatures) 00024 : _key (iFeatures.getKey()), _parent (NULL) { 00025 assert (false); 00026 } 00027 00028 // //////////////////////////////////////////////////////////////////// 00029 YieldFeatures::YieldFeatures (const Key_T& iKey) 00030 : _key (iKey), _parent (NULL) { 00031 } 00032 00033 // //////////////////////////////////////////////////////////////////// 00034 YieldFeatures::~YieldFeatures () { 00035 } 00036 00037 // //////////////////////////////////////////////////////////////////// 00038 std::string YieldFeatures::toString() const { 00039 std::ostringstream oStr; 00040 oStr << describeKey(); 00041 return oStr.str(); 00042 } 00043 00044 // //////////////////////////////////////////////////////////////////// 00045 bool YieldFeatures:: 00046 isTripTypeValid (const TripType_T& iBookingRequestTripType) const { 00047 bool oIsTripTypeValidFlag = true; 00048 00049 // Check whether the yield trip type is the same as the booking request 00050 // trip type 00051 const TripType_T& lYieldTripType = getTripType(); 00052 if (iBookingRequestTripType == lYieldTripType) { 00053 // One way case 00054 return oIsTripTypeValidFlag; 00055 } 00056 00057 if (iBookingRequestTripType == TRIP_TYPE_INBOUND || 00058 iBookingRequestTripType == TRIP_TYPE_OUTBOUND) { 00059 // Round trip case. 00060 if (lYieldTripType == TRIP_TYPE_ROUND_TRIP) { 00061 return oIsTripTypeValidFlag; 00062 } 00063 } 00064 00065 oIsTripTypeValidFlag = false; 00066 return false; 00067 } 00068 00069 } 00070