$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/CancellationStruct.hpp> 00010 #include <stdair/bom/BookingClass.hpp> 00011 00012 namespace stdair { 00013 // //////////////////////////////////////////////////////////////////// 00014 CancellationStruct::CancellationStruct (const SegmentPath_T& iSegPath, 00015 const ClassList_String_T& iList, 00016 const PartySize_T& iSize, 00017 const DateTime_T& iDateTime) 00018 : _segmentPath (iSegPath), _classList (iList), _partySize (iSize), 00019 _datetime (iDateTime) { 00020 } 00021 00022 // //////////////////////////////////////////////////////////////////// 00023 CancellationStruct::CancellationStruct (const SegmentPath_T& iSegPath, 00024 const BookingClassIDList_T& iIDList, 00025 const PartySize_T& iSize, 00026 const DateTime_T& iDateTime) 00027 : _segmentPath (iSegPath), _classIDList (iIDList), _partySize (iSize), 00028 _datetime (iDateTime) { 00029 } 00030 00031 // //////////////////////////////////////////////////////////////////// 00032 CancellationStruct::~CancellationStruct() { 00033 } 00034 00035 // //////////////////////////////////////////////////////////////////// 00036 void CancellationStruct::toStream (std::ostream& ioOut) const { 00037 ioOut << describe(); 00038 } 00039 00040 // //////////////////////////////////////////////////////////////////// 00041 void CancellationStruct::fromStream (std::istream& ioIn) { 00042 } 00043 00044 // //////////////////////////////////////////////////////////////////// 00045 const std::string CancellationStruct::describe() const { 00046 std::ostringstream oStr; 00047 00048 oStr << "Segment path: "; 00049 unsigned short idx = 0; 00050 for (SegmentPath_T::const_iterator lItSegmentPath = _segmentPath.begin(); 00051 lItSegmentPath != _segmentPath.end(); ++lItSegmentPath, ++idx) { 00052 if (idx != 0) { 00053 oStr << "-"; 00054 } 00055 const std::string& lSegmentKey = *lItSegmentPath; 00056 oStr << lSegmentKey; 00057 } 00058 if (_classList == "") { 00059 oStr << ";"; 00060 BookingClassIDList_T::const_iterator lItBookingClassIDList = 00061 _classIDList.begin(); 00062 idx = 0; 00063 for (; lItBookingClassIDList != _classIDList.end(); 00064 ++lItBookingClassIDList, ++idx) { 00065 if (idx != 0) { 00066 oStr << "-"; 00067 } 00068 const BookingClassID_T& lBookingClassID = *lItBookingClassIDList; 00069 const BookingClass& lBookingClass = lBookingClassID.getObject(); 00070 const ClassCode_T& lClassCode = lBookingClass.getClassCode(); 00071 oStr << lClassCode; 00072 } 00073 oStr << ";" << _partySize << ";" << _datetime; 00074 } else { 00075 oStr << ";" << _classList << ";" << _partySize << ";" << _datetime; 00076 } 00077 return oStr.str(); 00078 } 00079 00080 // //////////////////////////////////////////////////////////////////// 00081 const std::string CancellationStruct::display() const { 00082 std::ostringstream oStr; 00083 00084 // List of segment keys (one per segment) 00085 unsigned short idx = 0; 00086 for (SegmentPath_T::const_iterator itSegPath = _segmentPath.begin(); 00087 itSegPath != _segmentPath.end(); ++itSegPath, ++idx) { 00088 if (idx != 0) { 00089 oStr << " ; "; 00090 } 00091 const std::string& lSegmentKey = *itSegPath; 00092 oStr << "[" << idx << "] " << lSegmentKey; 00093 } 00094 if (_classList == "") { 00095 oStr << ";"; 00096 BookingClassIDList_T::const_iterator lItBookingClassIDList = 00097 _classIDList.begin(); 00098 idx = 0; 00099 for (; lItBookingClassIDList != _classIDList.end(); 00100 ++lItBookingClassIDList, ++idx) { 00101 if (idx != 0) { 00102 oStr << "-"; 00103 } 00104 const BookingClassID_T& lBookingClassID = *lItBookingClassIDList; 00105 const BookingClass& lBookingClass = lBookingClassID.getObject(); 00106 const ClassCode_T& lClassCode = lBookingClass.getClassCode(); 00107 oStr << lClassCode; 00108 } 00109 oStr << ";" << _partySize << ";" << _datetime; 00110 } else { 00111 oStr << ";" << _classList << ";" << _partySize << ";" << _datetime; 00112 } 00113 return oStr.str(); 00114 } 00115 }