From: <qua...@us...> - 2010-01-07 15:53:50
|
Revision: 90 http://stdair.svn.sourceforge.net/stdair/?rev=90&view=rev Author: quannaus Date: 2010-01-07 15:53:41 +0000 (Thu, 07 Jan 2010) Log Message: ----------- [Dev] Implemented the network building procedure. Modified Paths: -------------- trunk/stdair/stdair/bom/AirportDate.cpp trunk/stdair/stdair/bom/AirportDate.hpp trunk/stdair/stdair/bom/AirportDateContent.hpp trunk/stdair/stdair/bom/AirportDateStructure.hpp trunk/stdair/stdair/bom/FlightDateKey.hpp trunk/stdair/stdair/bom/InventoryKey.hpp trunk/stdair/stdair/bom/LegDateContent.cpp trunk/stdair/stdair/bom/LegDateContent.hpp trunk/stdair/stdair/bom/LegDateKey.cpp trunk/stdair/stdair/bom/LegDateKey.hpp trunk/stdair/stdair/bom/NetworkDate.cpp trunk/stdair/stdair/bom/NetworkDate.hpp trunk/stdair/stdair/bom/NetworkDateStructure.hpp trunk/stdair/stdair/bom/NetworkStructure.hpp trunk/stdair/stdair/bom/OutboundPath.cpp trunk/stdair/stdair/bom/OutboundPath.hpp trunk/stdair/stdair/bom/OutboundPathContent.hpp trunk/stdair/stdair/bom/OutboundPathStructure.hpp trunk/stdair/stdair/bom/OutboundPathTypes.hpp trunk/stdair/stdair/bom/SegmentDate.cpp trunk/stdair/stdair/bom/SegmentDate.hpp trunk/stdair/stdair/bom/SegmentDateContent.cpp trunk/stdair/stdair/bom/SegmentDateContent.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/AirportDate.cpp =================================================================== --- trunk/stdair/stdair/bom/AirportDate.cpp 2010-01-06 18:13:55 UTC (rev 89) +++ trunk/stdair/stdair/bom/AirportDate.cpp 2010-01-07 15:53:41 UTC (rev 90) @@ -4,6 +4,7 @@ // C #include <assert.h> // STDAIR +#include <stdair/basic/BasConst_Inventory.hpp> #include <stdair/bom/AirportDateStructure.hpp> #include <stdair/bom/AirportDate.hpp> #include <stdair/bom/OutboundPath.hpp> @@ -63,6 +64,34 @@ OutboundPathMap_T AirportDate::getOutboundPathMap () const { return _airportDateStructure.getChildrenHolder(); } + + // //////////////////////////////////////////////////////////////////// + void AirportDate:: + buildOutboundPathListList (OutboundPath& ioOutboundPath) { + const OutboundPathKey_T& lOutboundPathKey = ioOutboundPath.getKey(); + const NbOfSegments_T& lNbOfSegments = + lOutboundPathKey.getNbOfSegments (); + assert (lNbOfSegments > 0 + && lNbOfSegments <= MAXIMUM_NUMBER_OF_SEGMENTS_IN_OND); + const NbOfSegments_T lNbOfSegments_m1 = + static_cast<const NbOfSegments_T> (lNbOfSegments - 1); + + // If needed, initialise the list of lists with empty fixed-length + // outbound-path lists. + while (_outboundPathListList.size() <= lNbOfSegments_m1) { + OutboundPathLightList_T lOutboundPathLightList; + _outboundPathListList.push_back (lOutboundPathLightList); + } + + // Retrieve the i-fixed-length Outbound-Path list (i = number of + // segments). + OutboundPathLightList_T& lOutboundPathLightList = + _outboundPathListList.at (lNbOfSegments-1); + + // Add the OutboundPath to that fixed-length-path list. + lOutboundPathLightList.push_back (&ioOutboundPath); + } + } Modified: trunk/stdair/stdair/bom/AirportDate.hpp =================================================================== --- trunk/stdair/stdair/bom/AirportDate.hpp 2010-01-06 18:13:55 UTC (rev 89) +++ trunk/stdair/stdair/bom/AirportDate.hpp 2010-01-07 15:53:41 UTC (rev 90) @@ -5,7 +5,7 @@ // Import section // ////////////////////////////////////////////////////////////////////// // STDAIR -#include <stdair/bom/FlightDate.hpp> +#include <stdair/bom/NetworkDate.hpp> #include <stdair/bom/AirportDateStructure.hpp> #include <stdair/bom/AirportDateContent.hpp> #include <stdair/bom/AirportDateTypes.hpp> @@ -26,7 +26,7 @@ // Type definitions /** Definition allowing to retrieve the associated parent BOM content type. */ - typedef FlightDate Parent_T; + typedef NetworkDate Parent_T; /** Definition allowing to retrieve the associated BOM structure type. */ typedef AirportDateStructure_T BomStructure_T; @@ -68,13 +68,22 @@ /** Get a OutboundPathMap_T for iteration methods. */ OutboundPathMap_T getOutboundPathMap () const; - + /** Get the OutboundPathListList. */ + const OutboundPathListList_T& getOutboundPathListList () const { + return _outboundPathListList; + } + private: /** Retrieve the BOM structure object. */ BomStructure_T& getBomStructure () { return _airportDateStructure; } + public: + // //////////// Business Methods ////////////// + /** Build the list of lists of outbound paths. **/ + void buildOutboundPathListList (stdair::OutboundPath&); + protected: /** Constructors are private so as to force the usage of the Factory layer. */ @@ -91,6 +100,11 @@ /** Reference structure. */ BomStructure_T& _airportDateStructure; + /** The list of lists of OutboundPaths, used uniquement for the + construction of the main list of OutboundPaths in + AirportDateStructure. */ + OutboundPathListList_T _outboundPathListList; + }; } Modified: trunk/stdair/stdair/bom/AirportDateContent.hpp =================================================================== --- trunk/stdair/stdair/bom/AirportDateContent.hpp 2010-01-06 18:13:55 UTC (rev 89) +++ trunk/stdair/stdair/bom/AirportDateContent.hpp 2010-01-07 15:53:41 UTC (rev 90) @@ -23,6 +23,11 @@ const BomKey_T& getKey() const { return _key; } + + /** Get the (origin) airport (part of the primary key). */ + const AirportCode_T& getOrigin() const { + return _key.getBoardingPoint(); + } public: // /////////// Display support methods ///////// Modified: trunk/stdair/stdair/bom/AirportDateStructure.hpp =================================================================== --- trunk/stdair/stdair/bom/AirportDateStructure.hpp 2010-01-06 18:13:55 UTC (rev 89) +++ trunk/stdair/stdair/bom/AirportDateStructure.hpp 2010-01-07 15:53:41 UTC (rev 90) @@ -15,6 +15,7 @@ namespace stdair { // Forward declarations. template <typename BOM> struct BomMap_T; + struct NetworkDateKey_T; /** Wrapper class aimed at holding the actual content, modeled by an external specific AirportDate class (for instance, @@ -103,6 +104,15 @@ return oContentChild_ptr; } + + /** Get the AirportDate (from the Network parent class) corresponding + to the given key (reference date + airport code). + <br>Return the NULL pointer if not existing. */ + Content_T* getAirportDate (const BomKey_T& iAirportDateKey, + const NetworkDateKey_T& iNetworkDateKey)const{ + assert (_parent != NULL); + return _parent->getAirportDate (iAirportDateKey, iNetworkDateKey); + } private: // /////////// Setters ///////////// Modified: trunk/stdair/stdair/bom/FlightDateKey.hpp =================================================================== --- trunk/stdair/stdair/bom/FlightDateKey.hpp 2010-01-06 18:13:55 UTC (rev 89) +++ trunk/stdair/stdair/bom/FlightDateKey.hpp 2010-01-07 15:53:41 UTC (rev 90) @@ -43,6 +43,11 @@ const Date_T& getFlightDate() const { return _flightDate; } + + /** Get the airline code of the flight-date. */ + const AirlineCode_T& getAirlineCode () const { + return _parentKey.getAirlineCode(); + } // /////////// Setters ///////////// /** Set the parent key. */ Modified: trunk/stdair/stdair/bom/InventoryKey.hpp =================================================================== --- trunk/stdair/stdair/bom/InventoryKey.hpp 2010-01-06 18:13:55 UTC (rev 89) +++ trunk/stdair/stdair/bom/InventoryKey.hpp 2010-01-07 15:53:41 UTC (rev 90) @@ -34,7 +34,9 @@ // /////////// Getters ////////// /** Get the airline code. */ - const AirlineCode_T& getAirlineCode() const; + const AirlineCode_T& getAirlineCode() const { + return _airlineCode; + } // /////////// Display support methods ///////// /** Dump a Business Object Key into an output stream. Modified: trunk/stdair/stdair/bom/LegDateContent.cpp =================================================================== --- trunk/stdair/stdair/bom/LegDateContent.cpp 2010-01-06 18:13:55 UTC (rev 89) +++ trunk/stdair/stdair/bom/LegDateContent.cpp 2010-01-07 15:53:41 UTC (rev 90) @@ -24,9 +24,9 @@ // ////////////////////////////////////////////////////////////////////// const Duration_T LegDateContent::getTimeOffSet() const { - // TimeOffSet = (OffTime - BoardTime) + (OffDate - BoardDate) * 24 + // TimeOffSet = (OffTime - BoardingTime) + (OffDate - BoardingDate) * 24 // - ElapsedTime - Duration_T oTimeOffSet = (_offTime - _boardTime); + Duration_T oTimeOffSet = (_offTime - _boardingTime); const DateOffSet_T& lDateOffSet = getDateOffSet(); const Duration_T lDateOffSetInHours (lDateOffSet.days() * 24, 0, 0); oTimeOffSet += lDateOffSetInHours - _elapsedTime; Modified: trunk/stdair/stdair/bom/LegDateContent.hpp =================================================================== --- trunk/stdair/stdair/bom/LegDateContent.hpp 2010-01-06 18:13:55 UTC (rev 89) +++ trunk/stdair/stdair/bom/LegDateContent.hpp 2010-01-07 15:53:41 UTC (rev 90) @@ -24,9 +24,9 @@ return _key; } - /** Get the board point (part of the primary key). */ - const AirportCode_T& getBoardPoint () const { - return _key.getBoardPoint(); + /** Get the boarding point (part of the primary key). */ + const AirportCode_T& getBoardingPoint () const { + return _key.getBoardingPoint(); } /** Get the off point. */ @@ -34,14 +34,14 @@ return _offPoint; } - /** Get the board date. */ - const Date_T& getBoardDate () const { - return _boardDate; + /** Get the boarding date. */ + const Date_T& getBoardingDate () const { + return _boardingDate; } - /** Get the board time. */ - const Duration_T& getBoardTime () const { - return _boardTime; + /** Get the boarding time. */ + const Duration_T& getBoardingTime () const { + return _boardingTime; } /** Get the off date. */ @@ -85,14 +85,14 @@ } - /** Get the date off set (off date - board date). */ + /** Get the date off set (off date - boarding date). */ const DateOffSet_T getDateOffSet () const { - return _offDate - _boardDate; + return _offDate - _boardingDate; } - /** Get the time off set between board and off points. + /** Get the time off set between boarding and off points. <br>It is defined as being: - TimeOffSet = (OffTime - BoardTime) + (OffDate - BoardDate) * 24 + TimeOffSet = (OffTime - BoardingTime) + (OffDate - BoardingDate) * 24 - ElapsedTime. */ const Duration_T getTimeOffSet() const; @@ -103,14 +103,14 @@ _offPoint = iOffPoint; } - /** Set the board date. */ - void setBoardDate (const Date_T& iBoardDate) { - _boardDate = iBoardDate; + /** Set the boarding date. */ + void setBoardingDate (const Date_T& iBoardingDate) { + _boardingDate = iBoardingDate; } - /** Set the board time. */ - void setBoardTime (const Duration_T& iBoardTime) { - _boardTime = iBoardTime; + /** Set the boarding time. */ + void setBoardingTime (const Duration_T& iBoardingTime) { + _boardingTime = iBoardingTime; } /** Set the off date. */ @@ -172,11 +172,11 @@ /** Off Point. */ AirportCode_T _offPoint; - /** Board Date. */ - Date_T _boardDate; + /** Boarding Date. */ + Date_T _boardingDate; - /** Board Time. */ - Duration_T _boardTime; + /** Boarding Time. */ + Duration_T _boardingTime; /** Off Date. */ Date_T _offDate; Modified: trunk/stdair/stdair/bom/LegDateKey.cpp =================================================================== --- trunk/stdair/stdair/bom/LegDateKey.cpp 2010-01-06 18:13:55 UTC (rev 89) +++ trunk/stdair/stdair/bom/LegDateKey.cpp 2010-01-07 15:53:41 UTC (rev 90) @@ -7,12 +7,12 @@ namespace stdair { // //////////////////////////////////////////////////////////////////// - LegDateKey_T::LegDateKey_T (const AirportCode_T& iBoardPoint) - : _boardPoint (iBoardPoint) { + LegDateKey_T::LegDateKey_T (const AirportCode_T& iBoardingPoint) + : _boardingPoint (iBoardingPoint) { } // //////////////////////////////////////////////////////////////////// LegDateKey_T::LegDateKey_T (const LegDateKey_T& iKey) - : _parentKey (iKey._parentKey), _boardPoint (iKey._boardPoint) { + : _parentKey (iKey._parentKey), _boardingPoint (iKey._boardingPoint) { } // //////////////////////////////////////////////////////////////////// @@ -31,7 +31,7 @@ // //////////////////////////////////////////////////////////////////// const std::string LegDateKey_T::toString() const { std::ostringstream oStr; - oStr << _boardPoint; + oStr << _boardingPoint; return oStr.str(); } Modified: trunk/stdair/stdair/bom/LegDateKey.hpp =================================================================== --- trunk/stdair/stdair/bom/LegDateKey.hpp 2010-01-06 18:13:55 UTC (rev 89) +++ trunk/stdair/stdair/bom/LegDateKey.hpp 2010-01-07 15:53:41 UTC (rev 90) @@ -26,7 +26,7 @@ public: // /////////// Construction /////////// /** Constructors. */ - LegDateKey_T (const AirportCode_T& iBoardPoint); + LegDateKey_T (const AirportCode_T& iBoardingPoint); LegDateKey_T (const LegDateKey_T&); /** Destructor. */ @@ -34,8 +34,8 @@ // /////////// Getters ////////// /** Get the boarding point. */ - const AirportCode_T& getBoardPoint() const { - return _boardPoint; + const AirportCode_T& getBoardingPoint() const { + return _boardingPoint; } // /////////// Setters ///////////// @@ -67,8 +67,8 @@ /** Flight-date Key.*/ ParentKey_T _parentKey; - /** Boarding airport. */ - AirportCode_T _boardPoint; + /** Boardinging airport. */ + AirportCode_T _boardingPoint; }; } Modified: trunk/stdair/stdair/bom/NetworkDate.cpp =================================================================== --- trunk/stdair/stdair/bom/NetworkDate.cpp 2010-01-06 18:13:55 UTC (rev 89) +++ trunk/stdair/stdair/bom/NetworkDate.cpp 2010-01-07 15:53:41 UTC (rev 90) @@ -57,6 +57,12 @@ AirportDateMap_T NetworkDate::getAirportDateMap () const { return _networkDateStructure.getChildrenHolder(); } - + + // ////////////////////////////////////////////////////////////////////// + AirportDate* NetworkDate:: + getAirportDate (const AirportDateKey_T& iKey) const { + return _networkDateStructure.getContentChild (iKey); + } + } Modified: trunk/stdair/stdair/bom/NetworkDate.hpp =================================================================== --- trunk/stdair/stdair/bom/NetworkDate.hpp 2010-01-06 18:13:55 UTC (rev 89) +++ trunk/stdair/stdair/bom/NetworkDate.hpp 2010-01-07 15:53:41 UTC (rev 90) @@ -5,7 +5,7 @@ // Import section // ////////////////////////////////////////////////////////////////////// // STDAIR -#include <stdair/bom/BomRoot.hpp> +#include <stdair/bom/Network.hpp> #include <stdair/bom/NetworkDateStructure.hpp> #include <stdair/bom/NetworkDateTypes.hpp> #include <stdair/bom/AirportDateTypes.hpp> @@ -30,7 +30,7 @@ // ///////////////////////////////////////////////////////////////////////// /** Definition allowing to retrieve the associated parent BOM content type. */ - typedef BomRoot Parent_T; + typedef Network Parent_T; /** Definition allowing to retrieve the associated BOM structure type. */ typedef NetworkDateStructure_T BomStructure_T; @@ -41,9 +41,6 @@ /** Definition allowing to retrieve the associated BOM content child type. */ typedef AirportDate ContentChild_T; - - /** Definition allowing to retrieve the specific BookingClass type. */ - typedef BookingClass BookingClassContent_T; // ///////////////////////////////////////////////////////////////////////// public: @@ -74,7 +71,12 @@ /** Get a AirportDateMap_T for iteration methods. */ AirportDateMap_T getAirportDateMap () const; - + + /** Retrieve, if existing, the AirportDate corresponding to the + given airport-date key. + <br>If not existing, return the NULL pointer. */ + AirportDate* getAirportDate (const AirportDateKey_T&) const; + private: /** Retrieve the BOM structure object. */ BomStructure_T& getBomStructure () { Modified: trunk/stdair/stdair/bom/NetworkDateStructure.hpp =================================================================== --- trunk/stdair/stdair/bom/NetworkDateStructure.hpp 2010-01-06 18:13:55 UTC (rev 89) +++ trunk/stdair/stdair/bom/NetworkDateStructure.hpp 2010-01-07 15:53:41 UTC (rev 90) @@ -17,6 +17,7 @@ namespace stdair { // Forward declarations. template <typename BOM> struct BomMap_T; + struct AirportDateKey_T; /** Wrapper class aimed at holding the actual content, modeled by an external specific NetworkDate class (for instance, @@ -109,6 +110,26 @@ return oContentChild_ptr; } + + /** Get the AirportDate (from the Network parent class) corresponding + to the given key (reference date + airport code). + <br>Return the NULL pointer if not existing. */ + ContentChild_T* getAirportDate (const AirportDateKey_T& iAirportDateKey, + const BomKey_T& iNetworkDateKey) const { + assert (_parent != NULL); + ContentChild_T* oAirportDate_ptr = NULL; + + const BOM_CONTENT* lNetworkDate_ptr = + _parent->getContentChild (iNetworkDateKey); + + + if (lNetworkDate_ptr != NULL) { + oAirportDate_ptr = + lNetworkDate_ptr->getAirportDate (iAirportDateKey); + } + + return oAirportDate_ptr; + } private: // /////////// Setters ///////////// Modified: trunk/stdair/stdair/bom/NetworkStructure.hpp =================================================================== --- trunk/stdair/stdair/bom/NetworkStructure.hpp 2010-01-06 18:13:55 UTC (rev 89) +++ trunk/stdair/stdair/bom/NetworkStructure.hpp 2010-01-07 15:53:41 UTC (rev 90) @@ -60,15 +60,6 @@ /** Define the children bom holder type. */ typedef BomChildrenHolderImp<ContentChild_T> ChildrenBomHolder_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 booking class. */ - // typedef BomMap_T<BookingClass_T> BookingClassMap_T; - public: // /////////// Getters ///////////// /** Get the (parent) BomStructureRoot object. */ @@ -99,28 +90,22 @@ ioChildrenHolder = _childrenHolder; } - /** Get the holder of booking classes. */ - // BookingClassHolder_T& getBookingClassHolder() const { - // assert (_bookingClassHolder); - // return *_bookingClassHolder; - // } - /** Retrieve, if existing, the network-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 (getChildrenHolder()); - // const MapKey_T lMapKey = iKey.toString(); + ChildrenMap_T lChildrenMap (getChildrenHolder()); + const MapKey_T lMapKey = iKey.toString(); - // typename ChildrenMap_T::iterator itContentChild = - // lChildrenMap.find (lMapKey); + typename ChildrenMap_T::iterator itContentChild = + lChildrenMap.find (lMapKey); - // if (itContentChild != lChildrenMap.end()) { - // oContentChild_ptr = itContentChild->second; - // assert (oContentChild_ptr != NULL); - // } + if (itContentChild != lChildrenMap.end()) { + oContentChild_ptr = itContentChild->second; + assert (oContentChild_ptr != NULL); + } return oContentChild_ptr; } Modified: trunk/stdair/stdair/bom/OutboundPath.cpp =================================================================== --- trunk/stdair/stdair/bom/OutboundPath.cpp 2010-01-06 18:13:55 UTC (rev 89) +++ trunk/stdair/stdair/bom/OutboundPath.cpp 2010-01-07 15:53:41 UTC (rev 90) @@ -6,6 +6,9 @@ // STDAIR #include <stdair/bom/OutboundPathStructure.hpp> #include <stdair/bom/OutboundPath.hpp> +#include <stdair/bom/SegmentDate.hpp> +#include <stdair/bom/BomList.hpp> +#include <stdair/bom/BomMap.hpp> namespace stdair { @@ -20,16 +23,16 @@ OutboundPath::~OutboundPath () { } - // ////////////////////////////////////////////////////////////////////// + // //////////////////////////////////////////////////////////////////// void OutboundPath::toStream (std::ostream& ioOut) const { ioOut << toString() << std::endl; } - // ////////////////////////////////////////////////////////////////////// + // //////////////////////////////////////////////////////////////////// void OutboundPath::fromStream (std::istream& ioIn) { } - // ////////////////////////////////////////////////////////////////////// + // //////////////////////////////////////////////////////////////////// std::string OutboundPath::toString() const { std::ostringstream oStr; @@ -42,15 +45,190 @@ return oStr.str(); } - // ////////////////////////////////////////////////////////////////////// + // //////////////////////////////////////////////////////////////////// const std::string OutboundPath::describeKey() const { return _outboundPathStructure.describeKey(); } - // ////////////////////////////////////////////////////////////////////// + // //////////////////////////////////////////////////////////////////// const std::string OutboundPath::describeShortKey() const { return _outboundPathStructure.describeShortKey(); } + + // //////////////////////////////////////////////////////////////////// + SegmentDateList_T OutboundPath::getSegmentDateList () const { + return _outboundPathStructure.getSegmentDateHolder(); + } + + // //////////////////////////////////////////////////////////////////// + SegmentDateMap_T OutboundPath::getSegmentDateMap () const { + return _outboundPathStructure.getSegmentDateHolder(); + } + + // //////////////////////////////////////////////////////////////////// + const Date_T& OutboundPath::getOffDate () const { + const SegmentDate* lLastSegmentDate_ptr = getLastSegmentDate (); + assert (lLastSegmentDate_ptr != NULL); + return (lLastSegmentDate_ptr->getOffDate ()); + } + + // //////////////////////////////////////////////////////////////////// + const SegmentDate* OutboundPath::getLastSegmentDate () const { + const SegmentDate* oSegment_ptr = NULL; + + // Retrieve the last segment of the list + SegmentDateList_T lSegmentDateList = getSegmentDateList(); + SegmentDateList_T::reverse_iterator itLastSegment= lSegmentDateList.rbegin(); + + if (itLastSegment == lSegmentDateList.rend()) { + return oSegment_ptr; + } + + oSegment_ptr = &*itLastSegment; + assert (oSegment_ptr != NULL); + + return oSegment_ptr; + } + + // //////////////////////////////////////////////////////////////////// + const SegmentDate* OutboundPath::getFirstSegmentDate () const { + const SegmentDate* oSegment_ptr = NULL; + + // Retrieve the first segment of the list + SegmentDateList_T lSegmentDateList = getSegmentDateList(); + SegmentDateList_T::iterator itFirstSegment= lSegmentDateList.begin(); + + if (itFirstSegment == lSegmentDateList.end()) { + return oSegment_ptr; + } + + oSegment_ptr = &*itFirstSegment; + assert (oSegment_ptr != NULL); + + return oSegment_ptr; + } + + // //////////////////////////////////////////////////////////////////// + void OutboundPath::incrementTotalFlightTime (const Duration_T& iElapsed) { + _flightTime += iElapsed; + } + + // //////////////////////////////////////////////////////////////////// + void OutboundPath::updateAirlineCode() { + // TODO: to be optimised. + std::ostringstream ostr; + SegmentDateList_T lSegmentDateList = getSegmentDateList(); + + for (SegmentDateList_T::iterator itSegmentDate = lSegmentDateList.begin(); + itSegmentDate != lSegmentDateList.end(); ++itSegmentDate) { + const SegmentDate& lSegmentDate = *itSegmentDate; + ostr << lSegmentDate.getAirlineCode(); + } + + const AirlineCode_T lAirlineCode (ostr.str()); + setAirlineCode(lAirlineCode); + } + + // //////////////////////////////////////////////////////////////////// + AirportDate* OutboundPath::getDestinationAirportDate() const { + AirportDate* oAirportDate_ptr = NULL; + + // Retrieve the off point description (reference date + airport code). + const AirportCode_T& lDestination = getDestination(); + const Date_T& lReferenceDate = getOffDate(); + + const AirportDateKey_T lAirportDateKey (lDestination); + const NetworkDateKey_T lNetworkDateKey (lReferenceDate); + // Retrieve the destination airport corresponding to the destination + // reference date and airport code. + oAirportDate_ptr = _outboundPathStructure.getAirportDate (lAirportDateKey, + lNetworkDateKey); + + return oAirportDate_ptr; + } + + // //////////////////////////////////////////////////////////////////// + bool OutboundPath::isConnectable (const OutboundPath& iOutboundPath) const { + // Delegate the check on the two (potentially) connecting SegmentDate + // objects, i.e., the last SegmentDate of the current OutboundPath, + // and the first SegmentDate of the given OutboundPath. + const SegmentDate* lOffSegment_ptr = getLastSegmentDate(); + assert (lOffSegment_ptr != NULL); + + const SegmentDate* lBoardingSegment_ptr = + iOutboundPath.getFirstSegmentDate(); + assert (lBoardingSegment_ptr != NULL); + + return lOffSegment_ptr->isConnectable (*lBoardingSegment_ptr); + } + + // //////////////////////////////////////////////////////////////////// + bool OutboundPath:: + isAirlineFlown (const AirlineCode_T& iAirlineCode) const { + bool oAirlineFlown = false; + + const SegmentDateList_T& lSegmentDateList = getSegmentDateList (); + for (SegmentDateList_T::iterator itSegmentDate = + lSegmentDateList.begin(); + itSegmentDate != lSegmentDateList.end(); ++itSegmentDate) { + const SegmentDate& lSegmentDate = *itSegmentDate; + + const AirlineCode_T& lSegmentAirlineCode = + lSegmentDate.getAirlineCode(); + if (lSegmentAirlineCode == iAirlineCode) { + oAirlineFlown = true; + break; + } + } + + return oAirlineFlown; + } + + // ////////////////////////////////////////////////////////////////////// + const Duration_T OutboundPath::calculateElapsedTimeFromRouting () const { + const SegmentDateList_T& lAllSegmentList = getSegmentDateList(); + SegmentDateList_T::iterator itSegmentDate = lAllSegmentList.begin(); + + const SegmentDate* lCurrentSegmentDate_ptr = &*itSegmentDate; + assert (lCurrentSegmentDate_ptr != NULL); + + // Retrieve the elapsed time of the first segment + Duration_T oElapsedTime = lCurrentSegmentDate_ptr->getElapsedTime(); + + // Go to the next segment, if existing. If not existing, the following + // loop will not be entered (as it means: + // itSegmentDate == _segmentDateList.end()). + ++itSegmentDate; + + for (const SegmentDate* previousSegmentDate_ptr = lCurrentSegmentDate_ptr; + itSegmentDate != lAllSegmentList.end(); + ++itSegmentDate, previousSegmentDate_ptr = lCurrentSegmentDate_ptr) { + lCurrentSegmentDate_ptr = &*itSegmentDate; + assert (lCurrentSegmentDate_ptr != NULL); + assert (previousSegmentDate_ptr != NULL); + + // As the boarding point (and date) of the current segment are + // the same as the off point (and date) of the previous + // segment (by construction), there is no time difference. + assert (lCurrentSegmentDate_ptr->getBoardingPoint() + == previousSegmentDate_ptr->getOffPoint() + && lCurrentSegmentDate_ptr->getBoardingDate() + == previousSegmentDate_ptr->getOffDate()); + const Duration_T& lStopOverTime = + lCurrentSegmentDate_ptr->getBoardingTime() + - previousSegmentDate_ptr->getOffTime(); + oElapsedTime += lStopOverTime; + + // Add the elapsed time of the current outbound path + const Duration_T& currentElapsedTime = + lCurrentSegmentDate_ptr->getElapsedTime(); + oElapsedTime += currentElapsedTime; + } + + // Store the result + return oElapsedTime; + } + } Modified: trunk/stdair/stdair/bom/OutboundPath.hpp =================================================================== --- trunk/stdair/stdair/bom/OutboundPath.hpp 2010-01-06 18:13:55 UTC (rev 89) +++ trunk/stdair/stdair/bom/OutboundPath.hpp 2010-01-07 15:53:41 UTC (rev 90) @@ -10,10 +10,12 @@ #include <stdair/bom/OutboundPathContent.hpp> #include <stdair/bom/AirportDateTypes.hpp> #include <stdair/bom/OutboundPathTypes.hpp> +#include <stdair/bom/SegmentDateTypes.hpp> namespace stdair { // Forward declarations class FacBomContent; + class SegmentDate; struct OutboundPathKey_T; /** Class representing the actual functional/business content for a @@ -37,9 +39,29 @@ BOM content child type. */ typedef OutboundPath ContentChild_T; + /** Definition allowing to retrieve the specific SegmentDate type. */ + typedef SegmentDate SegmentDateContent_T; + public: // /////////// Getters ///////////// - + /** Get a SegmentDateList_T for iteration methods. */ + SegmentDateList_T getSegmentDateList () const; + + /** Get a SegmentDateMap_T for iteration methods. */ + SegmentDateMap_T getSegmentDateMap () const; + + /** Get the off date. */ + const Date_T& getOffDate () const; + + /** Get the last SegmentDate (constant) object of the list. + <br>Return a NULL pointer if the list is empty. */ + const SegmentDate* getLastSegmentDate () const; + + /** Get the first SegmentDate (constant) object of the list. + <br>Return a NULL pointer if the list is empty. */ + const SegmentDate* getFirstSegmentDate () const; + + public: // ///////// Setters ////////// @@ -64,7 +86,58 @@ at the same level). */ const std::string describeShortKey() const; + private: + // ////////////// Business methods ////////////// + /** Increments the total flight time of the outbound path.*/ + void incrementTotalFlightTime (const Duration_T&); + public: + /** Get the AirportDate corresponding to the destination of the + outbound-path, i.e., the off point of the last segment-date + of the (segment) list. + <br>Return the NULL pointer if there is no such AirportDate object, + e.g., when the destination is an end point (i.e., when no other + SegmentDate is starting from the destination). */ + AirportDate* getDestinationAirportDate() const; + + /** States whether or not the given OutboundPath may connect with the + current one. + <br>Basically, the board time of the given OutboundPath should be + such as to allow the passenger connecting from the previous flight + (current OutboundPath object) to the next one (given OutboundPath). + <br>Note that this method relies on the eponym method of the + SegmentDate class. */ + bool isConnectable (const OutboundPath&) const; + + /** State whether or not the given airline is flown by (at least) one of + the segments of the internal list. */ + bool isAirlineFlown (const AirlineCode_T&) const; + + /** Calculate the elapsed time according to the segment routing. + <br>Note that the given segment-date should come at the end of the + outbound-path. An assertion will fail if the given board point and + board date do not correspond to the off point and off date of the + last segment-date of the outbound-path. + <br>That method is a helper function allowing calculating the + elapsed time of a to-be-built OutboundPath object. Indeed, the + elapsed time can not be set after the object creation, as it is + part of the primary key (needed at the time of object creation). + <br>Actually, the elapsed time of the outbound path is the sum of the + elapsed times of the routing segments, plus the stop-over times. + The stop-over time is the difference between the board time of a + routing segment, and the off time of the previous segment. That is, + it is the time spent at the corresponding airport. + <br>Of course, in case of mono-segment outbound pathes, there is no + stop-over, and the elapsed time of the outbound-path is equal to the + elapsed time of the single routing segment. */ + const Duration_T calculateElapsedTimeFromRouting ()const; + + + public: + // ////////////// Business methods ////////////// + /** Update Airline Code. */ + void updateAirlineCode (); + private: /** Retrieve the BOM structure object. */ BomStructure_T& getBomStructure () { Modified: trunk/stdair/stdair/bom/OutboundPathContent.hpp =================================================================== --- trunk/stdair/stdair/bom/OutboundPathContent.hpp 2010-01-06 18:13:55 UTC (rev 89) +++ trunk/stdair/stdair/bom/OutboundPathContent.hpp 2010-01-07 15:53:41 UTC (rev 90) @@ -75,7 +75,6 @@ _flightPathCode = iFPCode; } - public: // /////////// Display support methods ///////// /** Dump a Business Object into an output stream. Modified: trunk/stdair/stdair/bom/OutboundPathStructure.hpp =================================================================== --- trunk/stdair/stdair/bom/OutboundPathStructure.hpp 2010-01-06 18:13:55 UTC (rev 89) +++ trunk/stdair/stdair/bom/OutboundPathStructure.hpp 2010-01-07 15:53:41 UTC (rev 90) @@ -11,6 +11,11 @@ #include <stdair/bom/BomStopContent.hpp> namespace stdair { + // Forward declarations. + template <typename BOM> struct BomMap_T; + struct AirportDateKey_T; + struct NetworkDateKey_T; + /** Wrapper class aimed at holding the actual content, modeled by an external specific OutboundPath class (for instance, in the AIRSCHED library). */ @@ -39,6 +44,18 @@ /** Definition allowing to retrieve the default children bom holder type. */ typedef BomChildrenHolderImp<BomStopContent> DefaultChildrenBomHolder_T; + /** Define the children segment-date type. */ + typedef typename BOM_CONTENT::SegmentDateContent_T SegmentDate_T; + + /** Define the children segment-date holder type. */ + typedef BomChildrenHolderImp<SegmentDate_T> SegmentDateHolder_T; + + /** Define the map of segment-date. */ + typedef BomMap_T<SegmentDate_T> SegmentDateMap_T; + + /** Definition allowing to retrieve the AirportDate type. */ + typedef typename BOM_CONTENT::Parent_T AirportDate_T; + public: // /////////// Getters ///////////// /** Get the (parent) AirportDateStructure object. */ @@ -47,13 +64,30 @@ } /** Get the (parent) AirportDateStructure object. */ - ParentBomStructure_T& getAirportDateStructure() const; + ParentBomStructure_T& getAirportDateStructure() const { + assert (_parent != NULL); + return *_parent; + } - /** Get the segment-cabin key. */ + /** Get the outbound path key. */ const BomKey_T& getKey() const { assert (_content != NULL); return _content->getKey(); } + /** Get the holder of segment-dates. */ + SegmentDateHolder_T& getSegmentDateHolder() const { + assert (_segmentDateHolder); + return *_segmentDateHolder; + } + + /** Get the AirportDate (from the Network parent class) corresponding + to the given key (reference date + airport code). + <br>Return the NULL pointer if not existing. */ + AirportDate_T* getAirportDate (const AirportDateKey_T& iAirportDateKey, + const NetworkDateKey_T& iNetworkDateKey)const{ + assert (_parent != NULL); + return _parent->getAirportDate (iAirportDateKey, iNetworkDateKey); + } private: // /////////// Setters ///////////// @@ -64,6 +98,11 @@ /** Default children holder setter. */ void setChildrenHolder (DefaultChildrenBomHolder_T&) { } + + /** Set the segment-date holder. */ + void setSegmentDateHolder (SegmentDateHolder_T& ioSegmentDateHolder) { + _segmentDateHolder = &ioSegmentDateHolder; + } public: // /////////// Display support methods ///////// @@ -92,7 +131,8 @@ /** Constructors are private so as to force the usage of the Factory layer. */ /** Default constructors. */ - OutboundPathStructure () : _parent (NULL), _content (NULL) { } + OutboundPathStructure () : _parent (NULL), _content (NULL), + _segmentDateHolder (NULL) { } OutboundPathStructure (const OutboundPathStructure&); /** Destructor. */ @@ -106,6 +146,9 @@ /** The actual functional (Business Object) content. */ BOM_CONTENT* _content; + /** Holder of segment-dates. */ + SegmentDateHolder_T* _segmentDateHolder; + }; } Modified: trunk/stdair/stdair/bom/OutboundPathTypes.hpp =================================================================== --- trunk/stdair/stdair/bom/OutboundPathTypes.hpp 2010-01-06 18:13:55 UTC (rev 89) +++ trunk/stdair/stdair/bom/OutboundPathTypes.hpp 2010-01-07 15:53:41 UTC (rev 90) @@ -31,6 +31,10 @@ /** Define the booking class map. */ typedef BomMap_T<OutboundPath> OutboundPathMap_T; + + typedef std::vector<std::vector<stdair::OutboundPath*> >OutboundPathListList_T; + typedef std::vector<stdair::OutboundPath*> OutboundPathLightList_T; + } #endif // __STDAIR_BOM_OUTBOUNDPATHTYPES_HPP Modified: trunk/stdair/stdair/bom/SegmentDate.cpp =================================================================== --- trunk/stdair/stdair/bom/SegmentDate.cpp 2010-01-06 18:13:55 UTC (rev 89) +++ trunk/stdair/stdair/bom/SegmentDate.cpp 2010-01-07 15:53:41 UTC (rev 90) @@ -4,6 +4,7 @@ // C #include <assert.h> // STDAIR +#include <stdair/basic/BasConst_TravelSolution.hpp> #include <stdair/bom/SegmentDateStructure.hpp> #include <stdair/bom/SegmentDate.hpp> #include <stdair/bom/SegmentCabin.hpp> @@ -71,25 +72,25 @@ } // ///////// /////////////////////////////////////////////////////////////// -// bool SegmentDate:: -// isConnectable (const SegmentDate& iSegmentDate) const { -// bool oIsConnectable = false; + bool SegmentDate:: + isConnectable (const SegmentDate& iSegmentDate) const { + bool oIsConnectable = false; + + const Date_T& lOffDate = getOffDate(); + const Date_T& lBoardingDate = iSegmentDate.getBoardingDate(); + const DateOffSet_T lDateOffSet = lBoardingDate - lOffDate; + const Duration_T lDateOffSetInHours (lDateOffSet.days() * 24, 0, 0); + + const Duration_T& lOffTime = getOffTime(); + const Duration_T& lBoardingTime = iSegmentDate.getBoardingTime(); + + const Duration_T lStopOverTime = + lBoardingTime - lOffTime + lDateOffSetInHours; -// const Date_T& lOffDate = getOffDate(); -// const Date_T& lBoardDate = iSegmentDate.getBoardDate(); -// const DateOffSet_T lDateOffSet = lBoardDate - lOffDate; -// const Duration_T lDateOffSetInHours (lDateOffSet.days() * 24, 0, 0); + oIsConnectable = lStopOverTime >= DEFAULT_MINIMUM_CONNECTION_TIME; -// const Duration_T& lOffTime = getOffTime(); -// const Duration_T& lBoardTime = iSegmentDate.getBoardTime(); - -// const Duration_T lStopOverTime = -// lBoardTime - lOffTime + lDateOffSetInHours; - -// oIsConnectable = lStopOverTime >= DEFAULT_MINIMUM_CONNECTION_TIME; - -// return oIsConnectable; -// } + return oIsConnectable; + } } Modified: trunk/stdair/stdair/bom/SegmentDate.hpp =================================================================== --- trunk/stdair/stdair/bom/SegmentDate.hpp 2010-01-06 18:13:55 UTC (rev 89) +++ trunk/stdair/stdair/bom/SegmentDate.hpp 2010-01-07 15:53:41 UTC (rev 90) @@ -80,7 +80,7 @@ <br>Basically, the board time of the given SegmentDate should be such as to allow the passenger connecting from the previous flight (current SegmentDate object) to the next one (given SegmentDate). */ - // bool isConnectable (const SegmentDate&) const; + bool isConnectable (const SegmentDate&) const; public: // /////////// Display support methods ///////// Modified: trunk/stdair/stdair/bom/SegmentDateContent.cpp =================================================================== --- trunk/stdair/stdair/bom/SegmentDateContent.cpp 2010-01-06 18:13:55 UTC (rev 89) +++ trunk/stdair/stdair/bom/SegmentDateContent.cpp 2010-01-07 15:53:41 UTC (rev 90) @@ -25,9 +25,9 @@ // ////////////////////////////////////////////////////////////////////// const Duration_T SegmentDateContent::getTimeOffSet() const { - // TimeOffSet = (OffTime - BoardTime) + (OffDate - BoardDate) * 24 + // TimeOffSet = (OffTime - BoardingTime) + (OffDate - BoardingDate) * 24 // - ElapsedTime - Duration_T oTimeOffSet = (_offTime - _boardTime); + Duration_T oTimeOffSet = (_offTime - _boardingTime); const DateOffSet_T& lDateOffSet = getDateOffSet(); const Duration_T lDateOffSetInHours (lDateOffSet.days() * 24, 0, 0); oTimeOffSet += lDateOffSetInHours - _elapsedTime; Modified: trunk/stdair/stdair/bom/SegmentDateContent.hpp =================================================================== --- trunk/stdair/stdair/bom/SegmentDateContent.hpp 2010-01-06 18:13:55 UTC (rev 89) +++ trunk/stdair/stdair/bom/SegmentDateContent.hpp 2010-01-07 15:53:41 UTC (rev 90) @@ -24,9 +24,9 @@ return _key; } - /** Get the board point (part of the primary key). */ - const AirportCode_T& getBoardPoint () const { - return _key.getBoardPoint(); + /** Get the boarding point (part of the primary key). */ + const AirportCode_T& getBoardingPoint () const { + return _key.getBoardingPoint(); } /** Get the off point (part of the primary key). */ @@ -59,14 +59,14 @@ return _segmentRPK; } - /** Get the board date. */ - const Date_T& getBoardDate () const { - return _boardDate; + /** Get the boarding date. */ + const Date_T& getBoardingDate () const { + return _boardingDate; } - /** Get the board time. */ - const Duration_T& getBoardTime () const { - return _boardTime; + /** Get the boarding time. */ + const Duration_T& getBoardingTime () const { + return _boardingTime; } /** Get the off date. */ @@ -89,17 +89,27 @@ return _distance; } - /** Get the date off set (off date - board date). */ + /** Get the date off set (off date - boarding date). */ const DateOffSet_T getDateOffSet () const { - return _offDate - _boardDate; + return _offDate - _boardingDate; } - /** Get the time off set between board and off points. + /** Get the time off set between boarding and off points. <br>It is defined as being: - TimeOffSet = (OffTime - BoardTime) + (OffDate - BoardDate) * 24 + TimeOffSet = (OffTime - BoardingTime) + (OffDate - BoardingDate) * 24 - ElapsedTime. */ const Duration_T getTimeOffSet() const; + /** Get the flight number of the segment. */ + const FlightNumber_T& getFlightNumber () const { + return _key.getFlightNumber(); + } + + /** Get the airline code of the segment. */ + const AirlineCode_T& getAirlineCode () const { + return _key.getAirlineCode(); + } + public: // ///////// Setters ////////// /** Set the revenue amount. */ @@ -107,14 +117,14 @@ _segmentRevenue = iSegmentRevenue; } - /** Set the board date. */ - void setBoardDate (const Date_T& iBoardDate) { - _boardDate = iBoardDate; + /** Set the boarding date. */ + void setBoardingDate (const Date_T& iBoardingDate) { + _boardingDate = iBoardingDate; } - /** Set the board time. */ - void setBoardTime (const Duration_T& iBoardTime) { - _boardTime = iBoardTime; + /** Set the boarding time. */ + void setBoardingTime (const Duration_T& iBoardingTime) { + _boardingTime = iBoardingTime; } /** Set the off date. */ @@ -208,11 +218,11 @@ /** Value of the Revenue Passanger Kilometer for this segment date.*/ Distance_T _segmentRPK; - /** Board Date. */ - Date_T _boardDate; + /** Boarding Date. */ + Date_T _boardingDate; - /** Board Time. */ - Duration_T _boardTime; + /** Boarding Time. */ + Duration_T _boardingTime; /** Off Date. */ Date_T _offDate; Modified: trunk/stdair/stdair/bom/SegmentDateKey.cpp =================================================================== --- trunk/stdair/stdair/bom/SegmentDateKey.cpp 2010-01-06 18:13:55 UTC (rev 89) +++ trunk/stdair/stdair/bom/SegmentDateKey.cpp 2010-01-07 15:53:41 UTC (rev 90) @@ -7,15 +7,15 @@ namespace stdair { // //////////////////////////////////////////////////////////////////// - SegmentDateKey_T::SegmentDateKey_T (const AirportCode_T& iBoardPoint, + SegmentDateKey_T::SegmentDateKey_T (const AirportCode_T& iBoardingPoint, const AirportCode_T& iOffPoint) - : _boardPoint (iBoardPoint), _offPoint (iOffPoint) { + : _boardingPoint (iBoardingPoint), _offPoint (iOffPoint) { } // //////////////////////////////////////////////////////////////////// SegmentDateKey_T::SegmentDateKey_T (const SegmentDateKey_T& iKey) : _parentKey (iKey._parentKey), - _boardPoint (iKey._boardPoint), _offPoint (iKey._offPoint) { + _boardingPoint (iKey._boardingPoint), _offPoint (iKey._offPoint) { } // //////////////////////////////////////////////////////////////////// @@ -34,7 +34,7 @@ // //////////////////////////////////////////////////////////////////// const std::string SegmentDateKey_T::toString() const { std::ostringstream oStr; - oStr << _boardPoint << "-" << _offPoint; + oStr << _boardingPoint << "-" << _offPoint; return oStr.str(); } Modified: trunk/stdair/stdair/bom/SegmentDateKey.hpp =================================================================== --- trunk/stdair/stdair/bom/SegmentDateKey.hpp 2010-01-06 18:13:55 UTC (rev 89) +++ trunk/stdair/stdair/bom/SegmentDateKey.hpp 2010-01-07 15:53:41 UTC (rev 90) @@ -33,9 +33,9 @@ ~SegmentDateKey_T (); // /////////// Getters ////////// - /** Get the boarding point. */ - const AirportCode_T& getBoardPoint() const { - return _boardPoint; + /** Get the boardinging point. */ + const AirportCode_T& getBoardingPoint() const { + return _boardingPoint; } /** Get the arrival point. */ @@ -43,6 +43,16 @@ return _offPoint; } + /** Get the flight number. */ + const FlightNumber_T& getFlightNumber() const { + return _parentKey.getFlightNumber(); + } + + /** Get the airline code of the segment. */ + const AirlineCode_T& getAirlineCode () const { + return _parentKey.getAirlineCode(); + } + // /////////// Setters ///////////// void setParentKey (const ParentKey_T& iParentKey) { _parentKey = iParentKey; @@ -72,8 +82,8 @@ /** Flight-date Key.*/ ParentKey_T _parentKey; - /** Boarding airport. */ - AirportCode_T _boardPoint; + /** Boardinging airport. */ + AirportCode_T _boardingPoint; /** Arrival airport. */ AirportCode_T _offPoint; Modified: trunk/stdair/stdair/factory/FacBomContent.hpp =================================================================== --- trunk/stdair/stdair/factory/FacBomContent.hpp 2010-01-06 18:13:55 UTC (rev 89) +++ trunk/stdair/stdair/factory/FacBomContent.hpp 2010-01-07 15:53:41 UTC (rev 90) @@ -45,7 +45,7 @@ <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::BomKey_T& ioKey) { + BOM_CONTENT_CHILD& create(const typename BOM_CONTENT_CHILD::BomKey_T& ioKey){ // Create the child structure object for the given key BOM_CONTENT_CHILD& lBomContentChild = @@ -128,6 +128,48 @@ (iBomRoot._bomRootStructure); } + /** Link a segment-date with an outbound path. */ + template <typename OUTBOUND_PATH> + static void addSegmentDateIntoOutboundPath + (OUTBOUND_PATH& ioOutboundPath, + const typename OUTBOUND_PATH::SegmentDateContent_T& iSegmentDate) { + + // Forward the job to FacBomStructure. + FacBomStructure:: + addSegmentDateIntoOutboundPath<typename OUTBOUND_PATH::BomStructure_T> + (ioOutboundPath._outboundPathStructure, + iSegmentDate._segmentDateStructure); + + // Increment the total flight time of the outbound path + const Duration_T lElapsed = iSegmentDate.getElapsedTime(); + ioOutboundPath.incrementTotalFlightTime (lElapsed); + // Increment the flight path code + std::ostringstream ostr; + FlightPathCode_T lPreviousFPCode = + ioOutboundPath.getCurrentFlightPathCode(); + ostr << lPreviousFPCode + << iSegmentDate.getFlightNumber(); + ioOutboundPath.setFlightPathCode(ostr.str()); + } + + /** Clone the links, existing between a reference OutboundPath and its + SegmentDate objects, to another OutboundPath. + @param OutboundPath& + @param const OutboundPath& The reference OutboundPath object. + @exception FacExceptionNullPointer + @exception FacException.*/ + template <typename OUTBOUND_PATH> + static void cloneSegmentDateLinks (OUTBOUND_PATH& ioOutboundPath, + const OUTBOUND_PATH& iReferenceOutboundPath) { + // Clone the list of SegmentDate pointers. + ioOutboundPath._outboundPathStructure._segmentDateHolder = + iReferenceOutboundPath._outboundPathStructure._segmentDateHolder; + + // Clone the flight path + ioOutboundPath._flightPathCode = + iReferenceOutboundPath._flightPathCode; + } + 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 2010-01-06 18:13:55 UTC (rev 89) +++ trunk/stdair/stdair/factory/FacBomStructure.hpp 2010-01-07 15:53:41 UTC (rev 90) @@ -137,7 +137,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 addFullBomObjectToBomHolder (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. @@ -208,7 +208,6 @@ // booking class holder directly in inventory or flight-date, ect. // ////////////////////////////////////////////////////////////////// private: - // ///////////////////////////////////////////////////////////////// template <typename BOM_ROOT_STRUCTURE> static void createDirectAccesses (BOM_ROOT_STRUCTURE& ioBomRootStructure) { @@ -332,8 +331,8 @@ const SEGMENT_DATE_KEY_T& lSegmentDateKey = lCurrentSegmentDate_ptr->getKey(); - const AirportCode_T& lBoardPoint = lSegmentDateKey.getBoardPoint(); - AirportCode_T currentBoardPoint = lBoardPoint; + const AirportCode_T& lBoardingPoint = lSegmentDateKey.getBoardingPoint(); + AirportCode_T currentBoardingPoint = lBoardingPoint; const AirportCode_T& lOffPoint = lSegmentDateKey.getOffPoint(); // Add a sanity check so as to ensure that the loop stops. If @@ -342,14 +341,14 @@ // segments are derived from the legs thanks to the // FlightPeriodStruct::buildSegments() method). unsigned short i = 1; - while (currentBoardPoint != lOffPoint + while (currentBoardingPoint != lOffPoint && i <= MAXIMUM_NUMBER_OF_LEGS_IN_FLIGHT) { - // Retrieve the (unique) LegDate getting that Board Point + // Retrieve the (unique) LegDate getting that Boarding Point const LEG_DATE_HOLDER_T& lLegDateHolder = ioFlightDateStructure.getSecondChildrenHolder(); const LEG_DATE_STRUCTURE_MAP_T& lLegDateMap = lLegDateHolder._bomChildrenMap; typename LEG_DATE_STRUCTURE_MAP_T::const_iterator itLegDate = - lLegDateMap.find (currentBoardPoint); + lLegDateMap.find (currentBoardingPoint); assert (itLegDate != lLegDateMap.end()); LEG_DATE_STRUCTURE_T* lLegDateStructure_ptr = itLegDate->second; assert (lLegDateStructure_ptr != NULL); @@ -361,7 +360,7 @@ const typename LEG_DATE_STRUCTURE_T::Content_T* lLegDateContent_ptr = lLegDateStructure_ptr->_content; assert (lLegDateContent_ptr != NULL); - currentBoardPoint = lLegDateContent_ptr->getOffPoint(); + currentBoardingPoint = lLegDateContent_ptr->getOffPoint(); ++i; } assert (i <= MAXIMUM_NUMBER_OF_LEGS_IN_FLIGHT); @@ -369,7 +368,7 @@ } // 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). + // its routing legs (e.g., boarding and off dates). createDirectAccessesWithinSegmentDate<SEGMENT_DATE_STRUCTURE_T> (*lCurrentSegmentDate_ptr); } } @@ -499,11 +498,11 @@ assert (lBookingClassStructure_ptr != NULL); bool addingSucceeded = - addFullBomObjecdToBomHolder<BOOKING_CLASS_T> (lFDBookingClassHolder, + addFullBomObjectToBomHolder<BOOKING_CLASS_T> (lFDBookingClassHolder, *lBookingClassStructure_ptr); assert (addingSucceeded == true); addingSucceeded = - addFullBomObjecdToBomHolder<BOOKING_CLASS_T> (lInvBookingClassHolder, + addFullBomObjectToBomHolder<BOOKING_CLASS_T> (lInvBookingClassHolder, *lBookingClassStructure_ptr); assert (addingSucceeded == true); } @@ -577,6 +576,33 @@ assert (addingSucceeded == true); } + /** Link a segment-date with an outbound path. */ + template <typename OUTBOUND_PATH_STRUCTURE> + static void addSegmentDateIntoOutboundPath + (OUTBOUND_PATH_STRUCTURE& ioOutboundPathStructure, + typename OUTBOUND_PATH_STRUCTURE::SegmentDate_T::BomStructure_T& ioSegmentDateStructure) { + + // Retrieve the segment-date type. + typedef typename OUTBOUND_PATH_STRUCTURE::SegmentDate_T SEGMENT_DATE_T; + typedef typename OUTBOUND_PATH_STRUCTURE::SegmentDate_T::BomStructure_T SEGMENT_DATE_STRUCTURE_T; + // Define the bom holder of segment-dates. + typedef BomChildrenHolderImp<SEGMENT_DATE_T> SEGMENT_DATE_HOLDER_T; + + // Check if it is necessary to initialize the SegmentDate holder. + if (boost::is_same<SEGMENT_DATE_T, BomStopContent>::value == false + && ioOutboundPathStructure._segmentDateHolder == NULL) { + // Initialize the segment-date holder within the outbound path. + SEGMENT_DATE_HOLDER_T& lSegmentDateHolder = + FacBomStructure::instance().createBomHolder<SEGMENT_DATE_T>(); + ioOutboundPathStructure.setSegmentDateHolder(lSegmentDateHolder); + } + assert (ioOutboundPathStructure._segmentDateHolder != NULL); + bool addingSucceeded = + addFullBomObjectToBomHolder<SEGMENT_DATE_T> (*ioOutboundPathStructure._segmentDateHolder, ioSegmentDateStructure); + assert (addingSucceeded == true); + } + // ////////////////////////////////////////////////////////////////// + private: /** The unique instance.*/ static FacBomStructure* _instance; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |