00001 // ////////////////////////////////////////////////////////////////////// 00002 // Import section 00003 // ////////////////////////////////////////////////////////////////////// 00004 // STL 00005 #include <cassert> 00006 #include <sstream> 00007 // StdAir 00008 #include <stdair/basic/BasConst_Inventory.hpp> 00009 #include <stdair/basic/BasConst_General.hpp> 00010 #include <stdair/bom/BomManager.hpp> 00011 #include <stdair/bom/Inventory.hpp> 00012 #include <stdair/bom/OnDDate.hpp> 00013 00014 namespace stdair { 00015 00016 // //////////////////////////////////////////////////////////////////// 00017 OnDDate::OnDDate() 00018 : _key (DEFAULT_OND_STRING_LIST), _parent (NULL) { 00019 assert (false); 00020 } 00021 00022 // //////////////////////////////////////////////////////////////////// 00023 OnDDate::OnDDate (const OnDDate& iOnDDate) 00024 : _key (iOnDDate.getKey()), _parent (NULL) { 00025 assert (false); 00026 } 00027 00028 // //////////////////////////////////////////////////////////////////// 00029 OnDDate::OnDDate (const Key_T& iKey) 00030 : _key (iKey), _parent (NULL) { 00031 } 00032 00033 // //////////////////////////////////////////////////////////////////// 00034 OnDDate::~OnDDate() { 00035 } 00036 00037 // //////////////////////////////////////////////////////////////////// 00038 std::string OnDDate::toString() const { 00039 std::ostringstream oStr; 00040 oStr << describeKey(); 00041 return oStr.str(); 00042 } 00043 00044 // //////////////////////////////////////////////////////////////////// 00045 const AirlineCode_T& OnDDate::getAirlineCode() const { 00046 const Inventory* lInventory_ptr = 00047 static_cast<const Inventory*> (getParent()); 00048 assert (lInventory_ptr != NULL); 00049 return lInventory_ptr->getAirlineCode(); 00050 } 00051 00052 // //////////////////////////////////////////////////////////////////// 00053 void OnDDate:: 00054 setDemandInformation (const CabinClassPairList_T& iCabinClassPairList, 00055 const YieldDemandPair_T& iYieldDemandPair) { 00056 std::ostringstream oStr; 00057 for(CabinClassPairList_T::const_iterator itCCP = iCabinClassPairList.begin(); 00058 itCCP != iCabinClassPairList.end(); ++itCCP) { 00059 oStr << itCCP->first << ":" << itCCP->second << ";"; 00060 } 00061 std::string lCabinClassPath = oStr.str(); 00062 StringDemandStructMap_T::iterator it = 00063 _classPathDemandMap.find(lCabinClassPath); 00064 if (it == _classPathDemandMap.end()) { 00065 const StringDemandStructPair_T lPairStringDemandChar (lCabinClassPath, 00066 iYieldDemandPair); 00067 _classPathDemandMap.insert (lPairStringDemandChar); 00068 const StringCabinClassPair_T lStringCabinClassPair (lCabinClassPath, 00069 iCabinClassPairList); 00070 _stringCabinClassPairListMap.insert (lStringCabinClassPair); 00071 } else { 00072 it->second = iYieldDemandPair; 00073 } 00074 } 00075 00076 // //////////////////////////////////////////////////////////////////// 00077 void OnDDate::setTotalForecast (const CabinCode_T& iCabinCode, 00078 const WTPDemandPair_T& iWTPDemandPair) { 00079 00080 CabinForecastMap_T::iterator it = 00081 _cabinForecastMap.find (iCabinCode); 00082 if (it == _cabinForecastMap.end()) { 00083 const CabinForecastPair_T lPairCabinForecastChar (iCabinCode, 00084 iWTPDemandPair); 00085 _cabinForecastMap.insert (lPairCabinForecastChar); 00086 } else { 00087 assert (false); 00088 } 00089 } 00090 00091 }