$treeview $search $mathjax
00001 // ////////////////////////////////////////////////////////////////////// 00002 // Import section 00003 // ////////////////////////////////////////////////////////////////////// 00004 // STL 00005 #include <cassert> 00006 #include <sstream> 00007 #include <vector> 00008 // StdAir 00009 #include <stdair/basic/BasConst_General.hpp> 00010 #include <stdair/service/Logger.hpp> 00011 // AirInv 00012 #include <airinv/AIRINV_Types.hpp> 00013 #include <airinv/bom/DCPEventStruct.hpp> 00014 00015 namespace AIRINV { 00016 00017 // //////////////////////////////////////////////////////////////////// 00018 DCPEventStruct::DCPEventStruct () 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 _cabinCode (""), 00026 _pos (""), 00027 _advancePurchase(0), 00028 _saturdayStay("T"), 00029 _changeFees("T"), 00030 _nonRefundable("T"), 00031 _minimumStay(0), 00032 _DCP(0), 00033 _airlineCode(""), 00034 _classCode("") { 00035 } 00036 00037 // //////////////////////////////////////////////////////////////////// 00038 stdair::Date_T DCPEventStruct::getDate() 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 DCPEventStruct::getTime() 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 // //////////////////////////////////////////////////////////////////// 00053 const std::string DCPEventStruct::describe () const { 00054 std::ostringstream ostr; 00055 ostr << "DCPEvent: " 00056 << _origin << "-" << _destination 00057 << ", POS(" << _pos << "), [" 00058 << _dateRangeStart << "/" << _dateRangeEnd << "] - [" 00059 << boost::posix_time::to_simple_string(_timeRangeStart) << "/" 00060 << boost::posix_time::to_simple_string(_timeRangeEnd) << "]\n " 00061 << "-Cabin code- " << _cabinCode << "\n " 00062 << "-Channel- " << _channel << "\n " 00063 << "-Conditions- " << _saturdayStay << ", " << _changeFees << ", " 00064 << _nonRefundable << ", " << _advancePurchase << ", " 00065 << _minimumStay << "\n " 00066 << "-DCP- " << _DCP << "\n "; 00067 assert (_airlineCodeList.size() == _classCodeList.size()); 00068 stdair::ClassList_StringList_T::const_iterator lItCurrentClassCode = 00069 _classCodeList.begin(); 00070 stdair::AirlineCode_T lAirlineCode; 00071 std::string lClassCode; 00072 for (stdair::AirlineCodeList_T::const_iterator lItCurrentAirlineCode = 00073 _airlineCodeList.begin(); 00074 lItCurrentAirlineCode != _airlineCodeList.end(); 00075 lItCurrentAirlineCode++) { 00076 lAirlineCode = *lItCurrentAirlineCode; 00077 lClassCode = *lItCurrentClassCode; 00078 ostr << lAirlineCode << ", " << lClassCode; 00079 ostr << " "; 00080 lItCurrentClassCode++; 00081 } 00082 ostr << std::endl; 00083 return ostr.str(); 00084 } 00085 00086 // ////////////////////////////////////////////////////////////////////// 00087 const stdair::AirlineCode_T& DCPEventStruct::getFirstAirlineCode () const { 00088 assert (_airlineCodeList.size() > 0); 00089 stdair::AirlineCodeList_T::const_iterator itFirstAirlineCode = 00090 _airlineCodeList.begin(); 00091 return *itFirstAirlineCode; 00092 } 00093 00094 // ////////////////////////////////////////////////////////////////////// 00095 void DCPEventStruct::beginAirline () { 00096 _itCurrentAirlineCode = _airlineCodeList.begin(); 00097 } 00098 00099 // ////////////////////////////////////////////////////////////////////// 00100 bool DCPEventStruct::hasNotReachedEndAirline () const { 00101 bool result = (_itCurrentAirlineCode != _airlineCodeList.end()); 00102 return result; 00103 } 00104 00105 // ////////////////////////////////////////////////////////////////////// 00106 stdair::AirlineCode_T DCPEventStruct::getCurrentAirlineCode () const { 00107 assert (_itCurrentAirlineCode != _airlineCodeList.end()); 00108 return (*_itCurrentAirlineCode); 00109 } 00110 00111 // ////////////////////////////////////////////////////////////////////// 00112 void DCPEventStruct::iterateAirline () { 00113 if (_itCurrentAirlineCode != _classCodeList.end()) { 00114 _itCurrentAirlineCode++; 00115 } 00116 } 00117 00118 // ////////////////////////////////////////////////////////////////////// 00119 const std::string& DCPEventStruct::getFirstClassCode () const { 00120 assert (_classCodeList.size() > 0); 00121 stdair::ClassList_StringList_T::const_iterator itFirstClassCode = 00122 _classCodeList.begin(); 00123 return *itFirstClassCode; 00124 } 00125 00126 // ////////////////////////////////////////////////////////////////////// 00127 void DCPEventStruct::beginClassCode () { 00128 _itCurrentClassCode = _classCodeList.begin(); 00129 } 00130 00131 // ////////////////////////////////////////////////////////////////////// 00132 bool DCPEventStruct::hasNotReachedEndClassCode () const { 00133 bool result = (_itCurrentClassCode != _classCodeList.end()); 00134 return result; 00135 } 00136 00137 // ////////////////////////////////////////////////////////////////////// 00138 std::string DCPEventStruct::getCurrentClassCode () const { 00139 assert (_itCurrentClassCode != _classCodeList.end()); 00140 return (*_itCurrentClassCode); 00141 } 00142 00143 00144 // ////////////////////////////////////////////////////////////////////// 00145 void DCPEventStruct::iterateClassCode () { 00146 if (_itCurrentClassCode != _classCodeList.end()) { 00147 _itCurrentClassCode++; 00148 } 00149 } 00150 00151 } 00152