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

stdair/bom/SegmentCabin.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_BookingClass.hpp>
00009 #include <stdair/basic/BasConst_Inventory.hpp>
00010 #include <stdair/basic/BasConst_Yield.hpp>
00011 #include <stdair/basic/BasConst_BomDisplay.hpp>
00012 #include <stdair/bom/BomManager.hpp>
00013 #include <stdair/bom/SegmentDate.hpp>
00014 #include <stdair/bom/SegmentCabin.hpp>
00015 #include <stdair/bom/BookingClass.hpp>
00016 #include <stdair/bom/BookingClassTypes.hpp>
00017 #include <stdair/bom/Policy.hpp>
00018 
00019 namespace stdair {
00020 
00021   // ////////////////////////////////////////////////////////////////////
00022   SegmentCabin::SegmentCabin() : _key (DEFAULT_CABIN_CODE), _parent (NULL) {
00023     assert (false);
00024   }
00025 
00026   // ////////////////////////////////////////////////////////////////////
00027   SegmentCabin::SegmentCabin (const SegmentCabin& iSegmentCabin)
00028     : _key (iSegmentCabin._key), _parent (NULL),
00029       _capacity (iSegmentCabin._capacity),
00030       _blockSpace (iSegmentCabin._blockSpace),
00031       _bookingCounter (iSegmentCabin._bookingCounter),
00032       _committedSpace (iSegmentCabin._committedSpace),
00033       _availabilityPool (iSegmentCabin._availabilityPool),
00034       _currentBidPrice (iSegmentCabin._currentBidPrice),
00035       _fareFamilyActivation (iSegmentCabin._fareFamilyActivation) {
00036   }
00037 
00038   // ////////////////////////////////////////////////////////////////////
00039   SegmentCabin::SegmentCabin (const Key_T& iKey)
00040     : _key (iKey), _parent (NULL),
00041       _capacity (DEFAULT_CABIN_CAPACITY),
00042       _blockSpace (DEFAULT_BLOCK_SPACE),
00043       _bookingCounter (DEFAULT_CLASS_NB_OF_BOOKINGS),
00044       _committedSpace (DEFAULT_COMMITTED_SPACE),
00045       _availabilityPool (DEFAULT_AVAILABILITY),
00046       _bidPriceVector (DEFAULT_BID_PRICE_VECTOR),
00047       _currentBidPrice (DEFAULT_BID_PRICE),
00048       _fareFamilyActivation (false) {
00049   }
00050 
00051   // ////////////////////////////////////////////////////////////////////
00052   SegmentCabin::~SegmentCabin() {
00053   }
00054 
00055   // ////////////////////////////////////////////////////////////////////
00056   const MapKey_T SegmentCabin::getFullerKey() const {
00057     const SegmentDate& lSegmentDate = BomManager::getParent<SegmentDate>(*this);
00058 
00059     const MapKey_T oFullKey =
00060       lSegmentDate.describeKey() + DEFAULT_KEY_FLD_DELIMITER + getCabinCode();
00061     return oFullKey;
00062   }
00063 
00064   // ////////////////////////////////////////////////////////////////////
00065   std::string SegmentCabin::toString() const {
00066     std::ostringstream oStr;
00067     oStr << describeKey();
00068     return oStr.str();
00069   }
00070 
00071   // ////////////////////////////////////////////////////////////////////
00072   const std::string SegmentCabin::describeConvexHull() const{
00073     std::ostringstream oStr;
00074     for (PolicyList_T::const_iterator itP = _convexHull.begin();
00075         itP != _convexHull.end(); ++itP) {
00076       const Policy* lPolicy = *itP;
00077       assert (lPolicy != NULL);
00078       oStr << lPolicy->toString();
00079     }
00080     return oStr.str();
00081   }
00082 
00083   // ////////////////////////////////////////////////////////////////////
00084   void SegmentCabin::
00085   updateFromReservation (const NbOfBookings_T& iNbOfBookings) {
00086     _committedSpace += iNbOfBookings;
00087   }
00088 
00089   // ////////////////////////////////////////////////////////////////////
00090   void SegmentCabin::addPolicy (Policy& ioPolicy) {
00091     _convexHull.push_back (&ioPolicy);
00092   }
00093 }
00094