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

stdair/bom/SimpleNestingStructure.cpp

Go to the documentation of this file.
00001 // //////////////////////////////////////////////////////////////////////
00002 // Import section
00003 // //////////////////////////////////////////////////////////////////////
00004 // STL
00005 #include <sstream>
00006 #include <cassert>
00007 #include <iomanip>
00008 #include <iostream>
00009 //STDAIR
00010 #include <stdair/stdair_exceptions.hpp>
00011 #include <stdair/basic/BasConst_Inventory.hpp>
00012 #include <stdair/bom/BomManager.hpp>
00013 #include <stdair/bom/BookingClass.hpp>
00014 #include <stdair/bom/BookingClass.hpp>
00015 #include <stdair/bom/SimpleNestingStructure.hpp>
00016 #include <stdair/bom/NestingNode.hpp>
00017 #include <stdair/bom/NestingNodeTypes.hpp>
00018 #include <stdair/service/Logger.hpp>
00019 
00020 namespace stdair {
00021     
00022   // ////////////////////////////////////////////////////////////////////
00023   SimpleNestingStructure::SimpleNestingStructure () : 
00024     _key (DEFAULT_NESTING_STRUCTURE_CODE), _parent (NULL) {
00025     assert (false);
00026   }
00027 
00028   // ////////////////////////////////////////////////////////////////////
00029   SimpleNestingStructure::
00030   SimpleNestingStructure (const SimpleNestingStructure& iSimpleNestingStructure)
00031   : _key (DEFAULT_NESTING_STRUCTURE_CODE), _parent (NULL) {
00032     assert (false);
00033   }
00034 
00035   // ////////////////////////////////////////////////////////////////////
00036   SimpleNestingStructure::SimpleNestingStructure (const Key_T& iKey)
00037   : _key (iKey), _parent (NULL) {
00038   }
00039     
00040   // ////////////////////////////////////////////////////////////////////
00041   SimpleNestingStructure::~SimpleNestingStructure() {
00042   }
00043   
00044   // ////////////////////////////////////////////////////////////////////
00045   // const bool SimpleNestingStructure::insertBookingClassList(const Yield_T& iYield,
00046   //                                   const BookingClassList_T& iBookingClassList) {
00047   //   const bool isBookinClassListEmpty = iBookingClassList.empty();
00048   //   if (isBookinClassListEmpty == true) {
00049   //     std::ostringstream ostr;
00050   //     ostr << "The booking class list is empty and it should not be. "
00051   //       "No insertion done in the nesting structure (";
00052   //     toStream(ostr);
00053   //     ostr << ").";
00054   //     STDAIR_LOG_DEBUG(ostr.str());
00055   //     throw BookingClassListEmptyInNestingStructException(ostr.str());
00056   //   }
00057   //   assert(isBookinClassListEmpty == false);
00058   //   NestingNodeMap_T::iterator itNestingNode = _nestingNodeMap.find (iYield);
00059   //   bool insertionSucceeded = false;
00060   //   // Search a node with the same yield and add the
00061   //   // booking classes to the booking class list of the node.
00062   //   // If there is not a node with the same yield, create it.
00063   //   if (itNestingNode == _nestingNodeMap.end()) {
00064   //     NestingNode_T lNode (iYield, iBookingClassList);
00065   //     insertionSucceeded = _nestingNodeMap.insert(lNode).second;
00066   //   } else {
00067   //     NestingNode_T& lNode = *itNestingNode;
00068   //     const Yield_T& lYield = lNode.first;
00069   //     assert(lYield == iYield);
00070   //     BookingClassList_T& lBCList = lNode.second;
00071   //     for (BookingClassList_T::const_iterator itBC = iBookingClassList.begin(); 
00072   //          itBC != iBookingClassList.end(); ++itBC) {
00073   //       BookingClass* lBC_ptr = *itBC;
00074   //       assert(lBC_ptr != NULL);
00075   //       lBCList.push_back(lBC_ptr);
00076   //     }
00077   //     insertionSucceeded = true;
00078   //   }
00079 
00080   //   return insertionSucceeded;
00081   // }
00082 
00083   // ////////////////////////////////////////////////////////////////////
00084   // const bool SimpleNestingStructure::
00085   // alreadyInNestingStructure(const ClassCode_T& iClassCode) const {
00086   //   bool isAlreadyInTheMap = false;
00087   //   NestingNodeMap_T::const_iterator itMap = _nestingNodeMap.begin();
00088   //   for(; itMap != _nestingNodeMap.end(); ++itMap) {
00089   //     const NestingNode_T& lNestingNode = *itMap;
00090   //     const BookingClassList_T& lBCList = lNestingNode.second;
00091   //     BookingClassList_T::const_iterator itBC = lBCList.begin();
00092   //     for (;itBC != lBCList.end(); ++itBC) {
00093   //       BookingClass* lBC_ptr = *itBC;
00094   //       assert(lBC_ptr != NULL);
00095   //       const BookingClassKey& lBookingClassKey = lBC_ptr->getKey();
00096   //       const ClassCode_T& lClassCode = lBookingClassKey.getClassCode();
00097   //       if (lClassCode == iClassCode) {
00098   //         isAlreadyInTheMap = true;
00099   //         return isAlreadyInTheMap;
00100   //       }
00101   //     }
00102   //   }
00103   //   return isAlreadyInTheMap;
00104   // }
00105     
00106   // ////////////////////////////////////////////////////////////////////
00107   std::string SimpleNestingStructure::toString () const {
00108     std::ostringstream oStr;
00109     oStr << describeKey();
00110  
00111     return oStr.str();
00112   }
00113 
00114   // ////////////////////////////////////////////////////////////////////
00115   const NestingNodeList_T& SimpleNestingStructure::getNestingNodeList() const {
00116     return BomManager::getList<NestingNode> (*this);
00117   }
00118   
00119 }