From: <qua...@us...> - 2009-11-12 16:44:56
|
Revision: 62 http://stdair.svn.sourceforge.net/stdair/?rev=62&view=rev Author: quannaus Date: 2009-11-12 16:44:45 +0000 (Thu, 12 Nov 2009) Log Message: ----------- [Dev] Migrated some more functions from LATUS_COM. Modified Paths: -------------- trunk/stdair/stdair/bom/AirlineFeatureKey.cpp trunk/stdair/stdair/bom/AirlineFeatureKey.hpp trunk/stdair/stdair/bom/AirlineFeatureSet.cpp trunk/stdair/stdair/bom/AirlineFeatureSet.hpp trunk/stdair/stdair/bom/AirlineFeatureSetKey.cpp trunk/stdair/stdair/bom/AirlineFeatureSetKey.hpp trunk/stdair/stdair/bom/AirlineFeatureSetStructure.hpp trunk/stdair/stdair/bom/BomChildrenHolderImp.hpp trunk/stdair/stdair/bom/BomKey.hpp trunk/stdair/stdair/bom/BomList.hpp trunk/stdair/stdair/bom/BomRoot.cpp trunk/stdair/stdair/bom/BomRoot.hpp trunk/stdair/stdair/bom/BomRootContent.hpp trunk/stdair/stdair/bom/BomRootKey.cpp trunk/stdair/stdair/bom/BomRootKey.hpp trunk/stdair/stdair/bom/BookingClassKey.cpp trunk/stdair/stdair/bom/BookingClassKey.hpp trunk/stdair/stdair/bom/FlightDate.hpp trunk/stdair/stdair/bom/FlightDateKey.cpp trunk/stdair/stdair/bom/FlightDateKey.hpp trunk/stdair/stdair/bom/FlightDateStructure.hpp trunk/stdair/stdair/bom/Inventory.cpp trunk/stdair/stdair/bom/Inventory.hpp trunk/stdair/stdair/bom/InventoryKey.cpp trunk/stdair/stdair/bom/InventoryKey.hpp trunk/stdair/stdair/bom/InventoryStructure.hpp trunk/stdair/stdair/bom/LegCabinKey.cpp trunk/stdair/stdair/bom/LegCabinKey.hpp trunk/stdair/stdair/bom/LegDateKey.cpp trunk/stdair/stdair/bom/LegDateKey.hpp trunk/stdair/stdair/bom/SegmentCabinKey.cpp trunk/stdair/stdair/bom/SegmentCabinKey.hpp trunk/stdair/stdair/bom/SegmentDateKey.cpp trunk/stdair/stdair/bom/SegmentDateKey.hpp trunk/stdair/stdair/factory/FacBomContent.hpp trunk/stdair/stdair/factory/FacBomStructure.hpp Modified: trunk/stdair/stdair/bom/AirlineFeatureKey.cpp =================================================================== --- trunk/stdair/stdair/bom/AirlineFeatureKey.cpp 2009-11-06 23:55:05 UTC (rev 61) +++ trunk/stdair/stdair/bom/AirlineFeatureKey.cpp 2009-11-12 16:44:45 UTC (rev 62) @@ -25,10 +25,15 @@ } // //////////////////////////////////////////////////////////////////// - std::string AirlineFeatureKey_T::toString() const { + const std::string AirlineFeatureKey_T::toString() const { std::ostringstream oStr; oStr << _airlineCode; return oStr.str(); } + // //////////////////////////////////////////////////////////////////// + const std::string AirlineFeatureKey_T::describe() const { + return toString(); + } + } Modified: trunk/stdair/stdair/bom/AirlineFeatureKey.hpp =================================================================== --- trunk/stdair/stdair/bom/AirlineFeatureKey.hpp 2009-11-06 23:55:05 UTC (rev 61) +++ trunk/stdair/stdair/bom/AirlineFeatureKey.hpp 2009-11-12 16:44:45 UTC (rev 62) @@ -7,12 +7,18 @@ // STDAIR #include <stdair/STDAIR_Types.hpp> #include <stdair/bom/BomKey.hpp> +#include <stdair/bom/AirlineFeatureSetKey.hpp> namespace stdair { /** Key of AirlineFeature. */ struct AirlineFeatureKey_T : public BomKey_T { - + public: + // /////////// Typedefs //////////// + /** Definition allowing to retrieve the parent key type. */ + typedef AirlineFeatureSetKey_T ParentKey_T; + + public: // /////////// Construction /////////// /** Constructor. */ AirlineFeatureKey_T (const AirlineCode_T& iAirlineCode); @@ -22,8 +28,11 @@ // /////////// Getters ////////// /** Get the airline code. */ - const AirlineCode_T& getAirlineCode() const; + const AirlineCode_T& getAirlineCode() const { return _airlineCode; } + // /////////// Setters ///////////// + void setParentKey (const ParentKey_T& iParentKey) { } + // /////////// Display support methods ///////// /** Dump a Business Object Key into an output stream. @param ostream& the output stream. */ @@ -38,8 +47,11 @@ when among children of a given parent Business Object. <br>For instance, "H" and "K" allow to differentiate among two marketing classes for the same segment-date. */ - std::string toString() const; + const std::string toString() const; + /** Display of the key. */ + const std::string describe() const; + private: // Attributes /** Airline code. */ Modified: trunk/stdair/stdair/bom/AirlineFeatureSet.cpp =================================================================== --- trunk/stdair/stdair/bom/AirlineFeatureSet.cpp 2009-11-06 23:55:05 UTC (rev 61) +++ trunk/stdair/stdair/bom/AirlineFeatureSet.cpp 2009-11-12 16:44:45 UTC (rev 62) @@ -17,7 +17,7 @@ AirlineFeatureSet (const BomKey_T& iKey, BomStructure_T& ioAirlineFeatureSetStructure) : AirlineFeatureSetContent (iKey), - _bomRootStructure (ioAirlineFeatureSetStructure) { + _bomStructure (ioAirlineFeatureSetStructure) { } // //////////////////////////////////////////////////////////////////// @@ -48,29 +48,18 @@ // ////////////////////////////////////////////////////////////////////// AirlineFeatureList_T AirlineFeatureSet::getAirlineFeatureList () const { - return _bomRootStructure.getChildrenList(); + return _bomStructure.getChildrenList(); } // ////////////////////////////////////////////////////////////////////// AirlineFeatureMap_T AirlineFeatureSet::getAirlineFeatureMap () const { - return _bomRootStructure.getChildrenList(); + return _bomStructure.getChildrenList(); } // ////////////////////////////////////////////////////////////////////// - const AirlineFeature* AirlineFeatureSet:: - getAirlineFeature (const AirlineCode_T& iAirlineCode) const { - - AirlineFeatureMap_T lAirlineFeatureMap = getAirlineFeatureMap (); - AirlineFeatureMap_T::iterator itAirlineFeature = - lAirlineFeatureMap.find (iAirlineCode); - - if (itAirlineFeature != lAirlineFeatureMap.end()) { - const AirlineFeature* oAirlineFeature_ptr = itAirlineFeature->second; - assert (oAirlineFeature_ptr != NULL); - return oAirlineFeature_ptr; - } - - return NULL; + AirlineFeature* AirlineFeatureSet:: + getAirlineFeature (const AirlineFeatureKey_T& iKey) const { + return _bomStructure.getContentChild (iKey); } } Modified: trunk/stdair/stdair/bom/AirlineFeatureSet.hpp =================================================================== --- trunk/stdair/stdair/bom/AirlineFeatureSet.hpp 2009-11-06 23:55:05 UTC (rev 61) +++ trunk/stdair/stdair/bom/AirlineFeatureSet.hpp 2009-11-12 16:44:45 UTC (rev 62) @@ -14,6 +14,7 @@ // Forward declarations. class FacBomContent; class AirlineFeature; + struct AirlineFeatureKey_T; struct AirlineFeatureSetKey_T; /** Class representing the actual functional/business content @@ -63,7 +64,7 @@ /** Retrieve, if existing, the Airline features corresponding to the given airline code. <br>If not existing, return the NULL pointer. */ - const AirlineFeature* getAirlineFeature (const AirlineCode_T&) const; + AirlineFeature* getAirlineFeature (const AirlineFeatureKey_T&) const; /** Get a AirlineFeatureList_T for iteration methods. */ AirlineFeatureList_T getAirlineFeatureList () const; @@ -74,7 +75,7 @@ private: /** Retrieve the BOM structure object. */ BomStructure_T& getBomStructure () { - return _bomRootStructure; + return _bomStructure; } protected: @@ -90,7 +91,7 @@ private: // Attributes /** Reference structure. */ - BomStructure_T& _bomRootStructure; + BomStructure_T& _bomStructure; }; } Modified: trunk/stdair/stdair/bom/AirlineFeatureSetKey.cpp =================================================================== --- trunk/stdair/stdair/bom/AirlineFeatureSetKey.cpp 2009-11-06 23:55:05 UTC (rev 61) +++ trunk/stdair/stdair/bom/AirlineFeatureSetKey.cpp 2009-11-12 16:44:45 UTC (rev 62) @@ -24,10 +24,15 @@ } // //////////////////////////////////////////////////////////////////// - std::string AirlineFeatureSetKey_T::toString() const { + const std::string AirlineFeatureSetKey_T::toString() const { std::ostringstream oStr; oStr << " -- AIRLINE FEATURE SET -- "; return oStr.str(); } + // //////////////////////////////////////////////////////////////////// + const std::string AirlineFeatureSetKey_T::describe() const { + return toString(); + } + } Modified: trunk/stdair/stdair/bom/AirlineFeatureSetKey.hpp =================================================================== --- trunk/stdair/stdair/bom/AirlineFeatureSetKey.hpp 2009-11-06 23:55:05 UTC (rev 61) +++ trunk/stdair/stdair/bom/AirlineFeatureSetKey.hpp 2009-11-12 16:44:45 UTC (rev 62) @@ -35,8 +35,11 @@ when among children of a given parent Business Object. <br>For instance, "H" and "K" allow to differentiate among two marketing classes for the same segment-date. */ - std::string toString() const; + const std::string toString() const; + /** Display of the key. */ + const std::string describe() const; + private: // Attributes // No attributes, as that class corresponds to the root of Bom structure. Modified: trunk/stdair/stdair/bom/AirlineFeatureSetStructure.hpp =================================================================== --- trunk/stdair/stdair/bom/AirlineFeatureSetStructure.hpp 2009-11-06 23:55:05 UTC (rev 61) +++ trunk/stdair/stdair/bom/AirlineFeatureSetStructure.hpp 2009-11-12 16:44:45 UTC (rev 62) @@ -12,8 +12,12 @@ #include <stdair/bom/BomStructureDummy.hpp> #include <stdair/bom/BomContentDummy.hpp> #include <stdair/bom/AirlineFeatureStructure.hpp> +#include <stdair/bom/AirlineFeatureKey.hpp> namespace stdair { + // Forward declarations. + template <typename BOM> struct BomMap_T; + /** Wrapper class aimed at holding the actual content, modeled by a specific AirlineFeatureSet class. */ template <typename BOM_CONTENT> @@ -31,6 +35,13 @@ BOM_CONTENT. */ typedef typename BOM_CONTENT::ContentChild_T ContentChild_T; + /** Definition allowing to retrieve the key type of the + ContentChild_T. */ + typedef AirlineFeatureKey_T ChildKey_T; + + /** Define the map of ContentChild_T. */ + typedef BomMap_T<ContentChild_T> ChildrenMap_T; + private: // Type definitions /** Definition allowing to retrieve the associated BOM key type. */ @@ -63,7 +74,27 @@ void getChildrenList (ChildrenBomHolder_T*& ioChildrenList) { ioChildrenList = _childrenList; } - + + /** Retrieve, if existing, the airline feature corresponding to the + given key. + <br>If not exissting, return the NULL pointer. */ + ContentChild_T* getContentChild (const ChildKey_T& iKey) const { + ContentChild_T* oContentChild_ptr = NULL; + + ChildrenMap_T lChildrenMap (getChildrenList()); + const MapKey_T lMapKey = iKey.toString(); + + typename ChildrenMap_T::iterator itContentChild = + lChildrenMap.find (lMapKey); + + if (itContentChild != lChildrenMap.end()) { + oContentChild_ptr = itContentChild->second; + return oContentChild_ptr; + } + + assert (oContentChild_ptr != NULL); + } + private: /////////////// Setters //////////////// /** Default children list setter. */ Modified: trunk/stdair/stdair/bom/BomChildrenHolderImp.hpp =================================================================== --- trunk/stdair/stdair/bom/BomChildrenHolderImp.hpp 2009-11-06 23:55:05 UTC (rev 61) +++ trunk/stdair/stdair/bom/BomChildrenHolderImp.hpp 2009-11-12 16:44:45 UTC (rev 62) @@ -109,7 +109,14 @@ MapReverseIterator_T mapREnd () const { return _bomChildrenList.rend(); } + + // /////////// Other operators ///////////// + /** Get the size of the list. */ + const unsigned int size () const { + return _bomChildrenOrderedList.size(); + } + /** Retrieve, if existing, the bom corresponding to the given key. */ MapIterator_T find (const MapKey_T& iKey) const { return _bomChildrenList.find (iKey); Modified: trunk/stdair/stdair/bom/BomKey.hpp =================================================================== --- trunk/stdair/stdair/bom/BomKey.hpp 2009-11-06 23:55:05 UTC (rev 61) +++ trunk/stdair/stdair/bom/BomKey.hpp 2009-11-12 16:44:45 UTC (rev 62) @@ -34,7 +34,12 @@ when among children of a given parent Business Object. <br>For instance, "H" and "K" allow to differentiate among two marketing classes for the same segment-date. */ - virtual std::string toString() const { return std::string("Hello!"); } + virtual const std::string toString() const { return std::string("Hello!"); } + + /** Display of the key. + <br>That string is unique at all levels. + */ + virtual const std::string describe() const { return toString(); } }; } Modified: trunk/stdair/stdair/bom/BomList.hpp =================================================================== --- trunk/stdair/stdair/bom/BomList.hpp 2009-11-06 23:55:05 UTC (rev 61) +++ trunk/stdair/stdair/bom/BomList.hpp 2009-11-12 16:44:45 UTC (rev 62) @@ -50,6 +50,10 @@ return the reverse iterator at the end of the list. */ reverse_iterator rend () const { return _bomHolder.listREnd(); } + // /////////// Other operators ///////////// + /** Get the size of the list. */ + const unsigned int size () const { return _bomHolder.size(); } + public: /** Default constructors. */ BomList_T (); Modified: trunk/stdair/stdair/bom/BomRoot.cpp =================================================================== --- trunk/stdair/stdair/bom/BomRoot.cpp 2009-11-06 23:55:05 UTC (rev 61) +++ trunk/stdair/stdair/bom/BomRoot.cpp 2009-11-12 16:44:45 UTC (rev 62) @@ -21,13 +21,27 @@ BomRoot::~BomRoot () { } - // ////////////////////////////////////////////////////////////////////// + // //////////////////////////////////////////////////////////////////// InventoryList_T BomRoot::getInventoryList () const { return _bomRootStructure.getChildrenList(); } - // ////////////////////////////////////////////////////////////////////// + // //////////////////////////////////////////////////////////////////// InventoryMap_T BomRoot::getInventoryMap () const { return _bomRootStructure.getChildrenList(); } + + Inventory* BomRoot::getInventory (const AirlineCode_T& iAirlineCode) const { + Inventory* oInventory_ptr = NULL; + + InventoryMap_T lInventoryMap = getInventoryMap (); + InventoryMap_T::iterator itInv = lInventoryMap.find (iAirlineCode); + + if (itInv != lInventoryMap.end()) { + oInventory_ptr = itInv->second; + } + + return oInventory_ptr; + } + } Modified: trunk/stdair/stdair/bom/BomRoot.hpp =================================================================== --- trunk/stdair/stdair/bom/BomRoot.hpp 2009-11-06 23:55:05 UTC (rev 61) +++ trunk/stdair/stdair/bom/BomRoot.hpp 2009-11-12 16:44:45 UTC (rev 62) @@ -109,6 +109,11 @@ return *_airlineFeatureSet; } + /** Retrieve, if existing, the Inventory corresponding to the + given airline code (Inventory key). + <br>If not existing, return the NULL pointer. */ + Inventory* getInventory (const AirlineCode_T&) const; + public: // //////////// Setters ////////////// /** Set the reference to the AirlineFeatureSet object. */ Modified: trunk/stdair/stdair/bom/BomRootContent.hpp =================================================================== --- trunk/stdair/stdair/bom/BomRootContent.hpp 2009-11-06 23:55:05 UTC (rev 61) +++ trunk/stdair/stdair/bom/BomRootContent.hpp 2009-11-12 16:44:45 UTC (rev 62) @@ -101,6 +101,13 @@ void setLoadFactor (const Revenue_T& iWSLF) { _wScheduleLoadFactor = iWSLF; } + + public: + // /////////// Business methods /////////// + /** Update the counter of flight-dates. */ + void updateFlightDateCounter() { + _flightDateCounter++; + } public: // /////////// Display support methods ///////// Modified: trunk/stdair/stdair/bom/BomRootKey.cpp =================================================================== --- trunk/stdair/stdair/bom/BomRootKey.cpp 2009-11-06 23:55:05 UTC (rev 61) +++ trunk/stdair/stdair/bom/BomRootKey.cpp 2009-11-12 16:44:45 UTC (rev 62) @@ -24,10 +24,15 @@ } // //////////////////////////////////////////////////////////////////// - std::string BomRootKey_T::toString() const { + const std::string BomRootKey_T::toString() const { std::ostringstream oStr; oStr << " -- ROOT -- "; return oStr.str(); } + + // //////////////////////////////////////////////////////////////////// + const std::string BomRootKey_T::describe() const { + return toString(); + } } Modified: trunk/stdair/stdair/bom/BomRootKey.hpp =================================================================== --- trunk/stdair/stdair/bom/BomRootKey.hpp 2009-11-06 23:55:05 UTC (rev 61) +++ trunk/stdair/stdair/bom/BomRootKey.hpp 2009-11-12 16:44:45 UTC (rev 62) @@ -33,8 +33,11 @@ when among children of a given parent Business Object. <br>For instance, "H" and "K" allow to differentiate among two marketing classes for the same segment-date. */ - std::string toString() const; + const std::string toString() const; + /** Display of the key. */ + const std::string describe() const; + private: // Attributes }; Modified: trunk/stdair/stdair/bom/BookingClassKey.cpp =================================================================== --- trunk/stdair/stdair/bom/BookingClassKey.cpp 2009-11-06 23:55:05 UTC (rev 61) +++ trunk/stdair/stdair/bom/BookingClassKey.cpp 2009-11-12 16:44:45 UTC (rev 62) @@ -25,10 +25,17 @@ } // //////////////////////////////////////////////////////////////////// - std::string BookingClassKey_T::toString() const { + const std::string BookingClassKey_T::toString() const { std::ostringstream oStr; oStr << _classCode; return oStr.str(); } + // //////////////////////////////////////////////////////////////////// + const std::string BookingClassKey_T::describe() const { + std::ostringstream oStr; + oStr << _parentKey.describe() << ", " << toString(); + return oStr.str(); + } + } Modified: trunk/stdair/stdair/bom/BookingClassKey.hpp =================================================================== --- trunk/stdair/stdair/bom/BookingClassKey.hpp 2009-11-06 23:55:05 UTC (rev 61) +++ trunk/stdair/stdair/bom/BookingClassKey.hpp 2009-11-12 16:44:45 UTC (rev 62) @@ -7,12 +7,18 @@ // STDAIR #include <stdair/STDAIR_Types.hpp> #include <stdair/bom/BomKey.hpp> +#include <stdair/bom/SegmentCabinKey.hpp> namespace stdair { /** Key of segment-cabin. */ struct BookingClassKey_T : public BomKey_T { - + public: + // /////////// Typedefs //////////// + /** Definition allowing to retrieve the parent key type. */ + typedef SegmentCabinKey_T ParentKey_T; + + public: // /////////// Construction /////////// /** Constructor. */ BookingClassKey_T (const ClassCode_T& iClassCode); @@ -24,6 +30,11 @@ /** Get the cabin code. */ const ClassCode_T& getClassCode () const; + // /////////// Setters ///////////// + void setParentKey (const ParentKey_T& iParentKey) { + _parentKey = iParentKey; + } + // /////////// Display support methods ///////// /** Dump a Business Object Key into an output stream. @param ostream& the output stream. */ @@ -38,10 +49,16 @@ when among children of a given parent Business Object. <br>For instance, "H" and "K" allow to differentiate among two marketing classes for the same segment-cabin. */ - std::string toString() const; + const std::string toString() const; + /** Display of the key. */ + const std::string describe() const; + private: // Attributes + /** Segment-cabin key.*/ + ParentKey_T _parentKey; + /** Cabin code. */ ClassCode_T _classCode; }; Modified: trunk/stdair/stdair/bom/FlightDate.hpp =================================================================== --- trunk/stdair/stdair/bom/FlightDate.hpp 2009-11-06 23:55:05 UTC (rev 61) +++ trunk/stdair/stdair/bom/FlightDate.hpp 2009-11-12 16:44:45 UTC (rev 62) @@ -46,6 +46,9 @@ BOM content child type. */ typedef LegDate SecondContentChild_T; + /** Definition allowing to retrieve the specific BookingClass type. */ + typedef BookingClass BookingClassContent_T; + public: // /////////// Getters ///////////// /** Get a SegmentDateList_T for iteration methods. */ Modified: trunk/stdair/stdair/bom/FlightDateKey.cpp =================================================================== --- trunk/stdair/stdair/bom/FlightDateKey.cpp 2009-11-06 23:55:05 UTC (rev 61) +++ trunk/stdair/stdair/bom/FlightDateKey.cpp 2009-11-12 16:44:45 UTC (rev 62) @@ -13,6 +13,12 @@ } // //////////////////////////////////////////////////////////////////// + FlightDateKey_T::FlightDateKey_T (const FlightDateKey_T& iKey) + : _parentKey (iKey._parentKey), + _flightNumber (iKey._flightNumber), _flightDate (iKey._flightDate) { + } + + // //////////////////////////////////////////////////////////////////// FlightDateKey_T::~FlightDateKey_T () { } @@ -26,10 +32,17 @@ } // //////////////////////////////////////////////////////////////////// - std::string FlightDateKey_T::toString() const { + const std::string FlightDateKey_T::toString() const { std::ostringstream oStr; oStr << _flightNumber << ", " << _flightDate; return oStr.str(); } + + // //////////////////////////////////////////////////////////////////// + const std::string FlightDateKey_T::describe() const { + std::ostringstream oStr; + oStr << _parentKey.describe() << ", " << toString(); + return oStr.str(); + } } Modified: trunk/stdair/stdair/bom/FlightDateKey.hpp =================================================================== --- trunk/stdair/stdair/bom/FlightDateKey.hpp 2009-11-06 23:55:05 UTC (rev 61) +++ trunk/stdair/stdair/bom/FlightDateKey.hpp 2009-11-12 16:44:45 UTC (rev 62) @@ -7,15 +7,28 @@ // STDAIR #include <stdair/STDAIR_Types.hpp> #include <stdair/bom/BomKey.hpp> +#include <stdair/bom/InventoryKey.hpp> namespace stdair { /** Key of flight-date. */ struct FlightDateKey_T : public BomKey_T { + friend struct SegmentDateKey_T; + friend struct LegDateKey_T; public: + // /////////// Typedefs //////////// + /** Definition allowing to retrieve the parent key type. */ + typedef InventoryKey_T ParentKey_T; + + private: + // /////////// Default constructor ////////// + FlightDateKey_T () { }; + + public: // /////////// Construction /////////// - /** Constructor. */ + /** Constructors. */ FlightDateKey_T (const FlightNumber_T&, const Date_T&); + FlightDateKey_T (const FlightDateKey_T&); /** Destructor. */ ~FlightDateKey_T (); @@ -31,6 +44,12 @@ return _flightDate; } + // /////////// Setters ///////////// + /** Set the parent key. */ + void setParentKey (const ParentKey_T& iParentKey) { + _parentKey = iParentKey; + } + // /////////// Display support methods ///////// /** Dump a Business Object Key into an output stream. @param ostream& the output stream. */ @@ -45,10 +64,16 @@ when among children of a given parent Business Object. <br>For instance, "H" and "K" allow to differentiate among two marketing classes for the same segment-date. */ - std::string toString() const; + const std::string toString() const; + /** Display of the key. */ + const std::string describe() const; + private: // Attributes + /** Inventory Key.*/ + ParentKey_T _parentKey; + /** Flight number. */ FlightNumber_T _flightNumber; Modified: trunk/stdair/stdair/bom/FlightDateStructure.hpp =================================================================== --- trunk/stdair/stdair/bom/FlightDateStructure.hpp 2009-11-06 23:55:05 UTC (rev 61) +++ trunk/stdair/stdair/bom/FlightDateStructure.hpp 2009-11-12 16:44:45 UTC (rev 62) @@ -55,6 +55,9 @@ /** Definition allowing to retrive the second children bom holder type. */ typedef BomChildrenHolderImp<SecondContentChild_T> SecondChildrenBomHolder_T; + /** Define the children booking class holder type. */ + typedef BomChildrenHolderImp<typename BOM_CONTENT::BookingClassContent_T> BookingClassHolder_T; + public: // /////////// Getters ///////////// /** Get the (parent) InventoryStructure object. */ @@ -113,6 +116,11 @@ void setChildrenList (SecondChildrenBomHolder_T& ioChildrenList) { _secondChildrenList = &ioChildrenList; } + + /** Set the booking class list. */ + void setBookingClassHolder (BookingClassHolder_T& ioBookingClassHolder) { + _bookingClassHolder = &ioBookingClassHolder; + } public: // /////////// Display support methods ///////// @@ -142,8 +150,8 @@ layer. */ /** Default constructors. */ FlightDateStructure () : _parent (NULL), _content (NULL), - _childrenList (NULL), - _secondChildrenList (NULL) { } + _childrenList (NULL), _secondChildrenList (NULL), + _bookingClassHolder (NULL) { } FlightDateStructure (const FlightDateStructure&); /** Destructor. */ @@ -163,6 +171,9 @@ /** List of leg-dates. */ SecondChildrenBomHolder_T* _secondChildrenList; + /** List of booking classes. */ + BookingClassHolder_T* _bookingClassHolder; + }; } Modified: trunk/stdair/stdair/bom/Inventory.cpp =================================================================== --- trunk/stdair/stdair/bom/Inventory.cpp 2009-11-06 23:55:05 UTC (rev 61) +++ trunk/stdair/stdair/bom/Inventory.cpp 2009-11-12 16:44:45 UTC (rev 62) @@ -58,10 +58,12 @@ return _inventoryStructure.getChildrenList(); } + // ////////////////////////////////////////////////////////////////////// + FlightDate* Inventory:: + getFlightDate (const FlightDateKey_T& iKey) const { + return _inventoryStructure.getContentChild (iKey); + } -// FlightDate* getFlightDate (const FlightNumber_T& iFlightNumber, -// const Date_T& iFlightDate) const; - // BookingClass* getBookingClass (const std::string&) const; // /** Clean the list of classes. */ Modified: trunk/stdair/stdair/bom/Inventory.hpp =================================================================== --- trunk/stdair/stdair/bom/Inventory.hpp 2009-11-06 23:55:05 UTC (rev 61) +++ trunk/stdair/stdair/bom/Inventory.hpp 2009-11-12 16:44:45 UTC (rev 62) @@ -16,6 +16,7 @@ class FacBomContent; class AirlineFeature; class BookingClass; + struct FlightDateKey_T; struct InventoryKey_T; /** Class representing the actual functional/business content for @@ -83,8 +84,7 @@ /** Retrieve, if existing, the FlightDate corresponding to the given flight number and flight date (FlightDate key). <br>If not existing, return the NULL pointer. */ - // FlightDate* getFlightDate (const FlightNumber_T& iFlightNumber, -// const Date_T& iFlightDate) const; + FlightDate* getFlightDate (const FlightDateKey_T&) const; public: // /////////// Setters //////////// @@ -137,9 +137,6 @@ /** The feature set of the correspondent airline. */ const AirlineFeature* _airlineFeature; - - /** List of booking classes. */ - //BookingClassHolder_T _bookingClassList; }; } Modified: trunk/stdair/stdair/bom/InventoryKey.cpp =================================================================== --- trunk/stdair/stdair/bom/InventoryKey.cpp 2009-11-06 23:55:05 UTC (rev 61) +++ trunk/stdair/stdair/bom/InventoryKey.cpp 2009-11-12 16:44:45 UTC (rev 62) @@ -10,6 +10,10 @@ InventoryKey_T::InventoryKey_T (const AirlineCode_T& iAirlineCode) : _airlineCode (iAirlineCode) { } + // //////////////////////////////////////////////////////////////////// + InventoryKey_T::InventoryKey_T (const InventoryKey_T& iKey) + : _airlineCode (iKey._airlineCode) { + } // //////////////////////////////////////////////////////////////////// InventoryKey_T::~InventoryKey_T () { @@ -25,10 +29,15 @@ } // //////////////////////////////////////////////////////////////////// - std::string InventoryKey_T::toString() const { + const std::string InventoryKey_T::toString() const { std::ostringstream oStr; oStr << _airlineCode; return oStr.str(); } + // //////////////////////////////////////////////////////////////////// + const std::string InventoryKey_T::describe() const { + return toString(); + } + } Modified: trunk/stdair/stdair/bom/InventoryKey.hpp =================================================================== --- trunk/stdair/stdair/bom/InventoryKey.hpp 2009-11-06 23:55:05 UTC (rev 61) +++ trunk/stdair/stdair/bom/InventoryKey.hpp 2009-11-12 16:44:45 UTC (rev 62) @@ -7,15 +7,27 @@ // STDAIR #include <stdair/STDAIR_Types.hpp> #include <stdair/bom/BomKey.hpp> +#include <stdair/bom/BomRootKey.hpp> namespace stdair { /** Key of inventory. */ struct InventoryKey_T : public BomKey_T { + friend struct FlightDateKey_T; public: + // /////////// Typedefs //////////// + /** Definition allowing to retrieve the parent key type. */ + typedef BomRootKey_T ParentKey_T; + + private: + // /////////// Default constructor ////////// + InventoryKey_T () { }; + + public: // /////////// Construction /////////// - /** Constructor. */ + /** Constructors. */ InventoryKey_T (const AirlineCode_T& iAirlineCode); + InventoryKey_T (const InventoryKey_T&); /** Destructor. */ ~InventoryKey_T (); @@ -38,8 +50,15 @@ when among children of a given parent Business Object. <br>For instance, "H" and "K" allow to differentiate among two marketing classes for the same segment-date. */ - std::string toString() const; - + const std::string toString() const; + + /** Display of the key. */ + const std::string describe() const; + + // /////////// Setters ///////////// + /** Set the parent key. */ + void setParentKey (const ParentKey_T& iParentKey) const { } + private: // Attributes /** Airline code. */ Modified: trunk/stdair/stdair/bom/InventoryStructure.hpp =================================================================== --- trunk/stdair/stdair/bom/InventoryStructure.hpp 2009-11-06 23:55:05 UTC (rev 61) +++ trunk/stdair/stdair/bom/InventoryStructure.hpp 2009-11-12 16:44:45 UTC (rev 62) @@ -12,8 +12,12 @@ #include <stdair/bom/BomStructureDummy.hpp> #include <stdair/bom/BomContentDummy.hpp> #include <stdair/bom/FlightDateStructure.hpp> +#include <stdair/bom/FlightDateKey.hpp> namespace stdair { + // Forward declarations. + template <typename BOM> struct BomMap_T; + /** Wrapper class aimed at holding the actual content, modeled by an external specific Inventory class (for instance, in the AIRSCHED library). */ @@ -34,7 +38,14 @@ /** Definition allowing to retrieve the children type of the BOM_CONTENT. */ typedef typename BOM_CONTENT::ContentChild_T ContentChild_T; + + /** Definition allowing to retrieve the key type of the + ContentChild_T. */ + typedef FlightDateKey_T ChildKey_T; + /** Define the map of ContentChild_T. */ + typedef BomMap_T<ContentChild_T> ChildrenMap_T; + /** Definition allowing to retrieve the associated parent BOM structure type. */ typedef typename BOM_CONTENT::Parent_T::BomStructure_T ParentBomStructure_T; @@ -76,11 +87,31 @@ assert (_childrenList != NULL); return *_childrenList; } - - /** Get the list of flight-dates. */ + + /** Get the list of flight-dates. */ void getChildrenList (ChildrenBomHolder_T*& ioChildrenList) { ioChildrenList = _childrenList; } + + /** Retrieve, if existing, the flight-date corresponding to the + given key. + <br>If not exissting, return the NULL pointer. */ + ContentChild_T* getContentChild (const ChildKey_T& iKey) const { + ContentChild_T* oContentChild_ptr= NULL; + + ChildrenMap_T lChildrenMap (getChildrenList()); + const MapKey_T lMapKey = iKey.toString(); + + typename ChildrenMap_T::iterator itContentChild = + lChildrenMap.find (lMapKey); + + if (itContentChild != lChildrenMap.end()) { + oContentChild_ptr = itContentChild->second; + assert (oContentChild_ptr != NULL); + } + + return oContentChild_ptr; + } private: // /////////// Setters ///////////// @@ -96,6 +127,11 @@ void setChildrenList (ChildrenBomHolder_T& ioChildrenList) { _childrenList = &ioChildrenList; } + + /** Set the booking class list. */ + void setBookingClassHolder (BookingClassHolder_T& ioBookingClassHolder) { + _bookingClassHolder = &ioBookingClassHolder; + } public: // /////////// Display support methods ///////// @@ -125,7 +161,7 @@ layer. */ /** Default constructors. */ InventoryStructure () : _parent (NULL), _content (NULL), - _childrenList (NULL) { } + _childrenList (NULL), _bookingClassHolder (NULL) { } InventoryStructure (const InventoryStructure&); /** Destructor. */ Modified: trunk/stdair/stdair/bom/LegCabinKey.cpp =================================================================== --- trunk/stdair/stdair/bom/LegCabinKey.cpp 2009-11-06 23:55:05 UTC (rev 61) +++ trunk/stdair/stdair/bom/LegCabinKey.cpp 2009-11-12 16:44:45 UTC (rev 62) @@ -12,6 +12,11 @@ } // //////////////////////////////////////////////////////////////////// + LegCabinKey_T::LegCabinKey_T (const LegCabinKey_T& iKey) + : _parentKey (iKey._parentKey), _cabinCode (iKey._cabinCode) { + } + + // //////////////////////////////////////////////////////////////////// LegCabinKey_T::~LegCabinKey_T () { } @@ -25,10 +30,17 @@ } // //////////////////////////////////////////////////////////////////// - std::string LegCabinKey_T::toString() const { + const std::string LegCabinKey_T::toString() const { std::ostringstream oStr; oStr << _cabinCode; return oStr.str(); } + + // //////////////////////////////////////////////////////////////////// + const std::string LegCabinKey_T::describe() const { + std::ostringstream oStr; + oStr << _parentKey.describe() << ", " << toString(); + return oStr.str(); + } } Modified: trunk/stdair/stdair/bom/LegCabinKey.hpp =================================================================== --- trunk/stdair/stdair/bom/LegCabinKey.hpp 2009-11-06 23:55:05 UTC (rev 61) +++ trunk/stdair/stdair/bom/LegCabinKey.hpp 2009-11-12 16:44:45 UTC (rev 62) @@ -7,15 +7,27 @@ // STDAIR #include <stdair/STDAIR_Types.hpp> #include <stdair/bom/BomKey.hpp> +#include <stdair/bom/LegDateKey.hpp> namespace stdair { /** Key of leg-cabin. */ struct LegCabinKey_T : public BomKey_T { + friend struct BookingClassKey_T; public: + // /////////// Typedefs //////////// + /** Definition allowing to retrieve the parent key type. */ + typedef LegDateKey_T ParentKey_T; + + private: + // /////////// Default constructor ////////// + LegCabinKey_T () { }; + + public: // /////////// Construction /////////// - /** Constructor. */ + /** Constructors. */ LegCabinKey_T (const CabinCode_T& iCabinCode); + LegCabinKey_T (const LegCabinKey_T&); /** Destructor. */ ~LegCabinKey_T (); @@ -25,6 +37,11 @@ const CabinCode_T& getCabinCode () const { return _cabinCode; } + + // /////////// Setters ///////////// + void setParentKey (const ParentKey_T& iParentKey) { + _parentKey = iParentKey; + } // /////////// Display support methods ///////// /** Dump a Business Object Key into an output stream. @@ -40,10 +57,16 @@ when among children of a given parent Business Object. <br>For instance, "H" and "K" allow to differentiate among two marketing classes for the same leg-cabin. */ - std::string toString() const; + const std::string toString() const; + /** Display of the key. */ + const std::string describe() const; + private: // Attributes + /** Leg-date Key.*/ + ParentKey_T _parentKey; + /** Cabin code. */ CabinCode_T _cabinCode; }; Modified: trunk/stdair/stdair/bom/LegDateKey.cpp =================================================================== --- trunk/stdair/stdair/bom/LegDateKey.cpp 2009-11-06 23:55:05 UTC (rev 61) +++ trunk/stdair/stdair/bom/LegDateKey.cpp 2009-11-12 16:44:45 UTC (rev 62) @@ -10,6 +10,10 @@ LegDateKey_T::LegDateKey_T (const AirportCode_T& iBoardPoint) : _boardPoint (iBoardPoint) { } + // //////////////////////////////////////////////////////////////////// + LegDateKey_T::LegDateKey_T (const LegDateKey_T& iKey) + : _parentKey (iKey._parentKey), _boardPoint (iKey._boardPoint) { + } // //////////////////////////////////////////////////////////////////// LegDateKey_T::~LegDateKey_T () { @@ -25,10 +29,17 @@ } // //////////////////////////////////////////////////////////////////// - std::string LegDateKey_T::toString() const { + const std::string LegDateKey_T::toString() const { std::ostringstream oStr; oStr << _boardPoint; return oStr.str(); } + // //////////////////////////////////////////////////////////////////// + const std::string LegDateKey_T::describe() const { + std::ostringstream oStr; + oStr << _parentKey.describe() << ", " << toString(); + return oStr.str(); + } + } Modified: trunk/stdair/stdair/bom/LegDateKey.hpp =================================================================== --- trunk/stdair/stdair/bom/LegDateKey.hpp 2009-11-06 23:55:05 UTC (rev 61) +++ trunk/stdair/stdair/bom/LegDateKey.hpp 2009-11-12 16:44:45 UTC (rev 62) @@ -7,15 +7,27 @@ // STDAIR #include <stdair/STDAIR_Types.hpp> #include <stdair/bom/BomKey.hpp> +#include <stdair/bom/FlightDateKey.hpp> namespace stdair { /** Key of leg-date. */ struct LegDateKey_T : public BomKey_T { - + friend struct LegCabinKey_T; + public: + // /////////// Typedefs //////////// + /** Definition allowing to retrieve the parent key type. */ + typedef FlightDateKey_T ParentKey_T; + + private: + // /////////// Default constructor ////////// + LegDateKey_T () { }; + + public: // /////////// Construction /////////// - /** Constructor. */ + /** Constructors. */ LegDateKey_T (const AirportCode_T& iBoardPoint); + LegDateKey_T (const LegDateKey_T&); /** Destructor. */ ~LegDateKey_T (); @@ -26,6 +38,11 @@ return _boardPoint; } + // /////////// Setters ///////////// + void setParentKey (const ParentKey_T& iParentKey) { + _parentKey = iParentKey; + } + // /////////// Display support methods ///////// /** Dump a Business Object Key into an output stream. @param ostream& the output stream. */ @@ -40,10 +57,16 @@ when among children of a given parent Business Object. <br>For instance, "H" and "K" allow to differentiate among two marketing classes for the same leg-date. */ - std::string toString() const; + const std::string toString() const; + /** Display of the key. */ + const std::string describe() const; + private: // Attributes + /** Flight-date Key.*/ + ParentKey_T _parentKey; + /** Boarding airport. */ AirportCode_T _boardPoint; }; Modified: trunk/stdair/stdair/bom/SegmentCabinKey.cpp =================================================================== --- trunk/stdair/stdair/bom/SegmentCabinKey.cpp 2009-11-06 23:55:05 UTC (rev 61) +++ trunk/stdair/stdair/bom/SegmentCabinKey.cpp 2009-11-12 16:44:45 UTC (rev 62) @@ -12,6 +12,11 @@ } // //////////////////////////////////////////////////////////////////// + SegmentCabinKey_T::SegmentCabinKey_T (const SegmentCabinKey_T& iKey) + : _parentKey (iKey._parentKey), _cabinCode (iKey._cabinCode) { + } + + // //////////////////////////////////////////////////////////////////// SegmentCabinKey_T::~SegmentCabinKey_T () { } @@ -25,10 +30,17 @@ } // //////////////////////////////////////////////////////////////////// - std::string SegmentCabinKey_T::toString() const { + const std::string SegmentCabinKey_T::toString() const { std::ostringstream oStr; oStr << _cabinCode; return oStr.str(); } + // //////////////////////////////////////////////////////////////////// + const std::string SegmentCabinKey_T::describe() const { + std::ostringstream oStr; + oStr << _parentKey.describe() << ", " << toString(); + return oStr.str(); + } + } Modified: trunk/stdair/stdair/bom/SegmentCabinKey.hpp =================================================================== --- trunk/stdair/stdair/bom/SegmentCabinKey.hpp 2009-11-06 23:55:05 UTC (rev 61) +++ trunk/stdair/stdair/bom/SegmentCabinKey.hpp 2009-11-12 16:44:45 UTC (rev 62) @@ -7,15 +7,27 @@ // STDAIR #include <stdair/STDAIR_Types.hpp> #include <stdair/bom/BomKey.hpp> +#include <stdair/bom/SegmentDateKey.hpp> namespace stdair { /** Key of segment-cabin. */ struct SegmentCabinKey_T : public BomKey_T { + friend struct BookingClassKey_T; public: + // /////////// Typedefs //////////// + /** Definition allowing to retrieve the parent key type. */ + typedef SegmentDateKey_T ParentKey_T; + + private: + // /////////// Default constructor ////////// + SegmentCabinKey_T () { }; + + public: // /////////// Construction /////////// /** Constructor. */ SegmentCabinKey_T (const CabinCode_T& iCabinCode); + SegmentCabinKey_T (const SegmentCabinKey_T&); /** Destructor. */ ~SegmentCabinKey_T (); @@ -25,6 +37,11 @@ const CabinCode_T& getCabinCode () const { return _cabinCode; } + + // /////////// Setters ///////////// + void setParentKey (const ParentKey_T& iParentKey) { + _parentKey = iParentKey; + } // /////////// Display support methods ///////// /** Dump a Business Object Key into an output stream. @@ -40,10 +57,16 @@ when among children of a given parent Business Object. <br>For instance, "H" and "K" allow to differentiate among two marketing classes for the same segment-cabin. */ - std::string toString() const; + const std::string toString() const; + /** Display of the key. */ + const std::string describe() const; + private: // Attributes + /** Segment-date Key.*/ + ParentKey_T _parentKey; + /** Cabin code. */ CabinCode_T _cabinCode; }; Modified: trunk/stdair/stdair/bom/SegmentDateKey.cpp =================================================================== --- trunk/stdair/stdair/bom/SegmentDateKey.cpp 2009-11-06 23:55:05 UTC (rev 61) +++ trunk/stdair/stdair/bom/SegmentDateKey.cpp 2009-11-12 16:44:45 UTC (rev 62) @@ -13,6 +13,12 @@ } // //////////////////////////////////////////////////////////////////// + SegmentDateKey_T::SegmentDateKey_T (const SegmentDateKey_T& iKey) + : _parentKey (iKey._parentKey), + _boardPoint (iKey._boardPoint), _offPoint (iKey._offPoint) { + } + + // //////////////////////////////////////////////////////////////////// SegmentDateKey_T::~SegmentDateKey_T () { } @@ -26,10 +32,17 @@ } // //////////////////////////////////////////////////////////////////// - std::string SegmentDateKey_T::toString() const { + const std::string SegmentDateKey_T::toString() const { std::ostringstream oStr; oStr << _boardPoint << "-" << _offPoint; return oStr.str(); } + // //////////////////////////////////////////////////////////////////// + const std::string SegmentDateKey_T::describe() const { + std::ostringstream oStr; + oStr << _parentKey.describe() << ", " << toString(); + return oStr.str(); + } + } Modified: trunk/stdair/stdair/bom/SegmentDateKey.hpp =================================================================== --- trunk/stdair/stdair/bom/SegmentDateKey.hpp 2009-11-06 23:55:05 UTC (rev 61) +++ trunk/stdair/stdair/bom/SegmentDateKey.hpp 2009-11-12 16:44:45 UTC (rev 62) @@ -7,15 +7,27 @@ // STDAIR #include <stdair/STDAIR_Types.hpp> #include <stdair/bom/BomKey.hpp> +#include <stdair/bom/FlightDateKey.hpp> namespace stdair { /** Key of segment-date. */ struct SegmentDateKey_T : public BomKey_T { + friend struct SegmentCabinKey_T; + + public: + // /////////// Typedefs //////////// + /** Definition allowing to retrieve the parent key type. */ + typedef FlightDateKey_T ParentKey_T; + private: + // /////////// Default constructor ////////// + SegmentDateKey_T () { }; + public: // /////////// Construction /////////// - /** Constructor. */ + /** Constructors. */ SegmentDateKey_T (const AirportCode_T&, const AirportCode_T&); + SegmentDateKey_T (const SegmentDateKey_T&); /** Destructor. */ ~SegmentDateKey_T (); @@ -30,6 +42,11 @@ const AirportCode_T& getOffPoint() const { return _offPoint; } + + // /////////// Setters ///////////// + void setParentKey (const ParentKey_T& iParentKey) { + _parentKey = iParentKey; + } // /////////// Display support methods ///////// /** Dump a Business Object Key into an output stream. @@ -45,10 +62,16 @@ when among children of a given parent Business Object. <br>For instance, "H" and "K" allow to differentiate among two marketing classes for the same segment-date. */ - std::string toString() const; + const std::string toString() const; + /** Display of the key. */ + const std::string describe() const; + private: // Attributes + /** Flight-date Key.*/ + ParentKey_T _parentKey; + /** Boarding airport. */ AirportCode_T _boardPoint; Modified: trunk/stdair/stdair/factory/FacBomContent.hpp =================================================================== --- trunk/stdair/stdair/factory/FacBomContent.hpp 2009-11-06 23:55:05 UTC (rev 61) +++ trunk/stdair/stdair/factory/FacBomContent.hpp 2009-11-12 16:44:45 UTC (rev 62) @@ -16,6 +16,7 @@ namespace stdair { // Forward declarations + template<typename BOM> struct BomList_T; class BomStructure; class BomContent; struct OptimizerStruct_T; @@ -43,11 +44,18 @@ <br>A structure object is created, under the hood, with the given key. That structure object then gets a pointer on the content object. */ template <typename BOM_CONTENT_CHILD> - BOM_CONTENT_CHILD& create (typename BOM_CONTENT_CHILD::Parent_T& ioContentParent, const typename BOM_CONTENT_CHILD::BomKey_T& iKey) { + BOM_CONTENT_CHILD& create (typename BOM_CONTENT_CHILD::Parent_T& ioContentParent, typename BOM_CONTENT_CHILD::BomKey_T& ioKey) { + + // Define the parent key type. + typedef typename BOM_CONTENT_CHILD::Parent_T::BomKey_T ParentKey_T; + + // Finish the construction of the child key by setting its parent. + const ParentKey_T& lParentKey = ioContentParent.getKey(); + ioKey.setParentKey (lParentKey); // Create the child structure object for the given key BOM_CONTENT_CHILD& lBomContentChild = - createInternal<BOM_CONTENT_CHILD> (iKey); + createInternal<BOM_CONTENT_CHILD> (ioKey); // Retrieve the child structure object typename BOM_CONTENT_CHILD::BomStructure_T& lBomStructureChild = @@ -104,7 +112,83 @@ return *aBomContent_ptr; } + // ////////////////////////////////////////////////////////////////// + // Section reserved for the building the direct accesses such as + // booking class holder directly in inventory or flight-date, ect. + // ////////////////////////////////////////////////////////////////// public: + template <typename BOM_ROOT> + static void createDirectAccesses (const BOM_ROOT& iBomRoot) { + // Retrieve the inventory type. + typedef typename BOM_ROOT::ContentChild_T INVENTORY_T; + // Define the list of inventories. + typedef BomList_T<INVENTORY_T> INVENTORY_LIST_T; + + // Browse the BomRoot and build direct accesses within each inventory. + const INVENTORY_LIST_T lInventoryList = iBomRoot.getInventoryList(); + for (typename INVENTORY_LIST_T::iterator itInv = lInventoryList.begin(); + itInv != lInventoryList.end(); ++itInv) { + INVENTORY_T& lCurrentInv = *itInv; + + createDirectAccessesWithinInventory (lCurrentInv); + } + } + + private: + /** Create a holder of all booking classes within the given inventory. */ + template <typename INVENTORY> + static void createDirectAccessesWithinInventory (INVENTORY& ioInventory){ + // Retrieve the flight-date type. + typedef typename INVENTORY::ContentChild_T FLIGHT_DATE_T; + // Define the list of flight-dates. + typedef BomList_T<FLIGHT_DATE_T> FLIGHT_DATE_LIST_T; + // Retrieve the booking class type. + typedef typename INVENTORY::BookingClassContent_T BOOKING_CLASS_T; + // Define the bom holder of booking classes. + typedef BomChildrenHolderImp<BOOKING_CLASS_T> BOOKING_CLASS_HOLDER_T; + + // Initialize the booking class holder within the inventory. + BOOKING_CLASS_HOLDER_T& lBookingClassHolder = + FacBomStructure::instance().createBomHolder<BOOKING_CLASS_T> (); + ioInventory._inventoryStructure.setBookingClassHolder(lBookingClassHolder); + + // Browse the inventory and build direct accesses within each + // flight-date, then build the booking class holder within the + // inventory. + const FLIGHT_DATE_LIST_T lFlightDateList = ioInventory.getFlightDateList(); + for (typename FLIGHT_DATE_LIST_T::iterator itFlightDate = + lFlightDateList.begin(); itFlightDate != lFlightDateList.end(); + ++itFlightDate) { + FLIGHT_DATE_T& lCurrentFlightDate = *itFlightDate; + createDirectAccessesWithinFlightDate (lCurrentFlightDate); + } + } + + /** Create the direct acceeses within the given flight-date, and, at the + same time, build the class holder for the parent inventory. */ + template <typename FLIGHT_DATE> + static void createDirectAccessesWithinFlightDate (const FLIGHT_DATE& ioFlightDate) { + // Retrieve the booking class type. + typedef typename FLIGHT_DATE::BookingClassContent_T BOOKING_CLASS_T; + // Define the bom holder of booking classes. + typedef BomChildrenHolderImp<BOOKING_CLASS_T> BOOKING_CLASS_HOLDER_T; + + typename FLIGHT_DATE::BomStructure_T::ParentBomStructure_T& lInvStructure = + ioFlightDate._flightDateStructure.getInventoryStructure(); + + BOOKING_CLASS_HOLDER_T* lInvBookingClassHolder_ptr = + lInvStructure._bookingClassHolder; + assert (lInvBookingClassHolder_ptr != NULL); + + // Retrieve the segment-date type. + typedef typename FLIGHT_DATE::ContentChild_T SEGMENT_DATE_T; + // Define the list of segment-dates. + typedef BomList_T<SEGMENT_DATE_T> SEGMENT_DATE_LIST_T; + + + } + + public: /** Provide the unique instance. <br>The singleton is instantiated when first used. @return FacBomContent& */ Modified: trunk/stdair/stdair/factory/FacBomStructure.hpp =================================================================== --- trunk/stdair/stdair/factory/FacBomStructure.hpp 2009-11-06 23:55:05 UTC (rev 61) +++ trunk/stdair/stdair/factory/FacBomStructure.hpp 2009-11-12 16:44:45 UTC (rev 62) @@ -89,25 +89,68 @@ ioBomParent.getChildrenList (lBomChildrenHolder_ptr); assert (lBomChildrenHolder_ptr != NULL); + bool hasInsertBeenSuccessful = + addBomObjecdToBomHolder <typename BOM_STRUCTURE_CHILD::Content_T> + (*lBomChildrenHolder_ptr, ioBomChild); + + return hasInsertBeenSuccessful; + } + + /** Add a BOM object into a dedicated BOM holder by using the + short key of the object. */ + template <typename BOM_CONTENT> + static bool addBomObjecdToBomHolder (BomChildrenHolderImp<BOM_CONTENT>& ioBomHolder, typename BOM_CONTENT::BomStructure_T& ioBomStructure) { + // Retrieve the bom structure type. + typedef typename BOM_CONTENT::BomStructure_T BOM_STRUCTURE_T; + // Define the bom holder type. + typedef BomChildrenHolderImp<BOM_CONTENT> BOM_HOLDER_T; + // Retrieve the short key - const typename BOM_STRUCTURE_CHILD::BomKey_T& lBomChildKey = - ioBomChild.getKey(); - const std::string& lBomChildKeyStr = lBomChildKey.toString(); + const typename BOM_STRUCTURE_T::BomKey_T& lBomKey = ioBomStructure.getKey(); + const std::string& lBomKeyStr = lBomKey.toString(); - // Insert the child structure object in the dedicated lists - typedef typename BOM_CHILDREN_HOLDER_T::BomChildrenList_T BOM_CHILDREN_LIST_T; + // Insert the structure object in the dedicated lists + typedef typename BOM_HOLDER_T::BomChildrenList_T BOM_LIST_T; const bool hasInsertBeenSuccessful = - lBomChildrenHolder_ptr->_bomChildrenList. - insert (typename BOM_CHILDREN_LIST_T::value_type (lBomChildKeyStr, - &ioBomChild)).second; + ioBomHolder._bomChildrenList. + insert (typename BOM_LIST_T::value_type (lBomKeyStr, + &ioBomStructure)).second; if (hasInsertBeenSuccessful == false) { return hasInsertBeenSuccessful; } - - lBomChildrenHolder_ptr->_bomChildrenOrderedList.push_back (&ioBomChild); + ioBomHolder._bomChildrenOrderedList.push_back (&ioBomStructure); + return true; } + + /** Add a BOM object into a dedicated BOM holder by using the + full key of the object. */ + template <typename BOM_CONTENT> + static bool addFullBomObjecdToBomHolder (BomChildrenHolderImp<BOM_CONTENT> ioBomHolder, typename BOM_CONTENT::BomStructure_T& ioBomStructure) { + // Retrieve the bom structure type. + typedef typename BOM_CONTENT::BomStructure_T BOM_STRUCTURE_T; + // Define the bom holder type. + typedef BomChildrenHolderImp<BOM_CONTENT> BOM_HOLDER_T; + + // Retrieve the short key + const typename BOM_STRUCTURE_T::BomKey_T& lBomKey = ioBomStructure.getKey(); + const std::string& lBomKeyStr = lBomKey.describe(); + + // Insert the structure object in the dedicated lists + typedef typename BOM_HOLDER_T::BomChildrenList_T BOM_LIST_T; + const bool hasInsertBeenSuccessful = + ioBomHolder._bomChildrenList. + insert (typename BOM_LIST_T::value_type (lBomKeyStr, + &ioBomStructure)).second; + if (hasInsertBeenSuccessful == false) { + return hasInsertBeenSuccessful; + } + + ioBomHolder._bomChildrenOrderedList.push_back (&ioBomStructure); + + return true; + } private: /** Create a bom children holder object with the given children type. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |