From: <qua...@us...> - 2009-11-13 08:52:49
|
Revision: 64 http://stdair.svn.sourceforge.net/stdair/?rev=64&view=rev Author: quannaus Date: 2009-11-13 08:52:41 +0000 (Fri, 13 Nov 2009) Log Message: ----------- [Dev] implemented the creation of direct accesses. Still have one uncomphensible bug. Modified Paths: -------------- trunk/stdair/stdair/basic/BasConst.cpp trunk/stdair/stdair/basic/BasConst_Inventory.hpp trunk/stdair/stdair/bom/FlightDate.cpp trunk/stdair/stdair/bom/FlightDate.hpp trunk/stdair/stdair/bom/FlightDateStructure.hpp trunk/stdair/stdair/bom/InventoryStructure.hpp trunk/stdair/stdair/bom/LegCabin.hpp trunk/stdair/stdair/bom/LegCabinStructure.hpp trunk/stdair/stdair/bom/LegDate.cpp trunk/stdair/stdair/bom/LegDate.hpp trunk/stdair/stdair/bom/LegDateStructure.hpp trunk/stdair/stdair/bom/SegmentCabin.hpp trunk/stdair/stdair/bom/SegmentCabinStructure.hpp trunk/stdair/stdair/bom/SegmentDate.cpp trunk/stdair/stdair/bom/SegmentDate.hpp trunk/stdair/stdair/bom/SegmentDateStructure.hpp trunk/stdair/stdair/factory/FacBomContent.hpp trunk/stdair/stdair/factory/FacBomStructure.hpp Modified: trunk/stdair/stdair/basic/BasConst.cpp =================================================================== --- trunk/stdair/stdair/basic/BasConst.cpp 2009-11-12 18:11:55 UTC (rev 63) +++ trunk/stdair/stdair/basic/BasConst.cpp 2009-11-13 08:52:41 UTC (rev 64) @@ -479,4 +479,13 @@ /** Default Bid-Price Vector. */ const BidPriceVector_T DEFAULT_BID_PRICE_VECTOR = std::vector<BidPrice_T>(); + /** Maximum number of legs linked to a single flight-date. + <br>Note that the number of derived segments is n*(n+1)/2 if n + is the number of legs. */ + const unsigned short MAXIMUM_NUMBER_OF_LEGS_IN_FLIGHT = 7; + + /** Maximum number of segments linked to a single O&D + (Origin & Destination). */ + const unsigned short MAXIMUM_NUMBER_OF_SEGMENTS_IN_OND = 3; + } Modified: trunk/stdair/stdair/basic/BasConst_Inventory.hpp =================================================================== --- trunk/stdair/stdair/basic/BasConst_Inventory.hpp 2009-11-12 18:11:55 UTC (rev 63) +++ trunk/stdair/stdair/basic/BasConst_Inventory.hpp 2009-11-13 08:52:41 UTC (rev 64) @@ -15,6 +15,15 @@ /** Default Bid-Price Vector. */ extern const BidPriceVector_T DEFAULT_BID_PRICE_VECTOR; + + /** Maximum number of legs linked to a single flight-date. + <br>Note that the number of derived segments is n*(n+1)/2 if n + is the number of legs. */ + extern const unsigned short MAXIMUM_NUMBER_OF_LEGS_IN_FLIGHT; + + /** Maximum number of segments linked to a single O&D + (Origin & Destination). */ + extern const unsigned short MAXIMUM_NUMBER_OF_SEGMENTS_IN_OND; } #endif // __STDAIR_BAS_BASCONST_INVENTORY_HPP Modified: trunk/stdair/stdair/bom/FlightDate.cpp =================================================================== --- trunk/stdair/stdair/bom/FlightDate.cpp 2009-11-12 18:11:55 UTC (rev 63) +++ trunk/stdair/stdair/bom/FlightDate.cpp 2009-11-13 08:52:41 UTC (rev 64) @@ -11,6 +11,7 @@ #include <stdair/bom/FlightDate.hpp> #include <stdair/bom/SegmentDate.hpp> #include <stdair/bom/LegDate.hpp> +#include <stdair/bom/BookingClass.hpp> #include <stdair/bom/BomList.hpp> #include <stdair/bom/BomMap.hpp> @@ -74,6 +75,21 @@ LegDateMap_T FlightDate::getLegDateMap () const { return _flightDateStructure.getSecondChildrenList(); } - + + // ////////////////////////////////////////////////////////////////////// + LegDate* FlightDate::getLegDate (const LegDateKey_T& iKey) const { + return _flightDateStructure.getSecondContentChild (iKey); + } + + // ////////////////////////////////////////////////////////////////////// + SegmentDate* FlightDate::getSegmentDate (const SegmentDateKey_T& iKey) const { + return _flightDateStructure.getContentChild (iKey); + } + + // ////////////////////////////////////////////////////////////////////// + BookingClass* FlightDate:: + getBookingClass (const BookingClassKey_T& iKey) const { + return _flightDateStructure.getBookingClass (iKey); + } } Modified: trunk/stdair/stdair/bom/FlightDate.hpp =================================================================== --- trunk/stdair/stdair/bom/FlightDate.hpp 2009-11-12 18:11:55 UTC (rev 63) +++ trunk/stdair/stdair/bom/FlightDate.hpp 2009-11-13 08:52:41 UTC (rev 64) @@ -62,31 +62,25 @@ /** Get a LegDateMap_T for iteration methods. */ LegDateMap_T getLegDateMap () const; - - /** Get the list of class structures */ - // BookingClassMap_T getClassList() const { -// return _bookingClassList; -// } - + /** Get the airline code (from the parent class). */ // const AirlineCode_T& getAirlineCode() const; -// /** Retrieve, if existing, the LegDate corresponding to the -// given board point (LegDate key). -// <br>If not existing, return the NULL pointer. */ -// LegDate* getLegDate (const AirportCode_T& iBoardPoint) const; + /** Retrieve, if existing, the LegDate corresponding to the + given LegDate key. + <br>If not existing, return the NULL pointer. */ + LegDate* getLegDate (const LegDateKey_T&) const; -// /** Retrieve, if existing, the SegmentDate corresponding to the -// given (board point, off point) pair (SegmentDate key). -// <br>If not existing, return the NULL pointer. */ -// SegmentDate* getSegmentDate (const AirportCode_T& iBoardPoint, -// const AirportCode_T& iOffPoint) const; + /** Retrieve, if existing, the SegmentDate corresponding to the + given SegmentDate key. + <br>If not existing, return the NULL pointer. */ + SegmentDate* getSegmentDate (const SegmentDateKey_T&) const; -// /** Return the BookingClass corresponding to a given key. -// <br>When no BookingClass, matching the given key, can be found, -// the NULL pointer is returned. -// <br>Otherwise, a pointer is returned on the BookingClass object. */ -// BookingClass* getBookingClass (const std::string&) const; + /** Return the BookingClass corresponding to a given key. + <br>When no BookingClass, matching the given key, can be found, + the NULL pointer is returned. + <br>Otherwise, a pointer is returned on the BookingClass object. */ + BookingClass* getBookingClass (const BookingClassKey_T&) const; // /** Retrieve, if existing, theOnD corresponding to the // given OnDKey. Modified: trunk/stdair/stdair/bom/FlightDateStructure.hpp =================================================================== --- trunk/stdair/stdair/bom/FlightDateStructure.hpp 2009-11-12 18:11:55 UTC (rev 63) +++ trunk/stdair/stdair/bom/FlightDateStructure.hpp 2009-11-13 08:52:41 UTC (rev 64) @@ -11,8 +11,14 @@ #include <stdair/bom/BomContentDummy.hpp> #include <stdair/bom/SegmentDateStructure.hpp> #include <stdair/bom/LegDateStructure.hpp> +#include <stdair/bom/SegmentDateKey.hpp> +#include <stdair/bom/LegDateKey.hpp> +#include <stdair/bom/BookingClassKey.hpp> namespace stdair { + // Forward declarations. + template <typename BOM> struct BomMap_T; + /** Wrapper class aimed at holding the actual content, modeled by an external specific FlightDate class (for instance, in the AIRSCHED library). */ @@ -30,6 +36,14 @@ /** Definition allowing to retrieve the associated BOM key type. */ typedef typename BOM_CONTENT::BomKey_T BomKey_T; + /** Definition allowing to retrieve the key type of the + ContentChild_T. */ + typedef SegmentDateKey_T ChildKey_T; + + /** Definition allowing to retrieve the key type of the + SecondContentChild_T. */ + typedef LegDateKey_T SecondChildKey_T; + /** Definition allowing to retrieve the associated parent BOM structure type. */ typedef typename BOM_CONTENT::Parent_T::BomStructure_T ParentBomStructure_T; @@ -38,9 +52,15 @@ BOM_CONTENT. */ typedef typename BOM_CONTENT::ContentChild_T ContentChild_T; + /** Define the map of ContentChild_T. */ + typedef BomMap_T<ContentChild_T> ChildrenMap_T; + /** Definition allowing to retrieve the second children type of the BOM_CONTENT. */ typedef typename BOM_CONTENT::SecondContentChild_T SecondContentChild_T; + + /** Define the map of SecondContentChild_T. */ + typedef BomMap_T<SecondContentChild_T> SecondChildrenMap_T; /** Definition allowing to retrieve the associated children type. */ typedef boost::mpl::vector<SegmentDateStructure<ContentChild_T>, @@ -55,8 +75,14 @@ /** 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; + /** Define the children booking class type. */ + typedef typename BOM_CONTENT::BookingClassContent_T BookingClass_T; + + /** Define the children booking class holder type. */ + typedef BomChildrenHolderImp<BookingClass_T> BookingClassHolder_T; + + /** Define the map of ContentChild_T. */ + typedef BomMap_T<BookingClass_T> BookingClassMap_T; public: // /////////// Getters ///////////// @@ -79,14 +105,22 @@ /** Get the list of segment-dates. */ const ChildrenBomHolder_T& getChildrenList() const { + assert (_childrenList != NULL); return *_childrenList; } /** Get the list of leg-dates. */ const SecondChildrenBomHolder_T& getSecondChildrenList() const { + assert (_secondChildrenList != NULL); return *_secondChildrenList; } + /** Get the holder of booking classes. */ + BookingClassHolder_T& getBookingClassHolder() const { + assert (_bookingClassHolder); + return *_bookingClassHolder; + } + /** Get the list of segment-dates. */ void getChildrenList (ChildrenBomHolder_T*& ioChildrenList) { ioChildrenList = _childrenList; @@ -96,7 +130,67 @@ void getChildrenList (SecondChildrenBomHolder_T*& ioChildrenList) { ioChildrenList = _secondChildrenList; } + + /** Retrieve, if existing, the segment-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; + } + /** Retrieve, if existing, the leg-date corresponding to the + given key. + <br>If not exissting, return the NULL pointer. */ + SecondContentChild_T* getSecondContentChild (const SecondChildKey_T& iKey) const { + SecondContentChild_T* oContentChild_ptr = NULL; + + SecondChildrenMap_T lChildrenMap (getSecondChildrenList()); + const MapKey_T lMapKey = iKey.toString(); + + typename SecondChildrenMap_T::iterator itContentChild = + lChildrenMap.find (lMapKey); + + if (itContentChild != lChildrenMap.end()) { + oContentChild_ptr = itContentChild->second; + assert (oContentChild_ptr != NULL); + } + + return oContentChild_ptr; + } + + /** Retrieve, if existing, the booking class corresponding to the + given key. + <br>If not exissting, return the NULL pointer. */ + BookingClass_T* getBookingClass (const BookingClassKey_T& iKey) const { + BookingClass_T* oBookingClass_ptr = NULL; + + BookingClassMap_T lBookingClassMap (getBookingClassHolder()); + const MapKey_T lMapKey = iKey.toString(); + + typename BookingClassMap_T::iterator itBookingClass = + lBookingClassMap.find (lMapKey); + + if (itBookingClass != lBookingClassMap.end()) { + oBookingClass_ptr = itBookingClass->second; + assert (oBookingClass_ptr != NULL); + } + + return oBookingClass_ptr; + } + private: // /////////// Setters ///////////// /** Set the (parent) FlightDate object. */ Modified: trunk/stdair/stdair/bom/InventoryStructure.hpp =================================================================== --- trunk/stdair/stdair/bom/InventoryStructure.hpp 2009-11-12 18:11:55 UTC (rev 63) +++ trunk/stdair/stdair/bom/InventoryStructure.hpp 2009-11-13 08:52:41 UTC (rev 64) @@ -60,8 +60,14 @@ /** Define the children bom holder type. */ typedef BomChildrenHolderImp<ContentChild_T> ChildrenBomHolder_T; - /** Define the children booking class holder type. */ - typedef BomChildrenHolderImp<typename BOM_CONTENT::BookingClassContent_T> BookingClassHolder_T; + /** Define the children booking class type. */ + typedef typename BOM_CONTENT::BookingClassContent_T BookingClass_T; + + /** Define the children booking class holder type. */ + typedef BomChildrenHolderImp<BookingClass_T> BookingClassHolder_T; + + /** Define the map of ContentChild_T. */ + typedef BomMap_T<BookingClass_T> BookingClassMap_T; public: // /////////// Getters ///////////// @@ -93,6 +99,12 @@ ioChildrenList = _childrenList; } + /** Get the holder of booking classes. */ + BookingClassHolder_T& getBookingClassHolder() const { + assert (_bookingClassHolder); + return *_bookingClassHolder; + } + /** Retrieve, if existing, the flight-date corresponding to the given key. <br>If not exissting, return the NULL pointer. */ Modified: trunk/stdair/stdair/bom/LegCabin.hpp =================================================================== --- trunk/stdair/stdair/bom/LegCabin.hpp 2009-11-12 18:11:55 UTC (rev 63) +++ trunk/stdair/stdair/bom/LegCabin.hpp 2009-11-13 08:52:41 UTC (rev 64) @@ -13,6 +13,7 @@ namespace stdair { // Forward declarations class FacBomContent; + class SegmentCabin; struct LegCabinKey_T; /** Class representing the actual functional/business content for a @@ -31,6 +32,9 @@ /** Definition allowing to retrieve the associated BOM key type. */ typedef LegCabinKey_T BomKey_T; + + /** Definition allowing to retrieve the specific SegmentCabin type. */ + typedef SegmentCabin SegmentCabinContent_T; public: // // ////// Getters from the parent class /////// Modified: trunk/stdair/stdair/bom/LegCabinStructure.hpp =================================================================== --- trunk/stdair/stdair/bom/LegCabinStructure.hpp 2009-11-12 18:11:55 UTC (rev 63) +++ trunk/stdair/stdair/bom/LegCabinStructure.hpp 2009-11-13 08:52:41 UTC (rev 64) @@ -40,6 +40,9 @@ /** Definition allowing to retrieve the default children bom holder type. */ typedef BomChildrenHolderImp<BomContentDummy> DefaultChildrenBomHolder_T; + /** Define the associated segment-cabin holder type. */ + typedef BomChildrenHolderImp<typename BOM_CONTENT::SegmentCabinContent_T> SegmentCabinHolder_T; + public: // /////////// Getters ///////////// /** Get the (parent) LegDateStructure object. */ @@ -66,6 +69,11 @@ /** Default children list setter. */ void setChildrenList (DefaultChildrenBomHolder_T&) { } + /** Set the segment-cabin holder. */ + void setSegmentCabinHolder (SegmentCabinHolder_T& ioSegmentCabinHolder) { + _segmentCabinHolder = &ioSegmentCabinHolder; + } + public: // /////////// Display support methods ///////// /** Dump a Business Object into an output stream. @@ -93,7 +101,8 @@ /** Constructors are private so as to force the usage of the Factory layer. */ /** Default constructors. */ - LegCabinStructure () : _parent (NULL), _content (NULL) { } + LegCabinStructure () : _parent (NULL), _content (NULL), + _segmentCabinHolder (NULL) { } LegCabinStructure (const LegCabinStructure&); /** Destructor. */ @@ -106,6 +115,9 @@ /** The actual functional (Business Object) content. */ BOM_CONTENT* _content; + + /** Holder of the associated segment-cabins. */ + SegmentCabinHolder_T* _segmentCabinHolder; }; } Modified: trunk/stdair/stdair/bom/LegDate.cpp =================================================================== --- trunk/stdair/stdair/bom/LegDate.cpp 2009-11-12 18:11:55 UTC (rev 63) +++ trunk/stdair/stdair/bom/LegDate.cpp 2009-11-13 08:52:41 UTC (rev 64) @@ -21,16 +21,16 @@ LegDate::~LegDate () { } - // ////////////////////////////////////////////////////////////////////// + // //////////////////////////////////////////////////////////////////// void LegDate::toStream (std::ostream& ioOut) const { ioOut << toString() << std::endl; } - // ////////////////////////////////////////////////////////////////////// + // //////////////////////////////////////////////////////////////////// void LegDate::fromStream (std::istream& ioIn) { } - // ////////////////////////////////////////////////////////////////////// + // //////////////////////////////////////////////////////////////////// std::string LegDate::toString() const { std::ostringstream oStr; @@ -43,25 +43,30 @@ return oStr.str(); } - // ////////////////////////////////////////////////////////////////////// + // //////////////////////////////////////////////////////////////////// const std::string LegDate::describeKey() const { return _legDateStructure.describeKey(); } - // ////////////////////////////////////////////////////////////////////// + // //////////////////////////////////////////////////////////////////// const std::string LegDate::describeShortKey() const { return _legDateStructure.describeShortKey(); } - // ////////////////////////////////////////////////////////////////////// + // //////////////////////////////////////////////////////////////////// LegCabinList_T LegDate::getLegCabinList () const { return _legDateStructure.getChildrenList(); } - // ////////////////////////////////////////////////////////////////////// + // //////////////////////////////////////////////////////////////////// LegCabinMap_T LegDate::getLegCabinMap () const { return _legDateStructure.getChildrenList(); } + + // //////////////////////////////////////////////////////////////////// + LegCabin* LegDate::getLegCabin (const LegCabinKey_T& iKey) const { + return _legDateStructure.getContentChild (iKey); + } } Modified: trunk/stdair/stdair/bom/LegDate.hpp =================================================================== --- trunk/stdair/stdair/bom/LegDate.hpp 2009-11-12 18:11:55 UTC (rev 63) +++ trunk/stdair/stdair/bom/LegDate.hpp 2009-11-13 08:52:41 UTC (rev 64) @@ -15,6 +15,7 @@ // Forward declarations class FacBomContent; struct LegDateKey_T; + struct LegCabinKey_T; /** Class representing the actual functional/business content for a leg-date. */ @@ -36,25 +37,28 @@ /** Definition allowing to retrieve the associated BOM content child type. */ typedef LegCabin ContentChild_T; + + /** Definition allowing to retrieve the specific SegmentDate type. */ + typedef SegmentDate SegmentDateContent_T; public: // /////////// Getters //////////// -// /** Get the airline code (from the parent class). */ -// const AirlineCode_T& getAirlineCode() const; - -// /** Get the flight number (from the parent class). */ -// const FlightNumber_T& getFlightNumber() const; - -// /** Get the flight-date (from the parent class). */ -// const Date_T& getFlightDateDate() const; - -// /** Retrieve, if existing, the LegCabin corresponding to the -// given cabin code (LegCabin key). -// <br>If not existing, return the NULL pointer. */ -// LegCabin* getLegCabin (const CabinCode_T& iCabinCode) const; + // /** Get the airline code (from the parent class). */ + // const AirlineCode_T& getAirlineCode() const; - // // ///////// Counting methods ////////// -// /** Update the counters of booked seats. */ + // /** Get the flight number (from the parent class). */ + // const FlightNumber_T& getFlightNumber() const; + + // /** Get the flight-date (from the parent class). */ + // const Date_T& getFlightDateDate() const; + + /** Retrieve, if existing, the LegCabin corresponding to the + given LegCabin key. + <br>If not existing, return the NULL pointer. */ + LegCabin* getLegCabin (const LegCabinKey_T&) const; + + // // ///////// Counting methods ////////// + // /** Update the counters of booked seats. */ // void updateBookingsAndSeatCounters(); // /** Update the values of commited spaces. */ Modified: trunk/stdair/stdair/bom/LegDateStructure.hpp =================================================================== --- trunk/stdair/stdair/bom/LegDateStructure.hpp 2009-11-12 18:11:55 UTC (rev 63) +++ trunk/stdair/stdair/bom/LegDateStructure.hpp 2009-11-13 08:52:41 UTC (rev 64) @@ -10,8 +10,12 @@ #include <stdair/bom/BomStructureDummy.hpp> #include <stdair/bom/BomContentDummy.hpp> #include <stdair/bom/LegCabinStructure.hpp> +#include <stdair/bom/LegCabinKey.hpp> namespace stdair { + // Forward declarations. + template <typename BOM> struct BomMap_T; + /** Wrapper class aimed at holding the actual content, modeled by an external specific LegDate class (for instance, in the AIRSCHED library). */ @@ -36,6 +40,12 @@ /** Definition allowing to retrieve the children type of the BOM_CONTENT. */ typedef typename BOM_CONTENT::ContentChild_T ContentChild_T; + + /** Definition allowing to retrieve the child key type. */ + typedef LegCabinKey_T ChildKey_T; + + /** Define the map of ContentChild_T. */ + typedef BomMap_T<ContentChild_T> ChildrenMap_T; /** Definition allowing to retrieve the associated children type. */ typedef boost::mpl::vector <LegCabinStructure<ContentChild_T>, @@ -47,6 +57,9 @@ /** Definition allowing to retrive the children bom holder type. */ typedef BomChildrenHolderImp<ContentChild_T> ChildrenBomHolder_T; + /** Define the associated segment-date holder type.*/ + typedef BomChildrenHolderImp<typename BOM_CONTENT::SegmentDateContent_T> SegmentDateHolder_T; + public: // /////////// Getters ///////////// /** Get the (parent) FlightDateStructure object. */ @@ -72,6 +85,26 @@ void getChildrenList (ChildrenBomHolder_T*& ioChildrenList) { ioChildrenList = _childrenList; } + + /** Retrieve, if existing, the leg-cabin 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 ///////////// @@ -87,6 +120,11 @@ void setChildrenList (ChildrenBomHolder_T& ioChildrenList) { _childrenList = &ioChildrenList; } + + /** Set the segment-date holder. */ + void setSegmentDateHolder (SegmentDateHolder_T& ioSegmentDateHolder) { + _segmentDateHolder = &ioSegmentDateHolder; + } public: // /////////// Display support methods ///////// @@ -116,7 +154,7 @@ layer. */ /** Default constructors. */ LegDateStructure () : _parent (NULL), _content (NULL), - _childrenList (NULL) { } + _childrenList (NULL), _segmentDateHolder (NULL) { } LegDateStructure (const LegDateStructure&); /** Destructor. */ @@ -132,6 +170,9 @@ /** List of leg-cabins. */ ChildrenBomHolder_T* _childrenList; + + /** Holder of associated segment-dates. */ + SegmentDateHolder_T* _segmentDateHolder; }; } Modified: trunk/stdair/stdair/bom/SegmentCabin.hpp =================================================================== --- trunk/stdair/stdair/bom/SegmentCabin.hpp 2009-11-12 18:11:55 UTC (rev 63) +++ trunk/stdair/stdair/bom/SegmentCabin.hpp 2009-11-13 08:52:41 UTC (rev 64) @@ -14,6 +14,7 @@ namespace stdair { // Forward declarations class FacBomContent; + class LegCabin; struct SegmentCabinKey_T; /** Class representing the actual functional/business content for a @@ -36,6 +37,9 @@ /** Definition allowing to retrieve the associated BOM content child type. */ typedef BookingClass ContentChild_T; + + /** Definition allowing to retrieve the specific LegCabin type. */ + typedef LegCabin LegCabinContent_T; public: // /////////// Getters ///////////// Modified: trunk/stdair/stdair/bom/SegmentCabinStructure.hpp =================================================================== --- trunk/stdair/stdair/bom/SegmentCabinStructure.hpp 2009-11-12 18:11:55 UTC (rev 63) +++ trunk/stdair/stdair/bom/SegmentCabinStructure.hpp 2009-11-13 08:52:41 UTC (rev 64) @@ -47,6 +47,9 @@ /** Definition allowing to retrive the children bom holder type. */ typedef BomChildrenHolderImp<ContentChild_T> ChildrenBomHolder_T; + /** Define the associated leg-cabin holder type. */ + typedef BomChildrenHolderImp<typename BOM_CONTENT::LegCabinContent_T> LegCabinHolder_T; + public: // /////////// Getters ///////////// /** Get the (parent) SegmentDateStructure object. */ @@ -55,7 +58,10 @@ } /** Get the (parent) SegmentDateStructure object. */ - ParentBomStructure_T& getSegmentDateStructure() const; + ParentBomStructure_T& getSegmentDateStructure() const { + assert (_parent != NULL); + return *_parent; + } /** Get the segment-date key. */ const BomKey_T& getKey() const { @@ -87,6 +93,11 @@ void setChildrenList (ChildrenBomHolder_T& ioChildrenList) { _childrenList = &ioChildrenList; } + + /** Set the leg-cabin holder. */ + void setLegCabinHolder (LegCabinHolder_T& ioLegCabinHolder) { + _legCabinHolder = &ioLegCabinHolder; + } public: // /////////// Display support methods ///////// @@ -116,7 +127,7 @@ layer. */ /** Default constructors. */ SegmentCabinStructure () : _parent (NULL), _content (NULL), - _childrenList (NULL) { } + _childrenList (NULL), _legCabinHolder (NULL) { } SegmentCabinStructure (const SegmentCabinStructure&); /** Destructor. */ @@ -132,6 +143,9 @@ /** List of segment-cabins. */ ChildrenBomHolder_T* _childrenList; + + /** Holder of associated leg-cabins. */ + LegCabinHolder_T* _legCabinHolder; }; } Modified: trunk/stdair/stdair/bom/SegmentDate.cpp =================================================================== --- trunk/stdair/stdair/bom/SegmentDate.cpp 2009-11-12 18:11:55 UTC (rev 63) +++ trunk/stdair/stdair/bom/SegmentDate.cpp 2009-11-13 08:52:41 UTC (rev 64) @@ -7,6 +7,7 @@ #include <stdair/bom/SegmentDateStructure.hpp> #include <stdair/bom/SegmentDate.hpp> #include <stdair/bom/SegmentCabin.hpp> +#include <stdair/bom/LegDate.hpp> #include <stdair/bom/BomList.hpp> #include <stdair/bom/BomMap.hpp> @@ -63,6 +64,11 @@ SegmentCabinMap_T SegmentDate::getSegmentCabinMap () const { return _segmentDateStructure.getChildrenList(); } + + // ////////////////////////////////////////////////////////////////////// + LegDateList_T SegmentDate::getLegDateList () const { + return _segmentDateStructure.getLegDateHolder(); + } // ///////// /////////////////////////////////////////////////////////////// // bool SegmentDate:: Modified: trunk/stdair/stdair/bom/SegmentDate.hpp =================================================================== --- trunk/stdair/stdair/bom/SegmentDate.hpp 2009-11-12 18:11:55 UTC (rev 63) +++ trunk/stdair/stdair/bom/SegmentDate.hpp 2009-11-13 08:52:41 UTC (rev 64) @@ -8,6 +8,7 @@ #include <stdair/bom/FlightDate.hpp> #include <stdair/bom/SegmentDateStructure.hpp> #include <stdair/bom/SegmentDateTypes.hpp> +#include <stdair/bom/LegDateTypes.hpp> #include <stdair/bom/SegmentCabinTypes.hpp> #include <stdair/bom/SegmentDateContent.hpp> @@ -36,6 +37,9 @@ /** Definition allowing to retrieve the associated BOM content child type. */ typedef SegmentCabin ContentChild_T; + + /** Definition allowing to retrieve the specific LegDate type. */ + typedef LegDate LegDateContent_T; public: // /////////// Getters ///////////// @@ -45,6 +49,9 @@ /** Get a SegmentCabinMap_T for iteration methods. */ SegmentCabinMap_T getSegmentCabinMap () const; + /** Get a LegDateList_T for iteration methods. */ + LegDateList_T getLegDateList () const; + // /** Get the airline code (from the parent class). */ // const AirlineCode_T& getAirlineCode() const; Modified: trunk/stdair/stdair/bom/SegmentDateStructure.hpp =================================================================== --- trunk/stdair/stdair/bom/SegmentDateStructure.hpp 2009-11-12 18:11:55 UTC (rev 63) +++ trunk/stdair/stdair/bom/SegmentDateStructure.hpp 2009-11-13 08:52:41 UTC (rev 64) @@ -47,6 +47,9 @@ /** Definition allowing to retrive the children bom holder type. */ typedef BomChildrenHolderImp<ContentChild_T> ChildrenBomHolder_T; + /** Define the associated leg-date holder type. */ + typedef BomChildrenHolderImp<typename BOM_CONTENT::LegDateContent_T> LegDateHolder_T; + public: // /////////// Getters ///////////// /** Get the (parent) FlightDateStructure object. */ @@ -55,7 +58,10 @@ } /** Get the (parent) FlightDateStructure object. */ - ParentBomStructure_T& getFlightDateStructure() const; + ParentBomStructure_T& getFlightDateStructure() const { + assert (_parent != NULL); + return *_parent; + } /** Get the segment-date key. */ const BomKey_T& getKey() const { @@ -65,9 +71,16 @@ /** Get the list of segment-cabins. */ const ChildrenBomHolder_T& getChildrenList() const { + assert (_childrenList != NULL); return *_childrenList; } + /** Get the list of leg-dates. */ + const LegDateHolder_T& getLegDateHolder() const { + assert (_legDateHolder != NULL); + return *_legDateHolder; + } + /** Get the list of segment-cabins. */ void getChildrenList (ChildrenBomHolder_T*& ioChildrenList) { ioChildrenList = _childrenList; @@ -87,6 +100,11 @@ void setChildrenList (ChildrenBomHolder_T& ioChildrenList) { _childrenList = &ioChildrenList; } + + /** Set the leg-date holder.*/ + void setLegDateHolder (LegDateHolder_T& ioLegDateHolder) { + _legDateHolder = &ioLegDateHolder; + } public: // /////////// Display support methods ///////// @@ -116,7 +134,7 @@ layer. */ /** Default constructors. */ SegmentDateStructure () : _parent (NULL), _content (NULL), - _childrenList (NULL) { } + _childrenList (NULL), _legDateHolder (NULL) { } SegmentDateStructure (const SegmentDateStructure&); /** Destructor. */ @@ -132,6 +150,9 @@ /** List of segment-cabins. */ ChildrenBomHolder_T* _childrenList; + + /** Holder of associated leg-dates. */ + LegDateHolder_T* _legDateHolder; }; } Modified: trunk/stdair/stdair/factory/FacBomContent.hpp =================================================================== --- trunk/stdair/stdair/factory/FacBomContent.hpp 2009-11-12 18:11:55 UTC (rev 63) +++ trunk/stdair/stdair/factory/FacBomContent.hpp 2009-11-13 08:52:41 UTC (rev 64) @@ -10,6 +10,7 @@ #include <boost/mpl/vector.hpp> // STDAIR #include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/BasConst_Inventory.hpp> #include <stdair/bom/BomStructure.hpp> #include <stdair/factory/FacBomStructure.hpp> @@ -137,7 +138,7 @@ private: /** Create a holder of all booking classes within the given inventory. */ template <typename INVENTORY> - static void createDirectAccessesWithinInventory (INVENTORY& ioInventory){ + static void createDirectAccessesWithinInventory(const INVENTORY& iInventory){ // Retrieve the flight-date type. typedef typename INVENTORY::ContentChild_T FLIGHT_DATE_T; // Define the list of flight-dates. @@ -150,12 +151,12 @@ // Initialize the booking class holder within the inventory. BOOKING_CLASS_HOLDER_T& lBookingClassHolder = FacBomStructure::instance().createBomHolder<BOOKING_CLASS_T> (); - ioInventory._inventoryStructure.setBookingClassHolder(lBookingClassHolder); + iInventory._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(); + const FLIGHT_DATE_LIST_T lFlightDateList = iInventory.getFlightDateList(); for (typename FLIGHT_DATE_LIST_T::iterator itFlightDate = lFlightDateList.begin(); itFlightDate != lFlightDateList.end(); ++itFlightDate) { @@ -167,27 +168,251 @@ /** 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) { + static void createDirectAccessesWithinFlightDate (const FLIGHT_DATE& iFlightDate) { // 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); - + + // Initialize the booking class holder within the flight-date. + BOOKING_CLASS_HOLDER_T& lBookingClassHolder = + FacBomStructure::instance().createBomHolder<BOOKING_CLASS_T> (); + iFlightDate._flightDateStructure.setBookingClassHolder(lBookingClassHolder); + // Retrieve the leg-date type. + typedef typename FLIGHT_DATE::SecondContentChild_T LEG_DATE_T; + // Define the holder of leg-dates. + typedef BomChildrenHolderImp<LEG_DATE_T> LEG_DATE_HOLDER_T; + // Retrieve the leg-date key type. + typedef typename LEG_DATE_T::BomKey_T LEG_DATE_KEY_T; // 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; + SEGMENT_DATE_LIST_T lSegmentDateList = iFlightDate.getSegmentDateList(); + for (typename SEGMENT_DATE_LIST_T::iterator itSegmentDate = + lSegmentDateList.begin(); + itSegmentDate != lSegmentDateList.end(); ++itSegmentDate) { + SEGMENT_DATE_T& lCurrentSegmentDate = *itSegmentDate; - + // Initialize the leg-date holder within the segment-date. + LEG_DATE_HOLDER_T& lLegDateHolder = + FacBomStructure::instance().createBomHolder<LEG_DATE_T> (); + lCurrentSegmentDate._segmentDateStructure.setLegDateHolder(lLegDateHolder); + + const AirportCode_T& lBoardPoint = + lCurrentSegmentDate.getBoardPoint(); + AirportCode_T currentBoardPoint = lBoardPoint; + const AirportCode_T& lOffPoint = lCurrentSegmentDate.getOffPoint(); + AirportCode_T currentOffPoint = lBoardPoint; + + // Add a sanity check so as to ensure that the loop stops. If + // there are more than MAXIMUM_NUMBER_OF_LEGS legs, there is + // an issue somewhere in the code (not in the parser, as the + // segments are derived from the legs thanks to the + // FlightPeriodStruct::buildSegments() method). + unsigned short i = 1; + while (currentOffPoint != lOffPoint + && i <= MAXIMUM_NUMBER_OF_LEGS_IN_FLIGHT) { + // Retrieve the (unique) LegDate getting that Board Point + const LEG_DATE_KEY_T lLegDateKey (currentOffPoint); + LEG_DATE_T* lLegDate_ptr = iFlightDate.getLegDate (lLegDateKey); + assert (lLegDate_ptr != NULL); + + // Link the SegmentDate and LegDate together + initLinkSegmentDateWithLegDate<SEGMENT_DATE_T> (lCurrentSegmentDate, *lLegDate_ptr); + + // Prepare the next iteration + currentBoardPoint = lLegDate_ptr->getOffPoint(); + currentOffPoint = lLegDate_ptr->getOffPoint(); + ++i; + } + assert (i <= MAXIMUM_NUMBER_OF_LEGS_IN_FLIGHT); + + // Create the routing for the leg- and segment-cabins. + // At the same time, set the SegmentDate attributes derived from + // its routing legs (e.g., board and off dates). + createDirectAccessesWithinSegmentDate (lCurrentSegmentDate); + } } + + /** Create the direct acceeses within the given segment-date, and, at the + same time, build the class holder for the corresponding flight-date + and inventory. */ + template <typename SEGMENT_DATE> + static void createDirectAccessesWithinSegmentDate (const SEGMENT_DATE& iSegmentDate) { + // Retrieve the segment-cabin type. + typedef typename SEGMENT_DATE::ContentChild_T SEGMENT_CABIN_T; + // Define the list of sement-cabin. + typedef BomList_T<SEGMENT_CABIN_T> SEGMENT_CABIN_LIST_T; + // Retrieve the leg-date type. + typedef typename SEGMENT_DATE::LegDateContent_T LEG_DATE_T; + // Define the list of leg-date. + typedef BomList_T<LEG_DATE_T> LEG_DATE_LIST_T; + // Retrieve the leg-cabin type. + typedef typename LEG_DATE_T::ContentChild_T LEG_CABIN_T; + // Define the leg-cabin holder. + typedef BomChildrenHolderImp<LEG_CABIN_T> LEG_CABIN_HOLDER_T; + // Retrieve the type of leg-cabin key. + typedef typename LEG_CABIN_T::BomKey_T LEG_CABIN_KEY_T; + + // Browse the segment-cabin list. + const SEGMENT_CABIN_LIST_T lSegmentCabinList = + iSegmentDate.getSegmentCabinList(); + for (typename SEGMENT_CABIN_LIST_T::iterator itSegmentCabin = + lSegmentCabinList.begin(); + itSegmentCabin != lSegmentCabinList.end(); ++itSegmentCabin) { + SEGMENT_CABIN_T& lSegmentCabin = *itSegmentCabin; + + // Initialize the leg-cabin holder for the current segment-cabin. + LEG_CABIN_HOLDER_T& lLegCabinHolder = FacBomStructure:: + instance().createBomHolder<LEG_CABIN_T> (); + lSegmentCabin._segmentCabinStructure.setLegCabinHolder (lLegCabinHolder); + + // Iterate on the routing legs + const LEG_DATE_LIST_T& lLegDateList = iSegmentDate.getLegDateList(); + for (typename LEG_DATE_LIST_T::iterator itLegDate = + lLegDateList.begin(); + itLegDate != lLegDateList.end(); ++itLegDate) { + const LEG_DATE_T& lLegDate = *itLegDate; + + // Retrieve the LegCabin getting the same class of service + // (cabin code) as the SegmentCabin. + const CabinCode_T& lCabinCode = lSegmentCabin.getCabinCode(); + const LEG_CABIN_KEY_T lLegCabinKey (lCabinCode); + + LEG_CABIN_T* lLegCabin_ptr = lLegDate.getLegCabin (lLegCabinKey); + + // In fact, the following assertion corresponds to the assumption + // that the cabins are the same on the segments AND on their routing + // legs. For some actual airline, that is not always true. If needed, + // we may implement the cabin mapping feature. + /* + if (lLegCabin_ptr == NULL) { + STDAIR_LOG_ERROR ("The cabin of the Segment: " + << lSegmentCabin._key.describe() + << " can not be found on the routing Legs." + << " The mapping of Segment-Cabins onto " + << "distinct Leg-Cabins is a feature not " + << "supported by LATUS."); + } + */ + assert (lLegCabin_ptr != NULL); + + // Link the SegmentCabin and LegCabin together + initLinkSegmentCabinWithLegCabin<SEGMENT_CABIN_T> (lSegmentCabin, *lLegCabin_ptr); + + // Build the class holders for the corresponding flight-date and + // inventory. + buildBookingClassHolders (lSegmentCabin); + } + } + } + + /** Build the booking class holders of the corresponding inventory + and flight-date of the given segment-cabin. */ + template <typename SEGMENT_CABIN> + static void buildBookingClassHolders (const SEGMENT_CABIN& iSegmentCabin) { + // Retrieve the flight-date structure type. + typedef typename SEGMENT_CABIN::Parent_T::Parent_T::BomStructure_T FLIGHT_DATE_STRUCTURE_T; + // Retrieve the booking class type. + typedef typename SEGMENT_CABIN::ContentChild_T BOOKING_CLASS_T; + + FLIGHT_DATE_STRUCTURE_T& lFDStructure = + iSegmentCabin._segmentCabinStructure.getSegmentDateStructure(). + getFlightDateStructure(); + + // Define the holder of booking classes. + typedef BomChildrenHolderImp<BOOKING_CLASS_T> BOOKING_CLASS_HOLDER_T; + + // Retrieve the booking class holders of the flight-date and the + // inventory. + BOOKING_CLASS_HOLDER_T& lFDBookingClassHolder = + lFDStructure.getBookingClassHolder(); + BOOKING_CLASS_HOLDER_T& lInvBookingClassHolder = + lFDStructure.getInventoryStructure().getBookingClassHolder(); + + // Define the list of booking classes. + typedef BomList_T<BOOKING_CLASS_T> BOOKING_CLASS_LIST_T; + BOOKING_CLASS_LIST_T lBookingClassList=iSegmentCabin.getBookingClassList(); + for (typename BOOKING_CLASS_LIST_T::iterator itBookingClass = + lBookingClassList.begin(); + itBookingClass != lBookingClassList.end(); ++itBookingClass) { + BOOKING_CLASS_T& lBookingClass = *itBookingClass; + + // bool addingSucceeded = FacBomStructure:: +// addFullBomObjecdToBomHolder<BOOKING_CLASS_T> (lFDBookingClassHolder, +// lBookingClass); +// assert (addingSucceeded == true); +// addingSucceeded = FacBomStructure:: +// addFullBomObjecdToBomHolder<BOOKING_CLASS_T> (lInvBookingClassHolder, +// lBookingClass); +// assert (addingSucceeded == true); + } + } + /** Build the link between the given segment-date and the given leg-date. */ + template <typename SEGMENT_DATE> + static void initLinkSegmentDateWithLegDate (SEGMENT_DATE& ioSegmentDate, + typename SEGMENT_DATE::LegDateContent_T& ioLegDate) { + // Retrieve the leg-date type. + typedef typename SEGMENT_DATE::LegDateContent_T LEG_DATE_T; + // Define the segment-date holder type. + typedef BomChildrenHolderImp<SEGMENT_DATE> SEGMENT_DATE_HOLDER_T; + // Define the leg-date holder type. + typedef BomChildrenHolderImp<LEG_DATE_T> LEG_DATE_HOLDER_T; + + LEG_DATE_HOLDER_T* lLegDateHolder_ptr = + ioSegmentDate._segmentDateStructure._legDateHolder; + assert (lLegDateHolder_ptr != NULL); + + // bool addingSucceeded = FacBomStructure:: +// addBomObjecdToBomHolder<LEG_DATE_T> (*lLegDateHolder_ptr, ioLegDate); +// assert (addingSucceeded == true); + + SEGMENT_DATE_HOLDER_T* lSegmentDateHolder_ptr = + ioLegDate._legDateStructure._segmentDateHolder; + if (lSegmentDateHolder_ptr == NULL) { + lSegmentDateHolder_ptr = &FacBomStructure:: + instance().createBomHolder<SEGMENT_DATE> (); + } + // addingSucceeded = FacBomStructure:: +// addBomObjecdToBomHolder<SEGMENT_DATE> (*lSegmentDateHolder_ptr, +// ioSegmentDate); +// assert (addingSucceeded == true); + } + + /** Build the link between the given segment-cabin and the given + leg-cabin. */ + template <typename SEGMENT_CABIN> + static void initLinkSegmentCabinWithLegCabin (SEGMENT_CABIN& ioSegmentCabin, + typename SEGMENT_CABIN::LegCabinContent_T& ioLegCabin) { + // Retrieve the leg-cabin type. + typedef typename SEGMENT_CABIN::LegCabinContent_T LEG_CABIN_T; + // Define the segment-cabin holder type. + typedef BomChildrenHolderImp<SEGMENT_CABIN> SEGMENT_CABIN_HOLDER_T; + // Define the leg-cabin holder type. + typedef BomChildrenHolderImp<LEG_CABIN_T> LEG_CABIN_HOLDER_T; + + LEG_CABIN_HOLDER_T* lLegCabinHolder_ptr = + ioSegmentCabin._segmentCabinStructure._legCabinHolder; + assert (lLegCabinHolder_ptr != NULL); + + // bool addingSucceeded = FacBomStructure:: +// addBomObjecdToBomHolder<LEG_CABIN_T>(*lLegCabinHolder_ptr, ioLegCabin); +// assert (addingSucceeded == true); + + SEGMENT_CABIN_HOLDER_T* lSegmentCabinHolder_ptr = + ioLegCabin._legCabinStructure._segmentCabinHolder; + if (lSegmentCabinHolder_ptr == NULL) { + lSegmentCabinHolder_ptr = &FacBomStructure:: + instance().createBomHolder<SEGMENT_CABIN> (); + } + // addingSucceeded = FacBomStructure:: +// addBomObjecdToBomHolder<SEGMENT_CABIN> (*lSegmentCabinHolder_ptr, +// ioSegmentCabin); +// assert (addingSucceeded == true); + } + public: /** Provide the unique instance. <br>The singleton is instantiated when first used. Modified: trunk/stdair/stdair/factory/FacBomStructure.hpp =================================================================== --- trunk/stdair/stdair/factory/FacBomStructure.hpp 2009-11-12 18:11:55 UTC (rev 63) +++ trunk/stdair/stdair/factory/FacBomStructure.hpp 2009-11-13 08:52:41 UTC (rev 64) @@ -127,7 +127,7 @@ /** 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) { + 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. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |