$treeview $search $mathjax
00001 // ////////////////////////////////////////////////////////////////////// 00002 // Import section 00003 // ////////////////////////////////////////////////////////////////////// 00004 // STL 00005 #include <cassert> 00006 #include <sstream> 00007 // StdAir 00008 #include <stdair/basic/BasConst_BookingClass.hpp> 00009 #include <stdair/bom/FareOptionStruct.hpp> 00010 00011 namespace stdair { 00012 00013 // //////////////////////////////////////////////////////////////////// 00014 FareOptionStruct::FareOptionStruct() 00015 : _fare (DEFAULT_FARE_VALUE), _avl (DEFAULT_AVAILABILITY) { 00016 } 00017 00018 // //////////////////////////////////////////////////////////////////// 00019 FareOptionStruct::FareOptionStruct (const FareOptionStruct& iFO) 00020 : _classPath (iFO._classPath), 00021 _fare (iFO._fare), _avl (iFO._avl), _changeFee (iFO._changeFee), 00022 _nonRefundable (iFO._nonRefundable), _saturdayStay (iFO._saturdayStay) { 00023 } 00024 00025 // //////////////////////////////////////////////////////////////////// 00026 FareOptionStruct::FareOptionStruct (const std::string& iClassPath, 00027 const Fare_T& iFare, 00028 const ChangeFees_T& iChangeFee, 00029 const NonRefundable_T& iNonRefundable, 00030 const SaturdayStay_T& iSaturdayNightStay) 00031 : _fare (iFare), _avl (DEFAULT_AVAILABILITY), 00032 _changeFee (iChangeFee), _nonRefundable (iNonRefundable), 00033 _saturdayStay (iSaturdayNightStay) { 00034 _classPath.push_back (iClassPath); 00035 } 00036 00037 // //////////////////////////////////////////////////////////////////// 00038 FareOptionStruct::~FareOptionStruct() { 00039 } 00040 00041 // //////////////////////////////////////////////////////////////////// 00042 void FareOptionStruct::toStream (std::ostream& ioOut) const { 00043 ioOut << describe(); 00044 } 00045 00046 // //////////////////////////////////////////////////////////////////// 00047 void FareOptionStruct::fromStream (std::istream& ioIn) { 00048 } 00049 00050 // //////////////////////////////////////////////////////////////////// 00051 const std::string FareOptionStruct::describe() const { 00052 std::ostringstream oStr; 00053 00054 oStr << "Class path: "; 00055 unsigned short idx = 0; 00056 for (ClassList_StringList_T::const_iterator itClassPath = 00057 _classPath.begin(); itClassPath != _classPath.end(); 00058 ++itClassPath, ++idx) { 00059 if (idx != 0) { 00060 oStr << "-"; 00061 } 00062 const std::string& lClassPath = *itClassPath; 00063 oStr << lClassPath; 00064 } 00065 00066 oStr << "; " << _fare << " EUR"; 00067 oStr << "; conditions: " << _changeFee << " " << _nonRefundable 00068 << " " << _saturdayStay; 00069 return oStr.str(); 00070 } 00071 00072 // //////////////////////////////////////////////////////////////////// 00073 const std::string FareOptionStruct::display() const { 00074 std::ostringstream oStr; 00075 00076 unsigned short idx = 0; 00077 for (ClassList_StringList_T::const_iterator itClassPath = 00078 _classPath.begin(); itClassPath != _classPath.end(); 00079 ++itClassPath, ++idx) { 00080 if (idx != 0) { 00081 oStr << "-"; 00082 } 00083 const std::string& lClassPath = *itClassPath; 00084 oStr << lClassPath; 00085 } 00086 00087 oStr << ", " << _fare << ", " << _changeFee << " " << _nonRefundable 00088 << " " << _saturdayStay; 00089 return oStr.str(); 00090 } 00091 00092 // //////////////////////////////////////////////////////////////////// 00093 void FareOptionStruct::addClassList (const std::string iClassCodeList) { 00094 _classPath.push_back (iClassCodeList); 00095 } 00096 00097 // //////////////////////////////////////////////////////////////////// 00098 void FareOptionStruct::emptyClassList () { 00099 _classPath.clear(); 00100 } 00101 00102 }