$treeview $search $mathjax
StdAir Logo  1.00.1
$projectbrief
$projectbrief
$searchbox

stdair/bom/YieldFeatures.cpp

Go to the documentation of this file.
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   }
00026 
00027   // ////////////////////////////////////////////////////////////////////
00028   YieldFeatures::YieldFeatures (const Key_T& iKey)
00029     : _key (iKey), _parent (NULL)  {
00030   }
00031 
00032   // ////////////////////////////////////////////////////////////////////
00033   YieldFeatures::~YieldFeatures () {
00034   }
00035   
00036   // ////////////////////////////////////////////////////////////////////
00037   std::string YieldFeatures::toString() const {
00038     std::ostringstream oStr;
00039     oStr << describeKey();
00040     return oStr.str();
00041   }
00042 
00043   // ////////////////////////////////////////////////////////////////////
00044   bool YieldFeatures::
00045   isTripTypeValid (const TripType_T& iBookingRequestTripType) const {
00046     bool oIsTripTypeValidFlag = true;
00047 
00048     // Check whether the yield trip type is the same as the booking request
00049     // trip type
00050     const TripType_T& lYieldTripType = getTripType();
00051     if (iBookingRequestTripType == lYieldTripType) {
00052       // One way case
00053       return oIsTripTypeValidFlag;
00054     }
00055 
00056     if (iBookingRequestTripType == TRIP_TYPE_INBOUND ||
00057         iBookingRequestTripType == TRIP_TYPE_OUTBOUND) {
00058       // Round trip case.
00059       if (lYieldTripType == TRIP_TYPE_ROUND_TRIP) {
00060         return oIsTripTypeValidFlag;
00061       }
00062     }
00063 
00064     oIsTripTypeValidFlag = false;
00065     return false;
00066   }
00067 
00068 }
00069