$treeview $search $mathjax
00001 // ////////////////////////////////////////////////////////////////////// 00002 // Import section 00003 // ////////////////////////////////////////////////////////////////////// 00004 // STL 00005 #include <cassert> 00006 #include <sstream> 00007 // StdAir 00008 #include <stdair/basic/BasConst_General.hpp> 00009 #include <stdair/service/Logger.hpp> 00010 // AIRRAC 00011 #include <airrac/AIRRAC_Types.hpp> 00012 #include <airrac/bom/YieldRuleStruct.hpp> 00013 00014 namespace AIRRAC { 00015 00016 // ////////////////////////////////////////////////////////////////////// 00017 YieldRuleStruct::YieldRuleStruct() 00018 : _yieldId(0), 00019 _origin(""), 00020 _destination(""), 00021 _dateRangeStart (stdair::DEFAULT_DATE), 00022 _dateRangeEnd (stdair::DEFAULT_DATE), 00023 _timeRangeStart (stdair::DEFAULT_EPSILON_DURATION), 00024 _timeRangeEnd (stdair::DEFAULT_EPSILON_DURATION), 00025 _yield(0), 00026 _cabinCode(""), 00027 _pos(""), 00028 _channel(""), 00029 _airlineCode(""), 00030 _classCode("") { 00031 } 00032 00033 // ////////////////////////////////////////////////////////////////////// 00034 YieldRuleStruct::~YieldRuleStruct() { 00035 } 00036 00037 // ////////////////////////////////////////////////////////////////////// 00038 stdair::Date_T YieldRuleStruct::calculateDate() const { 00039 _itYear.check(); _itMonth.check(); _itDay.check(); 00040 return stdair::Date_T (_itYear._value, _itMonth._value, _itDay._value); 00041 } 00042 00043 // ////////////////////////////////////////////////////////////////////// 00044 stdair::Duration_T YieldRuleStruct::calculateTime() const { 00045 _itHours.check(); _itMinutes.check(); _itSeconds.check(); 00046 return boost::posix_time::hours (_itHours._value) 00047 + boost::posix_time::minutes (_itMinutes._value) 00048 + boost::posix_time::seconds (_itSeconds._value); 00049 } 00050 00051 // ////////////////////////////////////////////////////////////////////// 00052 const std::string YieldRuleStruct::describe() const { 00053 std::ostringstream oStr; 00054 oStr << "YieldRule: " << _yieldId << ", "; 00055 00056 oStr << _origin << "-" << _destination << " (" 00057 << _pos << "), " << _channel << ", ["; 00058 oStr << _dateRangeStart << "/" << _dateRangeEnd << "] - [" 00059 << boost::posix_time::to_simple_string (_timeRangeStart) << "/" 00060 << boost::posix_time::to_simple_string (_timeRangeEnd) << "], "; 00061 00062 oStr << _cabinCode << ", " << _yield << " EUR, "; 00063 00064 // Sanity check 00065 assert (_airlineCodeList.size() == _classCodeList.size()); 00066 00067 // Browse the class-pathes 00068 unsigned short idx = 0; 00069 stdair::ClassList_StringList_T::const_iterator itClass = 00070 _classCodeList.begin(); 00071 for (stdair::AirlineCodeList_T::const_iterator itAirline = 00072 _airlineCodeList.begin(); 00073 itAirline != _airlineCodeList.end(); ++itAirline, ++itClass, ++idx) { 00074 if (idx != 0) { 00075 oStr << " - "; 00076 } 00077 const stdair::AirlineCode_T lAirlineCode = *itAirline; 00078 const stdair::ClassCode_T lClassCode = *itClass; 00079 oStr << lAirlineCode << " / " << lClassCode; 00080 } 00081 00082 return oStr.str(); 00083 } 00084 }