$treeview $search $mathjax
StdAir Logo  1.00.2
$projectbrief
$projectbrief
$searchbox

stdair/bom/OnDDate.cpp

Go to the documentation of this file.
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   }
00026   
00027   // ////////////////////////////////////////////////////////////////////
00028   OnDDate::OnDDate (const Key_T& iKey)
00029   : _key (iKey), _parent (NULL) {
00030   }
00031 
00032   // ////////////////////////////////////////////////////////////////////
00033   OnDDate::~OnDDate() {
00034   }
00035 
00036   // ////////////////////////////////////////////////////////////////////
00037   std::string OnDDate::toString() const {
00038     std::ostringstream oStr;
00039     oStr << describeKey();
00040     return oStr.str();
00041   }
00042 
00043   // ////////////////////////////////////////////////////////////////////
00044   const AirlineCode_T& OnDDate::getAirlineCode() const {
00045     const Inventory* lInventory_ptr =
00046       static_cast<const Inventory*> (getParent());
00047     assert (lInventory_ptr != NULL);
00048     return lInventory_ptr->getAirlineCode();
00049   }
00050 
00051   // ////////////////////////////////////////////////////////////////////
00052   void OnDDate::
00053   setDemandInformation (const CabinClassPairList_T& iCabinClassPairList,
00054                         const YieldDemandPair_T& iYieldDemandPair) {    
00055     std::ostringstream oStr;
00056     for(CabinClassPairList_T::const_iterator itCCP = iCabinClassPairList.begin();
00057         itCCP != iCabinClassPairList.end(); ++itCCP) {
00058       oStr << itCCP->first << ":" << itCCP->second << ";";
00059     }
00060     std::string lCabinClassPath = oStr.str();
00061     StringDemandStructMap_T::iterator it =
00062       _classPathDemandMap.find(lCabinClassPath);
00063     if (it == _classPathDemandMap.end()) {
00064       const StringDemandStructPair_T lPairStringDemandChar (lCabinClassPath,
00065                                                             iYieldDemandPair);
00066       _classPathDemandMap.insert (lPairStringDemandChar);
00067       const StringCabinClassPair_T lStringCabinClassPair (lCabinClassPath,
00068                                                           iCabinClassPairList);
00069       _stringCabinClassPairListMap.insert (lStringCabinClassPair);
00070     } else {
00071         it->second = iYieldDemandPair;
00072     }
00073   }
00074 
00075   // ////////////////////////////////////////////////////////////////////
00076   void OnDDate::setTotalForecast (const CabinCode_T& iCabinCode,
00077                                   const WTPDemandPair_T& iWTPDemandPair) {
00078 
00079     CabinForecastMap_T::iterator it =
00080       _cabinForecastMap.find (iCabinCode);
00081     if (it == _cabinForecastMap.end()) {
00082       const CabinForecastPair_T lPairCabinForecastChar (iCabinCode,
00083                                                         iWTPDemandPair);
00084       _cabinForecastMap.insert (lPairCabinForecastChar);
00085     } else {
00086       assert (false);
00087     }
00088   }
00089   
00090 }