From: <qua...@us...> - 2010-01-06 18:14:02
|
Revision: 89 http://stdair.svn.sourceforge.net/stdair/?rev=89&view=rev Author: quannaus Date: 2010-01-06 18:13:55 +0000 (Wed, 06 Jan 2010) Log Message: ----------- [Dev] Fixed some bugs. Modified Paths: -------------- trunk/stdair/stdair/basic/BasConst.cpp trunk/stdair/stdair/basic/BasConst_TravelSolution.hpp trunk/stdair/stdair/bom/AirportDate.cpp trunk/stdair/stdair/bom/AirportDateKey.cpp trunk/stdair/stdair/bom/AirportDateKey.hpp trunk/stdair/stdair/bom/Network.hpp trunk/stdair/stdair/bom/NetworkDateKey.cpp trunk/stdair/stdair/bom/NetworkDateKey.hpp trunk/stdair/stdair/bom/OutboundPathContent.cpp trunk/stdair/stdair/bom/OutboundPathContent.hpp trunk/stdair/stdair/bom/OutboundPathKey.cpp trunk/stdair/stdair/bom/OutboundPathKey.hpp Modified: trunk/stdair/stdair/basic/BasConst.cpp =================================================================== --- trunk/stdair/stdair/basic/BasConst.cpp 2010-01-06 16:53:49 UTC (rev 88) +++ trunk/stdair/stdair/basic/BasConst.cpp 2010-01-06 18:13:55 UTC (rev 89) @@ -10,6 +10,7 @@ #include <stdair/basic/BasConst_BookingClass.hpp> #include <stdair/basic/BasConst_Yield.hpp> #include <stdair/basic/BasConst_Period_BOM.hpp> +#include <stdair/basic/BasConst_TravelSolution.hpp> namespace stdair { Modified: trunk/stdair/stdair/basic/BasConst_TravelSolution.hpp =================================================================== --- trunk/stdair/stdair/basic/BasConst_TravelSolution.hpp 2010-01-06 16:53:49 UTC (rev 88) +++ trunk/stdair/stdair/basic/BasConst_TravelSolution.hpp 2010-01-06 18:13:55 UTC (rev 89) @@ -5,7 +5,7 @@ // Import section // ////////////////////////////////////////////////////////////////////// // LATUS Common -#include <stdair/basic/BasComTypes.hpp> +#include <stdair/STDAIR_Types.hpp> namespace stdair { Modified: trunk/stdair/stdair/bom/AirportDate.cpp =================================================================== --- trunk/stdair/stdair/bom/AirportDate.cpp 2010-01-06 16:53:49 UTC (rev 88) +++ trunk/stdair/stdair/bom/AirportDate.cpp 2010-01-06 18:13:55 UTC (rev 89) @@ -63,12 +63,6 @@ OutboundPathMap_T AirportDate::getOutboundPathMap () const { return _airportDateStructure.getChildrenHolder(); } - - // //////////////////////////////////////////////////////////////////// - OutboundPath* AirportDate:: - getOutboundPath (const OutboundPathKey_T& iKey) const { - return _airportDateStructure.getContentChild (iKey); - } } Modified: trunk/stdair/stdair/bom/AirportDateKey.cpp =================================================================== --- trunk/stdair/stdair/bom/AirportDateKey.cpp 2010-01-06 16:53:49 UTC (rev 88) +++ trunk/stdair/stdair/bom/AirportDateKey.cpp 2010-01-06 18:13:55 UTC (rev 89) @@ -16,6 +16,11 @@ } // //////////////////////////////////////////////////////////////////// + AirportDateKey_T::AirportDateKey_T (const AirportDateKey_T& iKey) + : _origin (iKey._origin) { + } + + // //////////////////////////////////////////////////////////////////// AirportDateKey_T::~AirportDateKey_T () { } Modified: trunk/stdair/stdair/bom/AirportDateKey.hpp =================================================================== --- trunk/stdair/stdair/bom/AirportDateKey.hpp 2010-01-06 16:53:49 UTC (rev 88) +++ trunk/stdair/stdair/bom/AirportDateKey.hpp 2010-01-06 18:13:55 UTC (rev 89) @@ -21,7 +21,7 @@ private: // /////////// Default constructor ////////// - AirportDateKey_T () { }; + AirportDateKey_T (); public: // /////////// Construction /////////// Modified: trunk/stdair/stdair/bom/Network.hpp =================================================================== --- trunk/stdair/stdair/bom/Network.hpp 2010-01-06 16:53:49 UTC (rev 88) +++ trunk/stdair/stdair/bom/Network.hpp 2010-01-06 18:13:55 UTC (rev 89) @@ -40,9 +40,6 @@ /** Definition allowing to retrieve the associated BOM content child type. */ typedef NetworkDate ContentChild_T; - - /** Definition allowing to retrieve the specific BookingClass type. */ - typedef BookingClass BookingClassContent_T; // ///////////////////////////////////////////////////////////////////////// public: Modified: trunk/stdair/stdair/bom/NetworkDateKey.cpp =================================================================== --- trunk/stdair/stdair/bom/NetworkDateKey.cpp 2010-01-06 16:53:49 UTC (rev 88) +++ trunk/stdair/stdair/bom/NetworkDateKey.cpp 2010-01-06 18:13:55 UTC (rev 89) @@ -17,6 +17,11 @@ } // //////////////////////////////////////////////////////////////////// + NetworkDateKey_T::NetworkDateKey_T (const NetworkDateKey_T& iKey) + : _referenceDate (iKey._referenceDate) { + } + + // //////////////////////////////////////////////////////////////////// NetworkDateKey_T::~NetworkDateKey_T () { } Modified: trunk/stdair/stdair/bom/NetworkDateKey.hpp =================================================================== --- trunk/stdair/stdair/bom/NetworkDateKey.hpp 2010-01-06 16:53:49 UTC (rev 88) +++ trunk/stdair/stdair/bom/NetworkDateKey.hpp 2010-01-06 18:13:55 UTC (rev 89) @@ -21,7 +21,7 @@ private: // /////////// Default constructor ////////// - NetworkDateKey_T () { }; + NetworkDateKey_T (); public: // /////////// Construction /////////// Modified: trunk/stdair/stdair/bom/OutboundPathContent.cpp =================================================================== --- trunk/stdair/stdair/bom/OutboundPathContent.cpp 2010-01-06 16:53:49 UTC (rev 88) +++ trunk/stdair/stdair/bom/OutboundPathContent.cpp 2010-01-06 18:13:55 UTC (rev 89) @@ -10,10 +10,10 @@ namespace stdair { // //////////////////////////////////////////////////////////////////// - OutboundPath::OutboundPath (const OutboundPathKey_T& iKey) + OutboundPathContent::OutboundPathContent (const OutboundPathKey_T& iKey) : _key (iKey), _airlineCode (DEFAULT_AIRLINE_CODE), _flightPathCode (DEFAULT_FLIGHTPATH_CODE), - _boardTime (NULL_BOOST_TIME_DURATION) { + _flightTime (NULL_BOOST_TIME_DURATION) { } // //////////////////////////////////////////////////////////////////// Modified: trunk/stdair/stdair/bom/OutboundPathContent.hpp =================================================================== --- trunk/stdair/stdair/bom/OutboundPathContent.hpp 2010-01-06 16:53:49 UTC (rev 88) +++ trunk/stdair/stdair/bom/OutboundPathContent.hpp 2010-01-06 18:13:55 UTC (rev 89) @@ -45,22 +45,22 @@ /** Get the number of segments (part of the primary key). */ const NbOfSegments_T& getNbOfSegments() const { - return _key._nbOfSegments; + return _key.getNbOfSegments(); } /** Get the destination (part of the primary key). */ const AirportCode_T& getDestination() const { - return _key._destination; + return _key.getOffPoint(); } /** Get the elapsed time (part of the primary key). */ const Duration_T& getElapsedTime() const { - return _key._elapsed; + return _key.getElapsedTime(); } /** Get the number of airlines (part of the primary key). */ const NbOfAirlines_T& getNbOfAirlines() const { - return _key._nbOfAirlines; + return _key.getNbOfAirlines(); } public: Modified: trunk/stdair/stdair/bom/OutboundPathKey.cpp =================================================================== --- trunk/stdair/stdair/bom/OutboundPathKey.cpp 2010-01-06 16:53:49 UTC (rev 88) +++ trunk/stdair/stdair/bom/OutboundPathKey.cpp 2010-01-06 18:13:55 UTC (rev 89) @@ -12,10 +12,10 @@ const Duration_T& iElapsedTime, const NbOfSegments_T& iNbOfSegments, const NbOfAirlines_T& iNbOfAirlines) - : destination (iDestination), - elapsed (iElapsedTime), - nbOfSegments (iNbOfSegments), - nbOfAirlines (iNbOfAirlines) { + : _destination (iDestination), + _elapsed (iElapsedTime), + _nbOfSegments (iNbOfSegments), + _nbOfAirlines (iNbOfAirlines) { } // //////////////////////////////////////////////////////////////////// @@ -34,7 +34,8 @@ // //////////////////////////////////////////////////////////////////// const std::string OutboundPathKey_T::toString() const { std::ostringstream oStr; - oStr << _classCode; + oStr << _destination << ", " << _elapsed << ", " + << _nbOfSegments << ", " << _nbOfAirlines; return oStr.str(); } @@ -47,12 +48,12 @@ // ////////////////////////////////////////////////////////////////////// const AirportCode_T& OutboundPathKey_T::getBoardingPoint() const { - return _parentKey.getBoardPoint(); + return _parentKey.getBoardingPoint(); } // ////////////////////////////////////////////////////////////////////// const Date_T& OutboundPathKey_T::getBoardingDate() const { - return _parentKey.getBoardDate(); + return _parentKey.getBoardingDate(); } } Modified: trunk/stdair/stdair/bom/OutboundPathKey.hpp =================================================================== --- trunk/stdair/stdair/bom/OutboundPathKey.hpp 2010-01-06 16:53:49 UTC (rev 88) +++ trunk/stdair/stdair/bom/OutboundPathKey.hpp 2010-01-06 18:13:55 UTC (rev 89) @@ -44,6 +44,11 @@ const NbOfAirlines_T& getNbOfAirlines() const { return _nbOfAirlines; } + + /** Get the elapsed time. */ + const Duration_T& getElapsedTime() const { + return _elapsed; + } /** Get boarding airport. */ const AirportCode_T& getBoardingPoint() const; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
From: <den...@us...> - 2010-01-20 20:09:43
|
Revision: 99 http://stdair.svn.sourceforge.net/stdair/?rev=99&view=rev Author: denis_arnaud Date: 2010-01-20 20:09:35 +0000 (Wed, 20 Jan 2010) Log Message: ----------- [Dev] Implemented the Logger service. Modified Paths: -------------- trunk/stdair/stdair/Makefile.am trunk/stdair/stdair/STDAIR_Types.hpp trunk/stdair/stdair/basic/sources.mk trunk/stdair/stdair/core/Makefile.am trunk/stdair/stdair/factory/FacSupervisor.cpp trunk/stdair/stdair/factory/FacSupervisor.hpp Added Paths: ----------- trunk/stdair/stdair/basic/BasFileMgr.cpp trunk/stdair/stdair/basic/BasFileMgr.hpp trunk/stdair/stdair/service/Logger.cpp trunk/stdair/stdair/service/Logger.hpp trunk/stdair/stdair/service/Makefile.am trunk/stdair/stdair/service/sources.mk Property Changed: ---------------- trunk/stdair/stdair/service/ Modified: trunk/stdair/stdair/Makefile.am =================================================================== --- trunk/stdair/stdair/Makefile.am 2010-01-20 17:07:06 UTC (rev 98) +++ trunk/stdair/stdair/Makefile.am 2010-01-20 20:09:35 UTC (rev 99) @@ -1,3 +1,4 @@ +# stdair include $(top_srcdir)/Makefile.common include $(srcdir)/core/sources.mk @@ -5,7 +6,7 @@ MAINTAINERCLEANFILES = Makefile.in -SUBDIRS = basic bom factory core config +SUBDIRS = basic bom factory config service core #EXTRA_DIST = config_msvc.h EXTRA_DIST = Modified: trunk/stdair/stdair/STDAIR_Types.hpp =================================================================== --- trunk/stdair/stdair/STDAIR_Types.hpp 2010-01-20 17:07:06 UTC (rev 98) +++ trunk/stdair/stdair/STDAIR_Types.hpp 2010-01-20 20:09:35 UTC (rev 99) @@ -7,7 +7,7 @@ // STL #include <string> #include <vector> -#include <list> +#include <map> // Boost (Extended STL) #include <boost/date_time/gregorian/gregorian.hpp> #include <boost/date_time/posix_time/posix_time.hpp> @@ -15,7 +15,7 @@ namespace stdair { - // ///////// Exceptions /////////// + // ///////// Exceptions /////////// class RootException : public std::exception { }; @@ -46,6 +46,9 @@ VERBOSE, LAST_VALUE } EN_LogLevel; + + static const std::string _logLevels[LAST_VALUE] = + {"C", "E", "N", "W", "D", "V"}; } // //////// Type definitions ///////// Added: trunk/stdair/stdair/basic/BasFileMgr.cpp =================================================================== --- trunk/stdair/stdair/basic/BasFileMgr.cpp (rev 0) +++ trunk/stdair/stdair/basic/BasFileMgr.cpp 2010-01-20 20:09:35 UTC (rev 99) @@ -0,0 +1,29 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +// Boost (STL Extension) +// Boost Filesystem (http://www.boost.org/doc/libs/1_41_0/libs/filesystem/doc/index.htm) +#include <boost/filesystem.hpp> +// StdAir +#include <stdair/basic/BasFileMgr.hpp> + +namespace boostfs = boost::filesystem; + +namespace stdair { + + // ////////////////////////////////////////////////////////////////////// + bool BasFileMgr::doesExistAndIsReadable (const std::string& iFilepath) { + bool oFine = false; + + boostfs::path lPath (iFilepath); + + if (boostfs::exists (lPath) == true && boostfs::is_regular (lPath) == true) { + oFine = true; + } + + return true; + } + +} Added: trunk/stdair/stdair/basic/BasFileMgr.hpp =================================================================== --- trunk/stdair/stdair/basic/BasFileMgr.hpp (rev 0) +++ trunk/stdair/stdair/basic/BasFileMgr.hpp 2010-01-20 20:09:35 UTC (rev 99) @@ -0,0 +1,22 @@ +#ifndef __STDAIR_BAS_BASFILEMGR_HPP +#define __STDAIR_BAS_BASFILEMGR_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <string> + +namespace stdair { + + /** Helper class for operations on files and on the file-system. */ + struct BasFileMgr { + public: + + // //////////// Functional Support Methods //////////// + static bool doesExistAndIsReadable (const std::string& iFilepath); + + }; + +} +#endif // __STDAIR_BAS_BASFILEMGR_HPP Modified: trunk/stdair/stdair/basic/sources.mk =================================================================== --- trunk/stdair/stdair/basic/sources.mk 2010-01-20 17:07:06 UTC (rev 98) +++ trunk/stdair/stdair/basic/sources.mk 2010-01-20 20:09:35 UTC (rev 99) @@ -6,7 +6,9 @@ $(top_srcdir)/stdair/basic/BasConst_Yield.hpp \ $(top_srcdir)/stdair/basic/BasConst_Period_BOM.hpp \ $(top_srcdir)/stdair/basic/BasConst_TravelSolution.hpp \ - $(top_srcdir)/stdair/basic/BasChronometer.hpp + $(top_srcdir)/stdair/basic/BasChronometer.hpp \ + $(top_srcdir)/stdair/basic/BasFileMgr.hpp bas_cc_sources = \ $(top_srcdir)/stdair/basic/BasConst.cpp \ - $(top_srcdir)/stdair/basic/BasChronometer.cpp + $(top_srcdir)/stdair/basic/BasChronometer.cpp \ + $(top_srcdir)/stdair/basic/BasFileMgr.cpp Modified: trunk/stdair/stdair/core/Makefile.am =================================================================== --- trunk/stdair/stdair/core/Makefile.am 2010-01-20 17:07:06 UTC (rev 98) +++ trunk/stdair/stdair/core/Makefile.am 2010-01-20 20:09:35 UTC (rev 99) @@ -1,3 +1,4 @@ +# core include $(top_srcdir)/Makefile.common include $(srcdir)/sources.mk @@ -15,6 +16,8 @@ libstdair_la_LIBADD = \ $(top_builddir)/stdair/basic/libbas.la \ $(top_builddir)/stdair/bom/libbom.la \ - $(top_builddir)/stdair/factory/libfac.la + $(top_builddir)/stdair/factory/libfac.la \ + $(top_builddir)/stdair/service/libsvc.la libstdair_la_LDFLAGS = \ - $(BOOST_DATE_TIME_LIB) -version-info $(GENERIC_LIBRARY_VERSION) + $(BOOST_DATE_TIME_LIB) $(BOOST_PROGRAM_OPTIONS_LIB) $(BOOST_FILESYSTEM_LIB) \ + -version-info $(GENERIC_LIBRARY_VERSION) Modified: trunk/stdair/stdair/factory/FacSupervisor.cpp =================================================================== --- trunk/stdair/stdair/factory/FacSupervisor.cpp 2010-01-20 17:07:06 UTC (rev 98) +++ trunk/stdair/stdair/factory/FacSupervisor.cpp 2010-01-20 20:09:35 UTC (rev 99) @@ -1,12 +1,14 @@ // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// -// C -#include <assert.h> -// STDAIR +// STL +#include <cassert> +#include <ostream> +// StdAir #include <stdair/factory/FacBomStructure.hpp> #include <stdair/factory/FacBomContent.hpp> #include <stdair/factory/FacSupervisor.hpp> +#include <stdair/service/Logger.hpp> namespace stdair { @@ -70,10 +72,16 @@ } // ////////////////////////////////////////////////////////////////////// + void FacSupervisor::cleanLoggerService() { + Logger::clean(); + } + + // ////////////////////////////////////////////////////////////////////// void FacSupervisor::cleanFactory () { if (_instance != NULL) { - _instance->cleanBomStructureLayer(); - _instance->cleanBomContentLayer(); + _instance->cleanBomStructureLayer(); + _instance->cleanBomContentLayer(); + _instance->cleanLoggerService(); } delete _instance; _instance = NULL; } Modified: trunk/stdair/stdair/factory/FacSupervisor.hpp =================================================================== --- trunk/stdair/stdair/factory/FacSupervisor.hpp 2010-01-20 17:07:06 UTC (rev 98) +++ trunk/stdair/stdair/factory/FacSupervisor.hpp 2010-01-20 20:09:35 UTC (rev 99) @@ -5,7 +5,10 @@ // Import section // ////////////////////////////////////////////////////////////////////// // STL +#include <iosfwd> #include <vector> +// StdAir +#include <stdair/STDAIR_Types.hpp> namespace stdair { @@ -48,6 +51,9 @@ for the BomContent layer. */ void cleanBomContentLayer(); + /** Delete the Logger object. */ + void cleanLoggerService(); + /** Clean the static instance. <br> The singleton is deleted.*/ static void cleanFactory (); Property changes on: trunk/stdair/stdair/service ___________________________________________________________________ Added: svn:ignore + .deps .libs Makefile Makefile.in Added: trunk/stdair/stdair/service/Logger.cpp =================================================================== --- trunk/stdair/stdair/service/Logger.cpp (rev 0) +++ trunk/stdair/stdair/service/Logger.cpp 2010-01-20 20:09:35 UTC (rev 99) @@ -0,0 +1,64 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// Stdair Logger +#include <stdair/factory/FacSupervisor.hpp> +#include <stdair/service/Logger.hpp> + +namespace stdair { + + Logger* Logger::_instance = NULL; + + // ////////////////////////////////////////////////////////////////////// + Logger::Logger () : _logStream (&std::cout) { + assert (false); + } + + // ////////////////////////////////////////////////////////////////////// + Logger::Logger (const Logger&) : _logStream (&std::cout) { + assert (false); + } + + // ////////////////////////////////////////////////////////////////////// + Logger::Logger (const LOG::EN_LogLevel iLevel, std::ostream& ioLogStream) + : _level (iLevel), _logStream (&ioLogStream) { + } + + // ////////////////////////////////////////////////////////////////////// + Logger::~Logger () { + _logStream = NULL; + } + + // ////////////////////////////////////////////////////////////////////// + void Logger::clean() { + delete _instance; _instance = NULL; + } + + // ////////////////////////////////////////////////////////////////////// + LOG::EN_LogLevel Logger::getLogLevel() { + return _level; + } + + // ////////////////////////////////////////////////////////////////////// + std::ostream& Logger::getLogStream() { + assert (_logStream != NULL); + return *_logStream; + } + + // ////////////////////////////////////////////////////////////////////// + void Logger::setLogParameters (const LOG::EN_LogLevel iLogLevel, + std::ostream& ioLogStream) { + _level = iLogLevel; + _logStream = &ioLogStream; + } + + // ////////////////////////////////////////////////////////////////////// + Logger& Logger::instance() { + if (_instance == NULL) { + _instance = new Logger (LOG::DEBUG, std::cout); + } + assert (_instance != NULL); + return *_instance; + } + +} Added: trunk/stdair/stdair/service/Logger.hpp =================================================================== --- trunk/stdair/stdair/service/Logger.hpp (rev 0) +++ trunk/stdair/stdair/service/Logger.hpp 2010-01-20 20:09:35 UTC (rev 99) @@ -0,0 +1,100 @@ +#ifndef __STDAIR_SVC_LOGGER_HPP +#define __STDAIR_SVC_LOGGER_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +#include <iostream> +#include <sstream> +#include <string> +// STDAIR +#include <stdair/STDAIR_Types.hpp> + +// /////////////// LOG MACROS ///////////////// +#define STDAIR_LOG_CORE(iLevel, iToBeLogged) \ + { std::ostringstream ostr; ostr << iToBeLogged; \ + stdair::Logger::instance().log (iLevel, __LINE__, __FILE__, ostr.str()); } + +#define STDAIR_LOG_CRITICAL(iToBeLogged) \ + STDAIR_LOG_CORE (stdair::LOG::CRITICAL, iToBeLogged) + +#define STDAIR_LOG_ERROR(iToBeLogged) \ + STDAIR_LOG_CORE (stdair::LOG::ERROR, iToBeLogged) + +#define STDAIR_LOG_NOTIFICATION(iToBeLogged) \ + STDAIR_LOG_CORE (stdair::LOG::NOTIFICATION, iToBeLogged) + +#define STDAIR_LOG_WARNING(iToBeLogged) \ + STDAIR_LOG_CORE (stdair::LOG::WARNING, iToBeLogged) + +#define STDAIR_LOG_DEBUG(iToBeLogged) \ + STDAIR_LOG_CORE (stdair::LOG::DEBUG, iToBeLogged) + +#define STDAIR_LOG_VERBOSE(iToBeLogged) \ + STDAIR_LOG_CORE (stdair::LOG::VERBOSE, iToBeLogged) +// /////////// (END OF) LOG MACROS ///////////// + + +namespace stdair { + + /** Class holding the stream for logs. + <br>Note that the error logs are seen as standard output logs, + but with a higher level of visibility. */ + class Logger { + // Friend classes + friend class FacSupervisor; + public: + + /** Main log entry. */ + template <typename T> + void log (const LOG::EN_LogLevel iLevel, const int iLineNumber, + const std::string& iFileName, const T& iToBeLogged) { + if (iLevel <= _level) { + assert (_logStream != NULL); + *_logStream << "[" << LOG::_logLevels[iLevel] << "]" << iFileName << ":" + << iLineNumber << ": " << iToBeLogged << std::endl; + } + } + + /** Get the log level. */ + LOG::EN_LogLevel getLogLevel(); + + /** get the log stream. */ + std::ostream& getLogStream(); + + /** Set the logger parameters (level and stream). */ + void setLogParameters (const LOG::EN_LogLevel iLogLevel, + std::ostream& ioLogStream); + + /** Return the static Logger instance.*/ + static Logger& instance(); + + + private: + /** Default constructors are private so that only the required + constructor can be used. */ + Logger (); + Logger (const Logger&); + Logger (const LOG::EN_LogLevel iLevel, std::ostream& ioLogStream); + /** Destructor. */ + ~Logger (); + + /** Delete the static Logger instance.*/ + static void clean(); + + private: + /** Log level. */ + LOG::EN_LogLevel _level; + + /** Stream dedicated to the logs. */ + std::ostream* _logStream; + + /** Instance object.*/ + static Logger* _instance; + }; + +} +#endif // __STDAIR_SVC_LOGGER_HPP + Added: trunk/stdair/stdair/service/Makefile.am =================================================================== --- trunk/stdair/stdair/service/Makefile.am (rev 0) +++ trunk/stdair/stdair/service/Makefile.am 2010-01-20 20:09:35 UTC (rev 99) @@ -0,0 +1,11 @@ +## service sub-directory +include $(top_srcdir)/Makefile.common +include $(srcdir)/sources.mk + +noinst_LTLIBRARIES= libsvc.la + +libsvc_la_SOURCES= $(svc_h_sources) $(svc_cc_sources) +libsvc_la_CXXFLAGS = + +#pkgincludedir = $(includedir)/@PACKAGE@/service +#pkginclude_HEADERS = $(svc_h_sources) Added: trunk/stdair/stdair/service/sources.mk =================================================================== --- trunk/stdair/stdair/service/sources.mk (rev 0) +++ trunk/stdair/stdair/service/sources.mk 2010-01-20 20:09:35 UTC (rev 99) @@ -0,0 +1,2 @@ +svc_h_sources = $(top_srcdir)/stdair/service/Logger.hpp +svc_cc_sources = $(top_srcdir)/stdair/service/Logger.cpp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-01-21 13:26:18
|
Revision: 101 http://stdair.svn.sourceforge.net/stdair/?rev=101&view=rev Author: denis_arnaud Date: 2010-01-21 13:26:12 +0000 (Thu, 21 Jan 2010) Log Message: ----------- [Dev] The log output stream initialisation has been moved into the StdAir library. Modified Paths: -------------- trunk/stdair/stdair/STDAIR_Types.hpp trunk/stdair/stdair/basic/sources.mk trunk/stdair/stdair/service/Logger.cpp trunk/stdair/stdair/service/Logger.hpp Added Paths: ----------- trunk/stdair/stdair/basic/BasDBParams.cpp trunk/stdair/stdair/basic/BasDBParams.hpp trunk/stdair/stdair/basic/BasLogParams.cpp trunk/stdair/stdair/basic/BasLogParams.hpp Modified: trunk/stdair/stdair/STDAIR_Types.hpp =================================================================== --- trunk/stdair/stdair/STDAIR_Types.hpp 2010-01-20 21:33:53 UTC (rev 100) +++ trunk/stdair/stdair/STDAIR_Types.hpp 2010-01-21 13:26:12 UTC (rev 101) @@ -22,6 +22,9 @@ class FileNotFoundException : public RootException { }; + class NonInitialisedLogServiceException : public RootException { + }; + class NonInitialisedServiceException : public RootException { }; Added: trunk/stdair/stdair/basic/BasDBParams.cpp =================================================================== --- trunk/stdair/stdair/basic/BasDBParams.cpp (rev 0) +++ trunk/stdair/stdair/basic/BasDBParams.cpp 2010-01-21 13:26:12 UTC (rev 101) @@ -0,0 +1,61 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +#include <istream> +#include <ostream> +#include <sstream> +// StdAir +#include <stdair/basic/BasDBParams.hpp> + +namespace stdair { + + // ////////////////////////////////////////////////////////////////////// + BasDBParams::BasDBParams (const std::string& iDBUser, + const std::string& iDBPasswd, + const std::string& iDBHost, + const std::string& iDBPort, + const std::string& iDBName) + : _user (iDBUser), _passwd (iDBPasswd), _host (iDBHost), _port (iDBPort), + _dbname (iDBName) { + } + + // ////////////////////////////////////////////////////////////////////// + BasDBParams::~BasDBParams() { + } + + // ////////////////////////////////////////////////////////////////////// + void BasDBParams::toStream (std::ostream& ioOut) const { + ioOut << toString(); + } + + // ////////////////////////////////////////////////////////////////////// + void BasDBParams::fromStream (std::istream&) { + } + + // ////////////////////////////////////////////////////////////////////// + std::string BasDBParams::toShortString() const { + std::ostringstream oStr; + oStr << _dbname << "." << _user << "@" << _host << ":" << _port; + return oStr.str(); + } + + // ////////////////////////////////////////////////////////////////////// + std::string BasDBParams::toString() const { + std::ostringstream oStr; + oStr << _dbname << "." << _user << "@" << _host << ":" << _port; + return oStr.str(); + } + + // ////////////////////////////////////////////////////////////////////// + bool BasDBParams::check () const { + if (_user.empty() == true || _passwd.empty() == true + || _host.empty() == true || _port.empty() + || _dbname.empty() == true) { + return false; + } + return true; + } + +} Added: trunk/stdair/stdair/basic/BasDBParams.hpp =================================================================== --- trunk/stdair/stdair/basic/BasDBParams.hpp (rev 0) +++ trunk/stdair/stdair/basic/BasDBParams.hpp 2010-01-21 13:26:12 UTC (rev 101) @@ -0,0 +1,125 @@ +#ifndef __STDAIR_BAS_BASDBPARAMS_HPP +#define __STDAIR_BAS_BASDBPARAMS_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <iosfwd> +#include <string> +// Stdair +#include <stdair/STDAIR_Types.hpp> + +namespace stdair { + + /** Structure holding the parameters for connection to a database. */ + struct BasDBParams { + public: + // ///////// Getters //////// + /** Get the database user name. */ + std::string getUser() const { + return _user; + } + + /** Get the database user password. */ + std::string getPassword() const { + return _passwd; + } + + /** Get the database host name. */ + std::string getHost() const { + return _host; + } + + /** Get the database port number. */ + std::string getPort() const { + return _port; + } + + /** Get the database name. */ + std::string getDBName() const { + return _dbname; + } + + + // ///////// Setters ////////// + /** Set the database user name. */ + void setUser (const std::string& iUser) { + _user = iUser; + } + + /** Set the database password. */ + void setPassword (const std::string& iPasswd) { + _passwd = iPasswd; + } + + /** Set the database host name. */ + void setHost (const std::string& iHost) { + _host = iHost; + } + + /** Set the database port number. */ + void setPort (const std::string& iPort) { + _port = iPort; + } + + /** Set the database name. */ + void setDBName (const std::string& iDBName) { + _dbname = iDBName; + } + + + public: + // ///////// Busines methods //////// + /** Check that all the parameters are fine. */ + bool check () const; + + + public: + // ///////// Display methods //////// + /** Dump a structure into an output stream. + @param ostream& the output stream. */ + void toStream (std::ostream& ioOut) const; + + /** Read a structure from an input stream. + @param istream& the input stream. */ + void fromStream (std::istream&); + + /** Get a short display of the DBParams structure. */ + std::string toShortString() const; + + /** Get the serialised version of the DBParams structure. */ + std::string toString() const; + + + public: + /** Main Constructor. */ + BasDBParams (const std::string& iDBUser, const std::string& iDBPasswd, + const std::string& iDBHost, const std::string& iDBPort, + const std::string& iDBName); + + /** Default Constructor. */ + // BasDBParams (); + /** Default copy constructor. */ + // BasDBParams (const BasDBParams&); + + /** Destructor. */ + ~BasDBParams(); + + + private: + // /////// Attributes ///////// + /** Database user name. */ + std::string _user; + /** Database user password. */ + std::string _passwd; + /** Database host name. */ + std::string _host; + /** Database port number. */ + std::string _port; + /** Database name. */ + std::string _dbname; + }; + +} +#endif // __STDAIR_BAS_BASDBPARAMS_HPP Added: trunk/stdair/stdair/basic/BasLogParams.cpp =================================================================== --- trunk/stdair/stdair/basic/BasLogParams.cpp (rev 0) +++ trunk/stdair/stdair/basic/BasLogParams.cpp 2010-01-21 13:26:12 UTC (rev 101) @@ -0,0 +1,47 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +#include <istream> +#include <ostream> +#include <sstream> +// StdAir +#include <stdair/basic/BasLogParams.hpp> + +namespace stdair { + + // ////////////////////////////////////////////////////////////////////// + BasLogParams::BasLogParams (const LOG::EN_LogLevel iLogLevel, + std::ostream& ioLogOutputStream) + : _logLevel (iLogLevel), _logStream (ioLogOutputStream) { + } + + // ////////////////////////////////////////////////////////////////////// + BasLogParams::~BasLogParams() { + } + + // ////////////////////////////////////////////////////////////////////// + void BasLogParams::toStream (std::ostream& ioOut) const { + ioOut << toString(); + } + + // ////////////////////////////////////////////////////////////////////// + void BasLogParams::fromStream (std::istream&) { + } + + // ////////////////////////////////////////////////////////////////////// + std::string BasLogParams::toShortString() const { + std::ostringstream oStr; + oStr << LOG::_logLevels[_logLevel]; + return oStr.str(); + } + + // ////////////////////////////////////////////////////////////////////// + std::string BasLogParams::toString() const { + std::ostringstream oStr; + oStr << LOG::_logLevels[_logLevel]; + return oStr.str(); + } + +} Added: trunk/stdair/stdair/basic/BasLogParams.hpp =================================================================== --- trunk/stdair/stdair/basic/BasLogParams.hpp (rev 0) +++ trunk/stdair/stdair/basic/BasLogParams.hpp 2010-01-21 13:26:12 UTC (rev 101) @@ -0,0 +1,82 @@ +#ifndef __STDAIR_BAS_BASLOGPARAMS_HPP +#define __STDAIR_BAS_BASLOGPARAMS_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <iosfwd> +#include <string> +// Stdair +#include <stdair/STDAIR_Types.hpp> + +namespace stdair { + + /** Structure holding parameters for logging. */ + struct BasLogParams { + friend class Logger; + public: + // ///////// Getters //////// + /** Get the log level. */ + const LOG::EN_LogLevel& getLogLevel() const { + return _logLevel; + } + + /** Get the log output stream. */ + std::ostream& getLogStream() const { + return _logStream; + } + + + // ///////// Setters ////////// + // No setters + + + public: + // ///////// Busines methods //////// + /** Check that all the parameters are fine. */ + bool check () const; + + + public: + // ///////// Display methods //////// + /** Dump a structure into an output stream. + @param ostream& the output stream. */ + void toStream (std::ostream& ioOut) const; + + /** Read a structure from an input stream. + @param istream& the input stream. */ + void fromStream (std::istream&); + + /** Get a short display of the LOGParams structure. */ + std::string toShortString() const; + + /** Get the serialised version of the LOGParams structure. */ + std::string toString() const; + + + public: + /** Main Constructor. */ + BasLogParams (const LOG::EN_LogLevel iLogLevel, + std::ostream& ioLogOutputStream); + + /** Default Constructor. */ + // BasLogParams (); + /** Default copy constructor. */ + // BasLogParams (const BasLogParams&); + + /** Destructor. */ + ~BasLogParams(); + + + private: + // /////// Attributes ///////// + /** Log level (e.g., LOG::DEBUG). */ + const LOG::EN_LogLevel _logLevel; + + /** Log output stream (e.g., std::cout). */ + std::ostream& _logStream; + }; + +} +#endif // __STDAIR_BAS_BASLOGPARAMS_HPP Modified: trunk/stdair/stdair/basic/sources.mk =================================================================== --- trunk/stdair/stdair/basic/sources.mk 2010-01-20 21:33:53 UTC (rev 100) +++ trunk/stdair/stdair/basic/sources.mk 2010-01-21 13:26:12 UTC (rev 101) @@ -7,8 +7,12 @@ $(top_srcdir)/stdair/basic/BasConst_Period_BOM.hpp \ $(top_srcdir)/stdair/basic/BasConst_TravelSolution.hpp \ $(top_srcdir)/stdair/basic/BasChronometer.hpp \ - $(top_srcdir)/stdair/basic/BasFileMgr.hpp + $(top_srcdir)/stdair/basic/BasFileMgr.hpp \ + $(top_srcdir)/stdair/basic/BasLogParams.hpp \ + $(top_srcdir)/stdair/basic/BasDBParams.hpp bas_cc_sources = \ $(top_srcdir)/stdair/basic/BasConst.cpp \ $(top_srcdir)/stdair/basic/BasChronometer.cpp \ - $(top_srcdir)/stdair/basic/BasFileMgr.cpp + $(top_srcdir)/stdair/basic/BasFileMgr.cpp \ + $(top_srcdir)/stdair/basic/BasLogParams.cpp \ + $(top_srcdir)/stdair/basic/BasDBParams.cpp Modified: trunk/stdair/stdair/service/Logger.cpp =================================================================== --- trunk/stdair/stdair/service/Logger.cpp 2010-01-20 21:33:53 UTC (rev 100) +++ trunk/stdair/stdair/service/Logger.cpp 2010-01-21 13:26:12 UTC (rev 101) @@ -2,63 +2,56 @@ // Import section // ////////////////////////////////////////////////////////////////////// // Stdair Logger -#include <stdair/factory/FacSupervisor.hpp> +//#include <stdair/factory/FacSupervisor.hpp> #include <stdair/service/Logger.hpp> namespace stdair { - Logger* Logger::_instance = NULL; + Logger* Logger::_instance = NULL; - // ////////////////////////////////////////////////////////////////////// - Logger::Logger () : _logStream (&std::cout) { - assert (false); - } + // ////////////////////////////////////////////////////////////////////// + Logger::Logger () : _logStream (std::cout), _level (LOG::DEBUG) { + assert (false); + } - // ////////////////////////////////////////////////////////////////////// - Logger::Logger (const Logger&) : _logStream (&std::cout) { - assert (false); - } + // ////////////////////////////////////////////////////////////////////// + Logger::Logger (const Logger&) : _logStream (std::cout), _level (LOG::DEBUG) { + assert (false); + } - // ////////////////////////////////////////////////////////////////////// - Logger::Logger (const LOG::EN_LogLevel iLevel, std::ostream& ioLogStream) - : _level (iLevel), _logStream (&ioLogStream) { - } + // ////////////////////////////////////////////////////////////////////// + Logger::Logger (const stdair::BasLogParams& iLogParams) + : _level (iLogParams._logLevel), _logStream (iLogParams._logStream) { + } - // ////////////////////////////////////////////////////////////////////// - Logger::~Logger () { - _logStream = NULL; - } + // ////////////////////////////////////////////////////////////////////// + Logger::~Logger () { + } - // ////////////////////////////////////////////////////////////////////// - void Logger::clean() { - delete _instance; _instance = NULL; - } - - // ////////////////////////////////////////////////////////////////////// - LOG::EN_LogLevel Logger::getLogLevel() { - return _level; - } + // ////////////////////////////////////////////////////////////////////// + void Logger::init (const BasLogParams& iLogParams) { + // Sanity check + if (_instance != NULL) { + STDAIR_LOG_ERROR ("Error: the log stream has already been initialised"); + // TODO: throw an exception? - // ////////////////////////////////////////////////////////////////////// - std::ostream& Logger::getLogStream() { - assert (_logStream != NULL); - return *_logStream; + } else { + _instance = new Logger (iLogParams); } + } - // ////////////////////////////////////////////////////////////////////// - void Logger::setLogParameters (const LOG::EN_LogLevel iLogLevel, - std::ostream& ioLogStream) { - _level = iLogLevel; - _logStream = &ioLogStream; + // ////////////////////////////////////////////////////////////////////// + Logger& Logger::instance() { + if (_instance == NULL) { + throw NonInitialisedLogServiceException(); } - - // ////////////////////////////////////////////////////////////////////// - Logger& Logger::instance() { - if (_instance == NULL) { - _instance = new Logger (LOG::DEBUG, std::cout); - } - assert (_instance != NULL); - return *_instance; - } - + assert (_instance != NULL); + return *_instance; + } + + // ////////////////////////////////////////////////////////////////////// + void Logger::clean() { + delete _instance; _instance = NULL; + } + } Modified: trunk/stdair/stdair/service/Logger.hpp =================================================================== --- trunk/stdair/stdair/service/Logger.hpp 2010-01-20 21:33:53 UTC (rev 100) +++ trunk/stdair/stdair/service/Logger.hpp 2010-01-21 13:26:12 UTC (rev 101) @@ -9,8 +9,9 @@ #include <iostream> #include <sstream> #include <string> -// STDAIR +// StdAir #include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/BasLogParams.hpp> // /////////////// LOG MACROS ///////////////// #define STDAIR_LOG_CORE(iLevel, iToBeLogged) \ @@ -52,32 +53,26 @@ void log (const LOG::EN_LogLevel iLevel, const int iLineNumber, const std::string& iFileName, const T& iToBeLogged) { if (iLevel <= _level) { - assert (_logStream != NULL); - *_logStream << "[" << LOG::_logLevels[iLevel] << "]" << iFileName << ":" - << iLineNumber << ": " << iToBeLogged << std::endl; + _logStream << "[" << LOG::_logLevels[iLevel] << "]" << iFileName << ":" + << iLineNumber << ": " << iToBeLogged << std::endl; } } - /** Get the log level. */ - LOG::EN_LogLevel getLogLevel(); + /** Initialise the static Logger instance. */ + static void init (const stdair::BasLogParams&); - /** get the log stream. */ - std::ostream& getLogStream(); - - /** Set the logger parameters (level and stream). */ - void setLogParameters (const LOG::EN_LogLevel iLogLevel, - std::ostream& ioLogStream); - - /** Return the static Logger instance.*/ + /** Return the static Logger instance. */ static Logger& instance(); private: /** Default constructors are private so that only the required constructor can be used. */ + Logger (const stdair::BasLogParams&); + /** Default constructor. It must not be used. */ Logger (); + /** Default copy constructor. It must not be used. */ Logger (const Logger&); - Logger (const LOG::EN_LogLevel iLevel, std::ostream& ioLogStream); /** Destructor. */ ~Logger (); @@ -85,14 +80,14 @@ static void clean(); private: + /** Instance object.*/ + static Logger* _instance; + /** Log level. */ LOG::EN_LogLevel _level; /** Stream dedicated to the logs. */ - std::ostream* _logStream; - - /** Instance object.*/ - static Logger* _instance; + std::ostream& _logStream; }; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-01-21 23:31:04
|
Revision: 103 http://stdair.svn.sourceforge.net/stdair/?rev=103&view=rev Author: denis_arnaud Date: 2010-01-21 23:30:57 +0000 (Thu, 21 Jan 2010) Log Message: ----------- [Dev] The static log service instance is now cleaned directly within the FacSupervisor::cleanFactory() method. Modified Paths: -------------- trunk/stdair/stdair/factory/FacBomContent.cpp trunk/stdair/stdair/factory/FacBomStructure.cpp trunk/stdair/stdair/factory/FacSupervisor.cpp trunk/stdair/stdair/service/Logger.cpp Modified: trunk/stdair/stdair/factory/FacBomContent.cpp =================================================================== --- trunk/stdair/stdair/factory/FacBomContent.cpp 2010-01-21 19:35:16 UTC (rev 102) +++ trunk/stdair/stdair/factory/FacBomContent.cpp 2010-01-21 23:30:57 UTC (rev 103) @@ -1,8 +1,8 @@ // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// -// C -#include <assert.h> +// STL +#include <cassert> // STDAIR #include <stdair/bom/BomStructure.hpp> #include <stdair/bom/BomContent.hpp> Modified: trunk/stdair/stdair/factory/FacBomStructure.cpp =================================================================== --- trunk/stdair/stdair/factory/FacBomStructure.cpp 2010-01-21 19:35:16 UTC (rev 102) +++ trunk/stdair/stdair/factory/FacBomStructure.cpp 2010-01-21 23:30:57 UTC (rev 103) @@ -1,9 +1,9 @@ // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// -// C -#include <assert.h> -// STDAIR +// STL +#include <cassert> +// StdAir #include <stdair/bom/BomStructure.hpp> #include <stdair/factory/FacSupervisor.hpp> #include <stdair/factory/FacBomStructure.hpp> Modified: trunk/stdair/stdair/factory/FacSupervisor.cpp =================================================================== --- trunk/stdair/stdair/factory/FacSupervisor.cpp 2010-01-21 19:35:16 UTC (rev 102) +++ trunk/stdair/stdair/factory/FacSupervisor.cpp 2010-01-21 23:30:57 UTC (rev 103) @@ -3,7 +3,6 @@ // ////////////////////////////////////////////////////////////////////// // STL #include <cassert> -#include <ostream> // StdAir #include <stdair/factory/FacBomStructure.hpp> #include <stdair/factory/FacBomContent.hpp> @@ -39,6 +38,7 @@ FacSupervisor::~FacSupervisor() { cleanBomStructureLayer(); cleanBomContentLayer(); + cleanLoggerService(); } // ////////////////////////////////////////////////////////////////////// @@ -73,16 +73,16 @@ // ////////////////////////////////////////////////////////////////////// void FacSupervisor::cleanLoggerService() { + // Clean the static instance of the log service Logger::clean(); } // ////////////////////////////////////////////////////////////////////// void FacSupervisor::cleanFactory () { - if (_instance != NULL) { - _instance->cleanBomStructureLayer(); - _instance->cleanBomContentLayer(); - _instance->cleanLoggerService(); - } + // Clean the static instance of the log service + Logger::clean(); + + // Clean the static instance of the FacSupervisor delete _instance; _instance = NULL; } Modified: trunk/stdair/stdair/service/Logger.cpp =================================================================== --- trunk/stdair/stdair/service/Logger.cpp 2010-01-21 19:35:16 UTC (rev 102) +++ trunk/stdair/stdair/service/Logger.cpp 2010-01-21 23:30:57 UTC (rev 103) @@ -26,6 +26,7 @@ // ////////////////////////////////////////////////////////////////////// Logger::~Logger () { + std::cout << "In Logger destructor" << std::endl; } // ////////////////////////////////////////////////////////////////////// @@ -33,11 +34,11 @@ // Sanity check if (_instance != NULL) { STDAIR_LOG_ERROR ("Error: the log stream has already been initialised"); - // TODO: throw an exception? + assert (false); + } + assert (_instance == NULL); - } else { - _instance = new Logger (iLogParams); - } + _instance = new Logger (iLogParams); } // ////////////////////////////////////////////////////////////////////// @@ -51,7 +52,9 @@ // ////////////////////////////////////////////////////////////////////// void Logger::clean() { + std::cout << "In Logger::clean(), before static instance deletion" << std::endl; delete _instance; _instance = NULL; + std::cout << "In Logger::clean(), after static instance deletion" << std::endl; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-01-22 19:47:36
|
Revision: 104 http://stdair.svn.sourceforge.net/stdair/?rev=104&view=rev Author: denis_arnaud Date: 2010-01-22 19:47:29 +0000 (Fri, 22 Jan 2010) Log Message: ----------- [Dev] Added a STDAIR_Service, wrapper around both the static Logger instance and the stdair::FacSupervisor one. Modified Paths: -------------- trunk/stdair/stdair/Makefile.am trunk/stdair/stdair/basic/Makefile.am trunk/stdair/stdair/bom/Makefile.am trunk/stdair/stdair/core/Makefile.am trunk/stdair/stdair/core/sources.mk trunk/stdair/stdair/factory/FacSupervisor.cpp trunk/stdair/stdair/factory/FacSupervisor.hpp trunk/stdair/stdair/factory/Makefile.am trunk/stdair/stdair/service/Logger.cpp trunk/stdair/stdair/service/Makefile.am trunk/stdair/stdair/service/sources.mk Added Paths: ----------- trunk/stdair/stdair/STDAIR_Service.hpp trunk/stdair/stdair/service/STDAIR_Service.cpp Modified: trunk/stdair/stdair/Makefile.am =================================================================== --- trunk/stdair/stdair/Makefile.am 2010-01-21 23:30:57 UTC (rev 103) +++ trunk/stdair/stdair/Makefile.am 2010-01-22 19:47:29 UTC (rev 104) @@ -13,5 +13,5 @@ # Header files -nobase_pkginclude_HEADERS = $(service_h_sources) +#nobase_pkginclude_HEADERS = $(service_h_sources) #nobase_nodist_pkginclude_HEADERS = $(top_builddir)/@PACKAGE@/config.h Added: trunk/stdair/stdair/STDAIR_Service.hpp =================================================================== --- trunk/stdair/stdair/STDAIR_Service.hpp (rev 0) +++ trunk/stdair/stdair/STDAIR_Service.hpp 2010-01-22 19:47:29 UTC (rev 104) @@ -0,0 +1,52 @@ +#ifndef __STDAIR_SVC_STDAIR_SERVICE_HPP +#define __STDAIR_SVC_STDAIR_SERVICE_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// StdAir +#include <stdair/basic/BasLogParams.hpp> + +namespace stdair { + + /** Interface for the STDAIR Services. */ + class STDAIR_Service { + public: + // ////////// Constructors and destructors ////////// + /** Constructor. + <br>The init() method is called; see the corresponding documentation + for more details. + <br>Moreover, a reference on an output stream is given, so + that log outputs can be directed onto that stream. + @param const stdair::BasLogParams& Parameters for the output log + stream. */ + STDAIR_Service (const BasLogParams&); + + /** Destructor. */ + ~STDAIR_Service(); + + + private: + // /////// Construction and Destruction helper methods /////// + /** Default constructor. */ + STDAIR_Service (); + /** Default copy constructor. */ + STDAIR_Service (const STDAIR_Service&); + + /** Initialise the log. */ + void logInit (const BasLogParams&); + + /** Initialise. + <br>The static instance of the log service (Logger object) is created. + <br>The static instance of the FacSupervisor object, itself referencing + all the other objects (factories and BOM), is created. + <br>As those two objects are static, there is no need to store them + in any service context. However, some lock mechanism may be needed + in order to secure the access to the corresponding resources. */ + void init (); + + /** Finalise. */ + void finalise (); + }; +} +#endif // __STDAIR_SVC_STDAIR_SERVICE_HPP Modified: trunk/stdair/stdair/basic/Makefile.am =================================================================== --- trunk/stdair/stdair/basic/Makefile.am 2010-01-21 23:30:57 UTC (rev 103) +++ trunk/stdair/stdair/basic/Makefile.am 2010-01-22 19:47:29 UTC (rev 104) @@ -2,11 +2,14 @@ include $(top_srcdir)/Makefile.common include $(srcdir)/sources.mk +# noinst_LTLIBRARIES= libbas.la libbas_la_SOURCES = $(bas_h_sources) $(bas_cc_sources) libbas_la_CXXFLAGS = $(BOOST_CFLAGS) libbas_la_LDFLAGS = -#pkgincludedir = $(includedir)/@PACKAGE@/basic -#pkginclude_HEADERS = $(bas_h_sources) + +# Header files +pkgincludedir = $(includedir)/stdair/basic +pkginclude_HEADERS = $(bas_h_sources) Modified: trunk/stdair/stdair/bom/Makefile.am =================================================================== --- trunk/stdair/stdair/bom/Makefile.am 2010-01-21 23:30:57 UTC (rev 103) +++ trunk/stdair/stdair/bom/Makefile.am 2010-01-22 19:47:29 UTC (rev 104) @@ -8,5 +8,7 @@ libbom_la_CXXFLAGS = $(BOOST_CFLAGS) libbom_la_LDFLAGS = -#pkgincludedir = $(includedir)/@PACKAGE@/bom -#pkginclude_HEADERS = $(bom_h_sources) + +# Header files +pkgincludedir = $(includedir)/stdair/bom +pkginclude_HEADERS = $(bom_h_sources) Modified: trunk/stdair/stdair/core/Makefile.am =================================================================== --- trunk/stdair/stdair/core/Makefile.am 2010-01-21 23:30:57 UTC (rev 103) +++ trunk/stdair/stdair/core/Makefile.am 2010-01-22 19:47:29 UTC (rev 104) @@ -21,3 +21,7 @@ libstdair_la_LDFLAGS = \ $(BOOST_DATE_TIME_LIB) $(BOOST_PROGRAM_OPTIONS_LIB) $(BOOST_FILESYSTEM_LIB) \ -version-info $(GENERIC_LIBRARY_VERSION) + +# +pkgincludedir = $(includedir)/stdair +pkginclude_HEADERS = $(service_h_sources) Modified: trunk/stdair/stdair/core/sources.mk =================================================================== --- trunk/stdair/stdair/core/sources.mk 2010-01-21 23:30:57 UTC (rev 103) +++ trunk/stdair/stdair/core/sources.mk 2010-01-22 19:47:29 UTC (rev 104) @@ -1,2 +1,3 @@ -service_h_sources = $(top_srcdir)/stdair/STDAIR_Types.hpp +service_h_sources = $(top_srcdir)/stdair/STDAIR_Types.hpp \ + $(top_srcdir)/stdair/STDAIR_Service.hpp service_cc_sources = Modified: trunk/stdair/stdair/factory/FacSupervisor.cpp =================================================================== --- trunk/stdair/stdair/factory/FacSupervisor.cpp 2010-01-21 23:30:57 UTC (rev 103) +++ trunk/stdair/stdair/factory/FacSupervisor.cpp 2010-01-22 19:47:29 UTC (rev 104) @@ -38,7 +38,6 @@ FacSupervisor::~FacSupervisor() { cleanBomStructureLayer(); cleanBomContentLayer(); - cleanLoggerService(); } // ////////////////////////////////////////////////////////////////////// @@ -78,11 +77,13 @@ } // ////////////////////////////////////////////////////////////////////// - void FacSupervisor::cleanFactory () { + void FacSupervisor::cleanAll () { // Clean the static instance of the log service - Logger::clean(); + cleanLoggerService(); - // Clean the static instance of the FacSupervisor + // Clean the static instance of the FacSupervisor. + // This in turn will invoke the destructor (~FacSupervisor() method) + // of the static instance. delete _instance; _instance = NULL; } Modified: trunk/stdair/stdair/factory/FacSupervisor.hpp =================================================================== --- trunk/stdair/stdair/factory/FacSupervisor.hpp 2010-01-21 23:30:57 UTC (rev 103) +++ trunk/stdair/stdair/factory/FacSupervisor.hpp 2010-01-22 19:47:29 UTC (rev 104) @@ -24,43 +24,46 @@ typedef std::vector<FacBomStructure*> BomStructureFactoryPool_T; typedef std::vector<FacBomContent*> BomContentFactoryPool_T; - /** Provides the unique instance. + /** Provide the unique (static) instance of the FacSupervisor object. <br>The singleton is instantiated when first used. @return FacSupervisor& */ static FacSupervisor& instance(); - /** Register a newly instantiated concrete factory for the BomStructure layer. + /** Register a newly instantiated concrete factory for the + BomStructure layer. <br>When a concrete Factory is firstly instantiated this factory have to register itself to the FacSupervisor - @param FacBomStructure& the concrete Factory to register. */ + @param FacBomStructure* The concrete Factory to register. */ void registerBomStructureFactory (FacBomStructure*); - /** Register a newly instantiated concrete factory for the BomContent layer. + /** Register a newly instantiated concrete factory for the + BomContent layer. <br>When a concrete Factory is firstly instantiated this factory have to register itself to the FacSupervisor - @param FacBomContent& the concrete Factory to register. */ + @param FacBomContent* The concrete Factory to register. */ void registerBomContentFactory (FacBomContent*); - /** Clean all created object. - <br>Call the clean method of all the instantiated factories + /** Clean all registered object. + <br>Call the clean method of all the instantiated factories for the BomStructure layer. */ void cleanBomStructureLayer(); - /** Clean all created object. - <br>Call the clean method of all the instantiated factories + /** Clean all the registered object. + <br>Call the clean method of all the instantiated factories for the BomContent layer. */ void cleanBomContentLayer(); - /** Delete the Logger object. */ - void cleanLoggerService(); + /** Delete the static instance of the Logger object. */ + static void cleanLoggerService(); /** Clean the static instance. - <br> The singleton is deleted.*/ - static void cleanFactory (); + <br>As the static instance (singleton) is deleted, all the other + registered objects will be deleted in turn. */ + static void cleanAll (); - /** Destructor - <br>The static instance is deleted (and reset to NULL) - by the static cleanFactory() method. */ + /** Destructor. + <br>That destructors is applied on the static instance. It then + deletes in turn all the other registered objects. */ ~FacSupervisor(); Modified: trunk/stdair/stdair/factory/Makefile.am =================================================================== --- trunk/stdair/stdair/factory/Makefile.am 2010-01-21 23:30:57 UTC (rev 103) +++ trunk/stdair/stdair/factory/Makefile.am 2010-01-22 19:47:29 UTC (rev 104) @@ -7,5 +7,7 @@ libfac_la_SOURCES= $(fac_h_sources) $(fac_cc_sources) libfac_la_CXXFLAGS = -#pkgincludedir = $(includedir)/@PACKAGE@/factory -#pkginclude_HEADERS = $(fac_h_sources) + +# Header files +pkgincludedir = $(includedir)/stdair/factory +pkginclude_HEADERS = $(fac_h_sources) Modified: trunk/stdair/stdair/service/Logger.cpp =================================================================== --- trunk/stdair/stdair/service/Logger.cpp 2010-01-21 23:30:57 UTC (rev 103) +++ trunk/stdair/stdair/service/Logger.cpp 2010-01-22 19:47:29 UTC (rev 104) @@ -26,7 +26,7 @@ // ////////////////////////////////////////////////////////////////////// Logger::~Logger () { - std::cout << "In Logger destructor" << std::endl; + // std::cout << "In Logger destructor" << std::endl; } // ////////////////////////////////////////////////////////////////////// @@ -52,9 +52,11 @@ // ////////////////////////////////////////////////////////////////////// void Logger::clean() { - std::cout << "In Logger::clean(), before static instance deletion" << std::endl; + // std::cout << "In Logger::clean(), before static instance deletion" + // << std::endl; delete _instance; _instance = NULL; - std::cout << "In Logger::clean(), after static instance deletion" << std::endl; + // std::cout << "In Logger::clean(), after static instance deletion" + // << std::endl; } } Modified: trunk/stdair/stdair/service/Makefile.am =================================================================== --- trunk/stdair/stdair/service/Makefile.am 2010-01-21 23:30:57 UTC (rev 103) +++ trunk/stdair/stdair/service/Makefile.am 2010-01-22 19:47:29 UTC (rev 104) @@ -2,10 +2,12 @@ include $(top_srcdir)/Makefile.common include $(srcdir)/sources.mk +# noinst_LTLIBRARIES= libsvc.la libsvc_la_SOURCES= $(svc_h_sources) $(svc_cc_sources) libsvc_la_CXXFLAGS = -#pkgincludedir = $(includedir)/@PACKAGE@/service -#pkginclude_HEADERS = $(svc_h_sources) +# Header files +pkgincludedir = $(includedir)/stdair/service +pkginclude_HEADERS = $(svc_h_sources) Added: trunk/stdair/stdair/service/STDAIR_Service.cpp =================================================================== --- trunk/stdair/stdair/service/STDAIR_Service.cpp (rev 0) +++ trunk/stdair/stdair/service/STDAIR_Service.cpp 2010-01-22 19:47:29 UTC (rev 104) @@ -0,0 +1,58 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +// StdAir +#include <stdair/basic/BasChronometer.hpp> +#include <stdair/bom/BomManager.hpp> // for display() +#include <stdair/factory/FacSupervisor.hpp> +#include <stdair/service/Logger.hpp> +#include <stdair/STDAIR_Service.hpp> + +namespace stdair { + + // ////////////////////////////////////////////////////////////////////// + STDAIR_Service::STDAIR_Service () { + assert (false); + } + + // ////////////////////////////////////////////////////////////////////// + STDAIR_Service::STDAIR_Service (const STDAIR_Service& iService) { + assert (false); + } + + // ////////////////////////////////////////////////////////////////////// + STDAIR_Service::STDAIR_Service (const stdair::BasLogParams& iLogParams) { + // Set the log file + logInit (iLogParams); + + // Initialise the (remaining of the) context + init (); + } + + // ////////////////////////////////////////////////////////////////////// + STDAIR_Service::~STDAIR_Service () { + // Delete/Clean all the objects from memory + finalise(); + } + + // ////////////////////////////////////////////////////////////////////// + void STDAIR_Service::logInit (const BasLogParams& iLogParams) { + Logger::init (iLogParams); + } + + // ////////////////////////////////////////////////////////////////////// + void STDAIR_Service::init () { + // Create the static instance of the FacSupervisor object + FacSupervisor::instance(); + } + + // ////////////////////////////////////////////////////////////////////// + void STDAIR_Service::finalise () { + // std::cout << "In STDAIR_Service destructor, before cleaning" << std::endl; + FacSupervisor::cleanAll(); + // std::cout << "In STDAIR_Service destructor, after cleaning" << std::endl; + } + +} Modified: trunk/stdair/stdair/service/sources.mk =================================================================== --- trunk/stdair/stdair/service/sources.mk 2010-01-21 23:30:57 UTC (rev 103) +++ trunk/stdair/stdair/service/sources.mk 2010-01-22 19:47:29 UTC (rev 104) @@ -1,2 +1,3 @@ svc_h_sources = $(top_srcdir)/stdair/service/Logger.hpp -svc_cc_sources = $(top_srcdir)/stdair/service/Logger.cpp +svc_cc_sources = $(top_srcdir)/stdair/service/Logger.cpp \ + $(top_srcdir)/stdair/service/STDAIR_Service.cpp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-01-28 22:49:16
|
Revision: 109 http://stdair.svn.sourceforge.net/stdair/?rev=109&view=rev Author: denis_arnaud Date: 2010-01-28 22:49:08 +0000 (Thu, 28 Jan 2010) Log Message: ----------- [Dev] Added a reference on the BomRoot in the STDAIR_Service. Modified Paths: -------------- trunk/stdair/stdair/STDAIR_Service.hpp trunk/stdair/stdair/service/STDAIR_Service.cpp Modified: trunk/stdair/stdair/STDAIR_Service.hpp =================================================================== --- trunk/stdair/stdair/STDAIR_Service.hpp 2010-01-28 15:49:36 UTC (rev 108) +++ trunk/stdair/stdair/STDAIR_Service.hpp 2010-01-28 22:49:08 UTC (rev 109) @@ -9,6 +9,10 @@ namespace stdair { + // Forward declarations + class BomRoot; + + /** Interface for the STDAIR Services. */ class STDAIR_Service { public: @@ -26,6 +30,15 @@ ~STDAIR_Service(); + // ///////////////// Getters /////////////////// + /** Get a reference on the BomRoot object. + <br>If the service context has not been initialised, that + method throws an exception (failing assertion). */ + BomRoot& getBomRoot () const { + return _bomRoot; + } + + private: // /////// Construction and Destruction helper methods /////// /** Default constructor. */ @@ -47,6 +60,12 @@ /** Finalise. */ void finalise (); + + + private: + // /////////////// Attributes /////////////// + /** Root of the BOM tree. */ + BomRoot& _bomRoot; }; } #endif // __STDAIR_SVC_STDAIR_SERVICE_HPP Modified: trunk/stdair/stdair/service/STDAIR_Service.cpp =================================================================== --- trunk/stdair/stdair/service/STDAIR_Service.cpp 2010-01-28 15:49:36 UTC (rev 108) +++ trunk/stdair/stdair/service/STDAIR_Service.cpp 2010-01-28 22:49:08 UTC (rev 109) @@ -6,24 +6,34 @@ // StdAir #include <stdair/basic/BasChronometer.hpp> #include <stdair/bom/BomManager.hpp> // for display() +#include <stdair/bom/BomRoot.hpp> +#include <stdair/bom/Inventory.hpp> // Child of BomRoot, needed for creation of BomRoot +#include <stdair/bom/Network.hpp> // Child of BomRoot, needed for creation of BomRoot #include <stdair/factory/FacSupervisor.hpp> +#include <stdair/factory/FacBomContent.hpp> #include <stdair/service/Logger.hpp> #include <stdair/STDAIR_Service.hpp> namespace stdair { // ////////////////////////////////////////////////////////////////////// - STDAIR_Service::STDAIR_Service () { + STDAIR_Service::STDAIR_Service () + : _bomRoot (FacBomContent::instance().create<BomRoot>()) { assert (false); } // ////////////////////////////////////////////////////////////////////// - STDAIR_Service::STDAIR_Service (const STDAIR_Service& iService) { + STDAIR_Service::STDAIR_Service (const STDAIR_Service& iService) + : _bomRoot (FacBomContent::instance().create<BomRoot>()) { assert (false); } // ////////////////////////////////////////////////////////////////////// - STDAIR_Service::STDAIR_Service (const stdair::BasLogParams& iLogParams) { + STDAIR_Service::STDAIR_Service (const stdair::BasLogParams& iLogParams) + : _bomRoot (FacBomContent::instance().create<BomRoot>()) { + // The root of the BOM tree, on which all of the other BOM objects + // will be attached, is being created with the STDAIR_Service constructor. + // Set the log file logInit (iLogParams); @@ -44,8 +54,6 @@ // ////////////////////////////////////////////////////////////////////// void STDAIR_Service::init () { - // Create the static instance of the FacSupervisor object - FacSupervisor::instance(); } // ////////////////////////////////////////////////////////////////////// This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-01-28 23:35:07
|
Revision: 110 http://stdair.svn.sourceforge.net/stdair/?rev=110&view=rev Author: denis_arnaud Date: 2010-01-28 23:35:01 +0000 (Thu, 28 Jan 2010) Log Message: ----------- There is now a separate header file for defining (smart) pointer on the STDAIR_Service. Modified Paths: -------------- trunk/stdair/stdair/STDAIR_Service.hpp trunk/stdair/stdair/core/sources.mk Added Paths: ----------- trunk/stdair/stdair/STDAIR_ServicePtr.hpp Modified: trunk/stdair/stdair/STDAIR_Service.hpp =================================================================== --- trunk/stdair/stdair/STDAIR_Service.hpp 2010-01-28 22:49:08 UTC (rev 109) +++ trunk/stdair/stdair/STDAIR_Service.hpp 2010-01-28 23:35:01 UTC (rev 110) @@ -4,6 +4,8 @@ // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// +// Boost +#include <boost/shared_ptr.hpp> // StdAir #include <stdair/basic/BasLogParams.hpp> Added: trunk/stdair/stdair/STDAIR_ServicePtr.hpp =================================================================== --- trunk/stdair/stdair/STDAIR_ServicePtr.hpp (rev 0) +++ trunk/stdair/stdair/STDAIR_ServicePtr.hpp 2010-01-28 23:35:01 UTC (rev 110) @@ -0,0 +1,19 @@ +#ifndef __STDAIR_SVC_STDAIR_SERVICEPTR_HPP +#define __STDAIR_SVC_STDAIR_SERVICEPTR_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// Boost +#include <boost/shared_ptr.hpp> + +namespace stdair { + + // Forward declarations + class STDAIR_Service; + + /** Pointer on the STDAIR Service handler. */ + typedef boost::shared_ptr<STDAIR_Service> STDAIR_ServicePtr_T; + +} +#endif // __STDAIR_SVC_STDAIR_SERVICEPTR_HPP Modified: trunk/stdair/stdair/core/sources.mk =================================================================== --- trunk/stdair/stdair/core/sources.mk 2010-01-28 22:49:08 UTC (rev 109) +++ trunk/stdair/stdair/core/sources.mk 2010-01-28 23:35:01 UTC (rev 110) @@ -1,3 +1,4 @@ service_h_sources = $(top_srcdir)/stdair/STDAIR_Types.hpp \ - $(top_srcdir)/stdair/STDAIR_Service.hpp + $(top_srcdir)/stdair/STDAIR_Service.hpp \ + $(top_srcdir)/stdair/STDAIR_ServicePtr.hpp service_cc_sources = This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-02-06 17:52:21
|
Revision: 115 http://stdair.svn.sourceforge.net/stdair/?rev=115&view=rev Author: denis_arnaud Date: 2010-02-06 17:51:39 +0000 (Sat, 06 Feb 2010) Log Message: ----------- [DB] Added support for database management (still a little work to do). Modified Paths: -------------- trunk/stdair/stdair/STDAIR_Service.hpp trunk/stdair/stdair/STDAIR_Types.hpp trunk/stdair/stdair/bom/TravelSolutionStruct.hpp trunk/stdair/stdair/bom/sources.mk trunk/stdair/stdair/factory/FacSupervisor.cpp trunk/stdair/stdair/factory/FacSupervisor.hpp trunk/stdair/stdair/service/Logger.cpp trunk/stdair/stdair/service/Logger.hpp trunk/stdair/stdair/service/Makefile.am trunk/stdair/stdair/service/STDAIR_Service.cpp trunk/stdair/stdair/service/sources.mk Added Paths: ----------- trunk/stdair/stdair/bom/AirlineStruct.cpp trunk/stdair/stdair/bom/AirlineStruct.hpp trunk/stdair/stdair/service/DBSessionManager.cpp trunk/stdair/stdair/service/DBSessionManager.hpp Modified: trunk/stdair/stdair/STDAIR_Service.hpp =================================================================== --- trunk/stdair/stdair/STDAIR_Service.hpp 2010-02-06 13:33:54 UTC (rev 114) +++ trunk/stdair/stdair/STDAIR_Service.hpp 2010-02-06 17:51:39 UTC (rev 115) @@ -8,6 +8,7 @@ #include <boost/shared_ptr.hpp> // StdAir #include <stdair/basic/BasLogParams.hpp> +#include <stdair/basic/BasDBParams.hpp> namespace stdair { @@ -24,10 +25,20 @@ for more details. <br>Moreover, a reference on an output stream is given, so that log outputs can be directed onto that stream. - @param const stdair::BasLogParams& Parameters for the output log - stream. */ + @param const BasLogParams& Parameters for the output log stream. */ STDAIR_Service (const BasLogParams&); + /** Constructor. + <br>The init() method is called; see the corresponding documentation + for more details. + <br>A reference on an output stream is given, so + that log outputs can be directed onto that stream. + <br>Moreover, database connection parameters are given, so + that database requests can use the corresponding access. + @param const BasLogParams& Parameters for the output log stream. + @param const BasDBParams& Parameters for the database session. */ + STDAIR_Service (const BasLogParams&, const BasDBParams&); + /** Destructor. */ ~STDAIR_Service(); @@ -51,11 +62,16 @@ /** Initialise the log. */ void logInit (const BasLogParams&); + /** Initialise the database session. */ + void dbInit (const BasDBParams&); + /** Initialise. <br>The static instance of the log service (Logger object) is created. + <br>The static instance of the database session manager + (DBSessionManager object) is created. <br>The static instance of the FacSupervisor object, itself referencing all the other objects (factories and BOM), is created. - <br>As those two objects are static, there is no need to store them + <br>As those three objects are static, there is no need to store them in any service context. However, some lock mechanism may be needed in order to secure the access to the corresponding resources. */ void init (); Modified: trunk/stdair/stdair/STDAIR_Types.hpp =================================================================== --- trunk/stdair/stdair/STDAIR_Types.hpp 2010-02-06 13:33:54 UTC (rev 114) +++ trunk/stdair/stdair/STDAIR_Types.hpp 2010-02-06 17:51:39 UTC (rev 115) @@ -14,6 +14,12 @@ #include <boost/tuple/tuple.hpp> #include <boost/shared_ptr.hpp> +// Forward declarations +namespace soci { + class session; + class statement; +} + namespace stdair { // Forward declarations @@ -29,6 +35,9 @@ class NonInitialisedLogServiceException : public RootException { }; + class NonInitialisedDBSessionManagerException : public RootException { + }; + class NonInitialisedServiceException : public RootException { }; @@ -38,6 +47,12 @@ class ObjectNotFoundException : public RootException { }; + class SQLDatabaseException : public RootException { + }; + + class SQLDatabaseConnectionImpossibleException : public SQLDatabaseException { + }; + class DocumentNotFoundException : public RootException { }; @@ -59,6 +74,12 @@ } // //////// Type definitions ///////// + /** Database session handler. */ + typedef soci::session DBSession_T; + + /** Database request statement handler. */ + typedef soci::statement DBRequestStatement_T; + /** Define the type for durations (e.g., elapsed in-flight time). */ typedef boost::posix_time::time_duration Duration_T; Added: trunk/stdair/stdair/bom/AirlineStruct.cpp =================================================================== --- trunk/stdair/stdair/bom/AirlineStruct.cpp (rev 0) +++ trunk/stdair/stdair/bom/AirlineStruct.cpp 2010-02-06 17:51:39 UTC (rev 115) @@ -0,0 +1,50 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +#include <istream> +#include <ostream> +#include <sstream> +// StdAir +#include <stdair/bom/AirlineStruct.hpp> + +namespace stdair { + + // //////////////////////////////////////////////////////////////////// + AirlineStruct::AirlineStruct () { + assert (false); + } + + // //////////////////////////////////////////////////////////////////// + AirlineStruct::AirlineStruct (const AirlineStruct& iAirlineStruct) + : _code (iAirlineStruct._code), _name (iAirlineStruct._name) { + } + + // //////////////////////////////////////////////////////////////////// + AirlineStruct::AirlineStruct (const AirlineCode_T& iAirlineCode, + const std::string& iAirlineName) + : _code (iAirlineCode), _name (iAirlineName) { + } + + // //////////////////////////////////////////////////////////////////// + AirlineStruct::~AirlineStruct () { + } + + // ////////////////////////////////////////////////////////////////////// + void AirlineStruct::toStream (std::ostream& ioOut) const { + ioOut << describe(); + } + + // ////////////////////////////////////////////////////////////////////// + void AirlineStruct::fromStream (std::istream& ioIn) { + } + + // ////////////////////////////////////////////////////////////////////// + const std::string AirlineStruct::describe() const { + std::ostringstream oStr; + oStr << _code << " " << _name; + return oStr.str(); + } + +} Added: trunk/stdair/stdair/bom/AirlineStruct.hpp =================================================================== --- trunk/stdair/stdair/bom/AirlineStruct.hpp (rev 0) +++ trunk/stdair/stdair/bom/AirlineStruct.hpp 2010-02-06 17:51:39 UTC (rev 115) @@ -0,0 +1,78 @@ +#ifndef __STDAIR_BOM_AIRLINESTRUCT_HPP +#define __STDAIR_BOM_AIRLINESTRUCT_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <iosfwd> +#include <string> +#include <vector> +// StdAir +#include <stdair/STDAIR_Types.hpp> +#include <stdair/bom/StructAbstract.hpp> + +namespace stdair { + + /** Structure holding parameters describing an airline. */ + struct AirlineStruct : public StructAbstract { + public: + // /////////// Getters /////////////// + /** Get the airline code. */ + const AirlineCode_T& getAirlineCode() const { + return _code; + } + + /** Get the airline name. */ + const std::string& getAirlineName() const { + return _name; + } + + // /////////// Setters /////////////// + /** Set the airline code. */ + void setAirlineCode (const AirlineCode_T& iAirlineCode) { + _code = iAirlineCode; + } + + /** Set the airline name. */ + void setAirlineName (const std::string& iAirlineName) { + _name = iAirlineName; + } + + + public: + // /////////// Display support method ///////////// + /** Dump a Business Object into an output stream. + @param ostream& the output stream. */ + void toStream (std::ostream& ioOut) const; + + /** Read a Business Object from an input stream. + @param istream& the input stream. */ + void fromStream (std::istream& ioIn); + + /** Display of the structure. */ + const std::string describe() const; + + + public: + // //////////// Constructors & Destructor /////////////// + /** Main constructor. */ + AirlineStruct (const AirlineCode_T&, const std::string& iAirlineName); + /** Destructor. */ + ~AirlineStruct (); + /** Default copy constructor. */ + AirlineStruct (const AirlineStruct&); + /** Default constructor, not to be used. */ + AirlineStruct (); + + private: + // ///////////////////// Attributes ////////////////////// + /** Airline code. */ + AirlineCode_T _code; + + /** Airline name. */ + std::string _name; + }; + +} +#endif // __STDAIR_BOM_AIRLINESTRUCT_HPP Modified: trunk/stdair/stdair/bom/TravelSolutionStruct.hpp =================================================================== --- trunk/stdair/stdair/bom/TravelSolutionStruct.hpp 2010-02-06 13:33:54 UTC (rev 114) +++ trunk/stdair/stdair/bom/TravelSolutionStruct.hpp 2010-02-06 17:51:39 UTC (rev 115) @@ -13,6 +13,7 @@ #include <stdair/bom/BookingClassTypes.hpp> namespace stdair { + // Forward declarations class OutboundPath; @@ -42,8 +43,8 @@ const std::string describe() const; + public: // //////////// Constructors & Destructor /////////////// - public: /** Main constructor. */ TravelSolutionStruct (OutboundPath&, const BookingClassSTLList_T&); /** Destructor. */ @@ -54,7 +55,7 @@ TravelSolutionStruct (); private: - // Attributes + // ///////////////////// Attributes ////////////////////// /** The outbound path associated to this solution.*/ OutboundPath* _outboundPath_ptr; Modified: trunk/stdair/stdair/bom/sources.mk =================================================================== --- trunk/stdair/stdair/bom/sources.mk 2010-02-06 13:33:54 UTC (rev 114) +++ trunk/stdair/stdair/bom/sources.mk 2010-02-06 17:51:39 UTC (rev 115) @@ -85,6 +85,7 @@ $(top_srcdir)/stdair/bom/TravelSolutionStruct.hpp \ $(top_srcdir)/stdair/bom/TravelSolutionTypes.hpp \ $(top_srcdir)/stdair/bom/BookingRequestStruct.hpp \ + $(top_srcdir)/stdair/bom/AirlineStruct.hpp \ $(top_srcdir)/stdair/bom/BomManager.hpp bom_cc_sources = \ $(top_srcdir)/stdair/bom/BomRootKey.cpp \ @@ -133,4 +134,5 @@ $(top_srcdir)/stdair/bom/DoWStruct.cpp \ $(top_srcdir)/stdair/bom/TravelSolutionStruct.cpp \ $(top_srcdir)/stdair/bom/BookingRequestStruct.cpp \ + $(top_srcdir)/stdair/bom/AirlineStruct.cpp \ $(top_srcdir)/stdair/bom/BomManager.cpp Modified: trunk/stdair/stdair/factory/FacSupervisor.cpp =================================================================== --- trunk/stdair/stdair/factory/FacSupervisor.cpp 2010-02-06 13:33:54 UTC (rev 114) +++ trunk/stdair/stdair/factory/FacSupervisor.cpp 2010-02-06 17:51:39 UTC (rev 115) @@ -8,6 +8,7 @@ #include <stdair/factory/FacBomContent.hpp> #include <stdair/factory/FacSupervisor.hpp> #include <stdair/service/Logger.hpp> +#include <stdair/service/DBSessionManager.hpp> namespace stdair { @@ -75,9 +76,18 @@ // Clean the static instance of the log service Logger::clean(); } + + // ////////////////////////////////////////////////////////////////////// + void FacSupervisor::cleanDBSessionManager() { + // Clean the static instance of the database session manager + DBSessionManager::clean(); + } // ////////////////////////////////////////////////////////////////////// void FacSupervisor::cleanAll () { + // Clean the static instance of the database session manager + cleanDBSessionManager(); + // Clean the static instance of the log service cleanLoggerService(); Modified: trunk/stdair/stdair/factory/FacSupervisor.hpp =================================================================== --- trunk/stdair/stdair/factory/FacSupervisor.hpp 2010-02-06 13:33:54 UTC (rev 114) +++ trunk/stdair/stdair/factory/FacSupervisor.hpp 2010-02-06 17:51:39 UTC (rev 115) @@ -56,6 +56,9 @@ /** Delete the static instance of the Logger object. */ static void cleanLoggerService(); + /** Delete the static instance of the DBSessionManager object. */ + static void cleanDBSessionManager(); + /** Clean the static instance. <br>As the static instance (singleton) is deleted, all the other registered objects will be deleted in turn. */ Added: trunk/stdair/stdair/service/DBSessionManager.cpp =================================================================== --- trunk/stdair/stdair/service/DBSessionManager.cpp (rev 0) +++ trunk/stdair/stdair/service/DBSessionManager.cpp 2010-02-06 17:51:39 UTC (rev 115) @@ -0,0 +1,117 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +#include <string> +#include <sstream> +// SOCI +#include <soci/core/soci.h> +#include <soci/backends/mysql/soci-mysql.h> +// StdAir +#include <stdair/basic/BasDBParams.hpp> +#include <stdair/service/DBSessionManager.hpp> +#include <stdair/service/Logger.hpp> + +namespace stdair { + + DBSessionManager* DBSessionManager::_instance = NULL; + + // ////////////////////////////////////////////////////////////////////// + DBSessionManager::DBSessionManager () : _dbSession (NULL) { + assert (false); + } + + // ////////////////////////////////////////////////////////////////////// + DBSessionManager::DBSessionManager (const DBSessionManager&) + : _dbSession (NULL) { + assert (false); + } + + // ////////////////////////////////////////////////////////////////////// + DBSessionManager::DBSessionManager (const BasDBParams& iDBParams) + : _dbSession (NULL) { + dbInit (iDBParams); + } + + // ////////////////////////////////////////////////////////////////////// + DBSessionManager::~DBSessionManager () { + // std::cout << "In DBSessionManager destructor" << std::endl; + dbFinalise(); + } + + // ////////////////////////////////////////////////////////////////////// + void DBSessionManager::dbInit (const BasDBParams& iDBParams) { + + // Database parameters + std::ostringstream oStr; + oStr << "db=" << iDBParams.getDBName() << " user=" << iDBParams.getUser() + << " password=" << iDBParams.getPassword() + << " port=" << iDBParams.getPort() << " host=" << iDBParams.getHost(); + const std::string lDBSessionConnectionString (oStr.str()); + + // Instanciate the database session: nothing else is performed at that stage + _dbSession = new DBSession_T(); + + try { + + // Open the connection to the database + _dbSession->open (soci::mysql, lDBSessionConnectionString); + + } catch (std::exception const& lException) { + STDAIR_LOG_ERROR ("Error while opening a connection to database: " + << lException.what()); + STDAIR_LOG_ERROR ("Database parameters used:" + << " db=" << iDBParams.getDBName() + << " user=" << iDBParams.getUser() + << " port=" << iDBParams.getPort() + << " host=" << iDBParams.getHost()); + throw SQLDatabaseConnectionImpossibleException(); + } + } + + // ////////////////////////////////////////////////////////////////////// + void DBSessionManager::dbFinalise () { + delete _dbSession; _dbSession = NULL; + } + + // ////////////////////////////////////////////////////////////////////// + void DBSessionManager::init (const BasDBParams& iDBParams) { + // Sanity check + if (_instance != NULL) { + STDAIR_LOG_ERROR ("Error: the DB session has already been initialised"); + assert (false); + } + assert (_instance == NULL); + + _instance = new DBSessionManager (iDBParams); + } + + // ////////////////////////////////////////////////////////////////////// + DBSessionManager& DBSessionManager::instance() { + if (_instance == NULL) { + throw NonInitialisedDBSessionManagerException(); + } + assert (_instance != NULL); + return *_instance; + } + + // ////////////////////////////////////////////////////////////////////// + void DBSessionManager::clean() { + //std::cout<< "In DBSessionManager::clean(),before static instance deletion" + // << std::endl; + delete _instance; _instance = NULL; + //std::cout<< "In DBSessionManager::clean(),after static instance deletion" + // << std::endl; + } + + // ////////////////////////////////////////////////////////////////////// + DBSession_T& DBSessionManager::getDBSession() const { + if (_dbSession == NULL) { + throw NonInitialisedDBSessionManagerException(); + } + assert (_dbSession != NULL); + return *_dbSession; + } + +} Added: trunk/stdair/stdair/service/DBSessionManager.hpp =================================================================== --- trunk/stdair/stdair/service/DBSessionManager.hpp (rev 0) +++ trunk/stdair/stdair/service/DBSessionManager.hpp 2010-02-06 17:51:39 UTC (rev 115) @@ -0,0 +1,69 @@ +#ifndef __STDAIR_SVC_DBSESSIONMANAGER_HPP +#define __STDAIR_SVC_DBSESSIONMANAGER_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// StdAir +#include <stdair/STDAIR_Types.hpp> + +namespace stdair { + + // Forward declarations + struct BasDBParams; + + /** Class holding the database session. + <br>Note that the database access is handled by the SOCI library. */ + class DBSessionManager { + // Friend classes + friend class FacSupervisor; + friend class STDAIR_Service; + + public: + /** Return the static DBSessionManager instance. */ + static DBSessionManager& instance(); + + /** Retrieve the database session handler, held by the static instance + of DBSessionManager. */ + DBSession_T& getDBSession() const; + + + private: + /** Default constructors are private so that only the required + constructor can be used. */ + DBSessionManager (const BasDBParams&); + /** Default constructor. It must not be used. */ + DBSessionManager (); + /** Default copy constructor. It must not be used. */ + DBSessionManager (const DBSessionManager&); + /** Destructor. */ + ~DBSessionManager (); + + /** Initialise the (MySQL) database connection for the static + DBSessionManager instance. */ + void dbInit (const BasDBParams&); + + /** Close the (MySQL) database connection attached to the static + DBSessionManager instance. */ + void dbFinalise (); + + + private: + /** Initialise the static DBSessionManager instance. + <br>The (MySQL) database connection is initialised. */ + static void init (const BasDBParams&); + + /** Delete the static DBSessionManager instance.*/ + static void clean(); + + + private: + /** Instance object.*/ + static DBSessionManager* _instance; + + /** Database session handler. */ + DBSession_T* _dbSession; + }; + +} +#endif // __STDAIR_SVC_DBSESSIONMANAGER_HPP Modified: trunk/stdair/stdair/service/Logger.cpp =================================================================== --- trunk/stdair/stdair/service/Logger.cpp 2010-02-06 13:33:54 UTC (rev 114) +++ trunk/stdair/stdair/service/Logger.cpp 2010-02-06 17:51:39 UTC (rev 115) @@ -1,8 +1,7 @@ // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// -// Stdair Logger -//#include <stdair/factory/FacSupervisor.hpp> +// StdAir Logger #include <stdair/service/Logger.hpp> namespace stdair { @@ -20,7 +19,7 @@ } // ////////////////////////////////////////////////////////////////////// - Logger::Logger (const stdair::BasLogParams& iLogParams) + Logger::Logger (const BasLogParams& iLogParams) : _level (iLogParams._logLevel), _logStream (iLogParams._logStream) { } Modified: trunk/stdair/stdair/service/Logger.hpp =================================================================== --- trunk/stdair/stdair/service/Logger.hpp 2010-02-06 13:33:54 UTC (rev 114) +++ trunk/stdair/stdair/service/Logger.hpp 2010-02-06 17:51:39 UTC (rev 115) @@ -46,6 +46,7 @@ class Logger { // Friend classes friend class FacSupervisor; + friend class STDAIR_Service; public: /** Main log entry. */ @@ -58,9 +59,6 @@ } } - /** Initialise the static Logger instance. */ - static void init (const stdair::BasLogParams&); - /** Return the static Logger instance. */ static Logger& instance(); @@ -68,7 +66,7 @@ private: /** Default constructors are private so that only the required constructor can be used. */ - Logger (const stdair::BasLogParams&); + Logger (const BasLogParams&); /** Default constructor. It must not be used. */ Logger (); /** Default copy constructor. It must not be used. */ @@ -76,6 +74,13 @@ /** Destructor. */ ~Logger (); + // TODO: migrate all the XXXXXX_Service to the new way to initialise + // Logger, and get rid of that 'public:' interface + public: + /** Initialise the static Logger instance. */ + static void init (const BasLogParams&); + + private: /** Delete the static Logger instance.*/ static void clean(); Modified: trunk/stdair/stdair/service/Makefile.am =================================================================== --- trunk/stdair/stdair/service/Makefile.am 2010-02-06 13:33:54 UTC (rev 114) +++ trunk/stdair/stdair/service/Makefile.am 2010-02-06 17:51:39 UTC (rev 115) @@ -6,7 +6,8 @@ noinst_LTLIBRARIES= libsvc.la libsvc_la_SOURCES= $(svc_h_sources) $(svc_cc_sources) -libsvc_la_CXXFLAGS = +libsvc_la_CXXFLAGS = $(SOCI_CFLAGS) $(MYSQL_CFLAGS) +libsvc_la_LDFLAGS = $(SOCI_LIBS) $(MYSQL_LIBS) # Header files pkgincludedir = $(includedir)/stdair/service Modified: trunk/stdair/stdair/service/STDAIR_Service.cpp =================================================================== --- trunk/stdair/stdair/service/STDAIR_Service.cpp 2010-02-06 13:33:54 UTC (rev 114) +++ trunk/stdair/stdair/service/STDAIR_Service.cpp 2010-02-06 17:51:39 UTC (rev 115) @@ -12,6 +12,7 @@ #include <stdair/factory/FacSupervisor.hpp> #include <stdair/factory/FacBomContent.hpp> #include <stdair/service/Logger.hpp> +#include <stdair/service/DBSessionManager.hpp> #include <stdair/STDAIR_Service.hpp> namespace stdair { @@ -29,7 +30,7 @@ } // ////////////////////////////////////////////////////////////////////// - STDAIR_Service::STDAIR_Service (const stdair::BasLogParams& iLogParams) + STDAIR_Service::STDAIR_Service (const BasLogParams& iLogParams) : _bomRoot (FacBomContent::instance().create<BomRoot>()) { // The root of the BOM tree, on which all of the other BOM objects // will be attached, is being created with the STDAIR_Service constructor. @@ -42,6 +43,23 @@ } // ////////////////////////////////////////////////////////////////////// + STDAIR_Service::STDAIR_Service (const BasLogParams& iLogParams, + const BasDBParams& iDBParams) + : _bomRoot (FacBomContent::instance().create<BomRoot>()) { + // The root of the BOM tree, on which all of the other BOM objects + // will be attached, is being created with the STDAIR_Service constructor. + + // Set the log file + logInit (iLogParams); + + // Create a database session + dbInit (iDBParams); + + // Initialise the (remaining of the) context + init (); + } + + // ////////////////////////////////////////////////////////////////////// STDAIR_Service::~STDAIR_Service () { // Delete/Clean all the objects from memory finalise(); @@ -53,6 +71,11 @@ } // ////////////////////////////////////////////////////////////////////// + void STDAIR_Service::dbInit (const BasDBParams& iDBParams) { + DBSessionManager::init (iDBParams); + } + + // ////////////////////////////////////////////////////////////////////// void STDAIR_Service::init () { } Modified: trunk/stdair/stdair/service/sources.mk =================================================================== --- trunk/stdair/stdair/service/sources.mk 2010-02-06 13:33:54 UTC (rev 114) +++ trunk/stdair/stdair/service/sources.mk 2010-02-06 17:51:39 UTC (rev 115) @@ -1,3 +1,7 @@ -svc_h_sources = $(top_srcdir)/stdair/service/Logger.hpp -svc_cc_sources = $(top_srcdir)/stdair/service/Logger.cpp \ - $(top_srcdir)/stdair/service/STDAIR_Service.cpp +svc_h_sources = \ + $(top_srcdir)/stdair/service/Logger.hpp \ + $(top_srcdir)/stdair/service/DBSessionManager.hpp +svc_cc_sources = \ + $(top_srcdir)/stdair/service/Logger.cpp \ + $(top_srcdir)/stdair/service/DBSessionManager.cpp \ + $(top_srcdir)/stdair/service/STDAIR_Service.cpp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-02-07 19:43:36
|
Revision: 120 http://stdair.svn.sourceforge.net/stdair/?rev=120&view=rev Author: denis_arnaud Date: 2010-02-07 19:43:30 +0000 (Sun, 07 Feb 2010) Log Message: ----------- 1. Integrated more initialisation procedures within the STDAIR_Service object. 2. Added a sample stdair::DBManagerForAirlines class. Modified Paths: -------------- trunk/stdair/stdair/Makefile.am trunk/stdair/stdair/STDAIR_Service.hpp trunk/stdair/stdair/bom/BomRoot.cpp trunk/stdair/stdair/bom/BomRoot.hpp trunk/stdair/stdair/bom/BookingRequestStruct.cpp trunk/stdair/stdair/core/Makefile.am trunk/stdair/stdair/service/STDAIR_Service.cpp Added Paths: ----------- trunk/stdair/stdair/command/CmdAbstract.cpp trunk/stdair/stdair/command/CmdAbstract.hpp trunk/stdair/stdair/command/DBManagerForAirlines.cpp trunk/stdair/stdair/command/DBManagerForAirlines.hpp trunk/stdair/stdair/command/Makefile.am trunk/stdair/stdair/command/sources.mk Property Changed: ---------------- trunk/stdair/stdair/command/ Modified: trunk/stdair/stdair/Makefile.am =================================================================== --- trunk/stdair/stdair/Makefile.am 2010-02-07 02:48:33 UTC (rev 119) +++ trunk/stdair/stdair/Makefile.am 2010-02-07 19:43:30 UTC (rev 120) @@ -6,7 +6,7 @@ MAINTAINERCLEANFILES = Makefile.in -SUBDIRS = basic bom dbadaptor factory config service core +SUBDIRS = basic bom dbadaptor factory command config service core #EXTRA_DIST = config_msvc.h EXTRA_DIST = Modified: trunk/stdair/stdair/STDAIR_Service.hpp =================================================================== --- trunk/stdair/stdair/STDAIR_Service.hpp 2010-02-07 02:48:33 UTC (rev 119) +++ trunk/stdair/stdair/STDAIR_Service.hpp 2010-02-07 19:43:30 UTC (rev 120) @@ -14,7 +14,7 @@ // Forward declarations class BomRoot; - + class Inventory; /** Interface for the STDAIR Services. */ class STDAIR_Service { @@ -43,6 +43,12 @@ ~STDAIR_Service(); + /** Retrieve the Inventory corresponding to the given airline code + (Inventory key). + <br>If not existing, a ObjectNotFoundException exception is thrown. */ + Inventory& getInventory (const AirlineCode_T& iAirlineCode) const; + + // ///////////////// Getters /////////////////// /** Get a reference on the BomRoot object. <br>If the service context has not been initialised, that @@ -51,6 +57,17 @@ return _bomRoot; } + public: + // /////// Construction and Destruction helper methods /////// + /** Retrieve the Inventory corresponding to the given airline code + (Inventory key). + <br>If not existing, a ObjectNotFoundException exception is thrown. */ + Inventory& createInventory (const AirlineCode_T& iAirlineCode) const; + + /** Add the airline-specific AirlineFeature object to its AirlineFeatureSet + parent. */ + void addAirlineFeature (const AirlineCode_T& iAirlineCode) const; + private: // /////// Construction and Destruction helper methods /////// @@ -76,6 +93,10 @@ in order to secure the access to the corresponding resources. */ void init (); + /** Initialise the AirlineFeatureSet object, and attach it to the + BomRoot. */ + void initAirlineFeatureSet (); + /** Finalise. */ void finalise (); Modified: trunk/stdair/stdair/bom/BomRoot.cpp =================================================================== --- trunk/stdair/stdair/bom/BomRoot.cpp 2010-02-07 02:48:33 UTC (rev 119) +++ trunk/stdair/stdair/bom/BomRoot.cpp 2010-02-07 19:43:30 UTC (rev 120) @@ -70,4 +70,10 @@ return oNetwork_ptr; } + // //////////////////////////////////////////////////////////////////// + AirlineFeatureSet& BomRoot::getAirlineFeatureSet() const { + assert (_airlineFeatureSet != NULL); + return *_airlineFeatureSet; + } + } Modified: trunk/stdair/stdair/bom/BomRoot.hpp =================================================================== --- trunk/stdair/stdair/bom/BomRoot.hpp 2010-02-07 02:48:33 UTC (rev 119) +++ trunk/stdair/stdair/bom/BomRoot.hpp 2010-02-07 19:43:30 UTC (rev 120) @@ -117,10 +117,7 @@ NetworkMap_T getNetworkMap () const; /** Get the reference of the AirlineFeatureSet object. */ - const AirlineFeatureSet& getAirlineFeatureSet() const { - assert (_airlineFeatureSet != NULL); - return *_airlineFeatureSet; - } + AirlineFeatureSet& getAirlineFeatureSet() const; /** Retrieve, if existing, the Inventory corresponding to the given airline code (Inventory key). @@ -135,7 +132,7 @@ public: // //////////// Setters ////////////// /** Set the reference to the AirlineFeatureSet object. */ - void setAirlineFeatureSet (const AirlineFeatureSet* ioAirlineFeatureSet_ptr){ + void setAirlineFeatureSet (AirlineFeatureSet* ioAirlineFeatureSet_ptr) { _airlineFeatureSet = ioAirlineFeatureSet_ptr; } @@ -161,7 +158,7 @@ BomStructure_T& _bomRootStructure; /** Set of all AirlineFeatures.*/ - const AirlineFeatureSet* _airlineFeatureSet; + AirlineFeatureSet* _airlineFeatureSet; }; } Modified: trunk/stdair/stdair/bom/BookingRequestStruct.cpp =================================================================== --- trunk/stdair/stdair/bom/BookingRequestStruct.cpp 2010-02-07 02:48:33 UTC (rev 119) +++ trunk/stdair/stdair/bom/BookingRequestStruct.cpp 2010-02-07 19:43:30 UTC (rev 120) @@ -33,7 +33,10 @@ // ////////////////////////////////////////////////////////////////////// const std::string BookingRequestStruct::describe() const { - return ""; + std::ostringstream oStr; + oStr << _origin << " - " << _destination << " " << _departureDate + << " " << _paxType << " " << _partySize; + return oStr.str(); } } Property changes on: trunk/stdair/stdair/command ___________________________________________________________________ Added: svn:ignore + .deps .libs Makefile.in Makefile Added: trunk/stdair/stdair/command/CmdAbstract.cpp =================================================================== --- trunk/stdair/stdair/command/CmdAbstract.cpp (rev 0) +++ trunk/stdair/stdair/command/CmdAbstract.cpp 2010-02-07 19:43:30 UTC (rev 120) @@ -0,0 +1,9 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// StdAir +#include <stdair/command/CmdAbstract.hpp> + +namespace stdair { + +} Added: trunk/stdair/stdair/command/CmdAbstract.hpp =================================================================== --- trunk/stdair/stdair/command/CmdAbstract.hpp (rev 0) +++ trunk/stdair/stdair/command/CmdAbstract.hpp 2010-02-07 19:43:30 UTC (rev 120) @@ -0,0 +1,17 @@ +#ifndef __STDAIR_CMD_CMDABSTRACT_HPP +#define __STDAIR_CMD_CMDABSTRACT_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// + +namespace stdair { + + /** Base class for the Command layer. */ + class CmdAbstract { + public: + + }; + +} +#endif // __STDAIR_CMD_CMDABSTRACT_HPP Added: trunk/stdair/stdair/command/DBManagerForAirlines.cpp =================================================================== --- trunk/stdair/stdair/command/DBManagerForAirlines.cpp (rev 0) +++ trunk/stdair/stdair/command/DBManagerForAirlines.cpp 2010-02-07 19:43:30 UTC (rev 120) @@ -0,0 +1,167 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +// SOCI +#include <soci/core/soci.h> +#include <soci/backends/mysql/soci-mysql.h> +// StdAir +#include <stdair/bom/AirlineStruct.hpp> +#include <stdair/dbadaptor/DbaAirline.hpp> +#include <stdair/service/Logger.hpp> +// Stdair +#include <stdair/command/DBManagerForAirlines.hpp> + +namespace stdair { + + // ////////////////////////////////////////////////////////////////////// + void DBManagerForAirlines:: + prepareSelectStatement (DBSession_T& ioSociSession, + DBRequestStatement_T& ioSelectStatement, + AirlineStruct& ioAirline) { + + try { + + // Instanciate a SQL statement (no request is performed at that stage) + /** + select code, name + from airlines; + */ + + ioSelectStatement = (ioSociSession.prepare + << "select iata_code, name " + << "from airlines ", soci::into (ioAirline)); + + // Execute the SQL query + ioSelectStatement.execute(); + + } catch (std::exception const& lException) { + STDAIR_LOG_ERROR ("Error: " << lException.what()); + throw SQLDatabaseException(); + } + } + + // ////////////////////////////////////////////////////////////////////// + void DBManagerForAirlines:: + prepareSelectOnAirlineCodeStatement (DBSession_T& ioSociSession, + DBRequestStatement_T& ioSelectStatement, + const AirlineCode_T& iAirlineCode, + AirlineStruct& ioAirline) { + + try { + + // Instanciate a SQL statement (no request is performed at that stage) + /** + select code, name + from airlines + where code = iAirlineCode; + */ + + ioSelectStatement = (ioSociSession.prepare + << "select iata_code, name " + << "from airlines " + << "where iata_code = :airline_code ", + soci::into (ioAirline), soci::use (iAirlineCode)); + + // Execute the SQL query + ioSelectStatement.execute(); + + } catch (std::exception const& lException) { + STDAIR_LOG_ERROR ("Error: " << lException.what()); + throw SQLDatabaseException(); + } + } + + // ////////////////////////////////////////////////////////////////////// + bool DBManagerForAirlines:: + iterateOnStatement (DBRequestStatement_T& ioStatement, + AirlineStruct& ioAirline) { + bool hasStillData = false; + + try { + + // Retrieve the next row of Airline object + hasStillData = ioStatement.fetch(); + + } catch (std::exception const& lException) { + STDAIR_LOG_ERROR ("Error: " << lException.what()); + throw SQLDatabaseException(); + } + + return hasStillData; + } + + // ////////////////////////////////////////////////////////////////////// + void DBManagerForAirlines::updateAirlineInDB (DBSession_T& ioSociSession, + const AirlineStruct& iAirline) { + + try { + + // Begin a transaction on the database + ioSociSession.begin(); + + // Retrieve the airline code + const std::string& lAirlineCode = iAirline.getAirlineCode(); + + // Retrieve the airline name + const std::string& lAirlineName = iAirline.getAirlineName(); + + // Instanciate a SQL statement (no request is performed at that stage) + DBRequestStatement_T lUpdateStatement = + (ioSociSession.prepare + << "update airlines " + << "set name = :name " + << "where iata_code = :iata_code", + soci::use (lAirlineName), soci::use (lAirlineCode)); + + // Execute the SQL query + lUpdateStatement.execute (true); + + // Commit the transaction on the database + ioSociSession.commit(); + + // Debug + // STDAIR_LOG_DEBUG ("[" << lAirlineCode << "] " << iAirline); + + } catch (std::exception const& lException) { + STDAIR_LOG_ERROR ("Error: " << lException.what()); + throw SQLDatabaseException(); + } + } + + // ////////////////////////////////////////////////////////////////////// + bool DBManagerForAirlines::retrieveAirline (DBSession_T& ioSociSession, + const AirlineCode_T& iAirlineCode, + AirlineStruct& ioAirline) { + bool oHasRetrievedAirline = false; + + try { + + // Prepare the SQL request corresponding to the select statement + DBRequestStatement_T lSelectStatement (ioSociSession); + prepareSelectOnAirlineCodeStatement (ioSociSession, lSelectStatement, + iAirlineCode, ioAirline); + + const bool shouldDoReset = true; + bool hasStillData = iterateOnStatement (lSelectStatement, ioAirline); + if (hasStillData == true) { + oHasRetrievedAirline = true; + } + + // Sanity check + const bool shouldNotDoReset = false; + hasStillData = iterateOnStatement (lSelectStatement, ioAirline); + + // Debug + // STDAIR_LOG_DEBUG ("[" << iDocID << "] " << ioAirline); + + } catch (std::exception const& lException) { + STDAIR_LOG_ERROR ("Error: " << lException.what()); + throw SQLDatabaseException(); + } + + return oHasRetrievedAirline; + } + +} Added: trunk/stdair/stdair/command/DBManagerForAirlines.hpp =================================================================== --- trunk/stdair/stdair/command/DBManagerForAirlines.hpp (rev 0) +++ trunk/stdair/stdair/command/DBManagerForAirlines.hpp 2010-02-07 19:43:30 UTC (rev 120) @@ -0,0 +1,74 @@ +#ifndef __DSIM_CMD_DBMANAGERFORAIRLINES_HPP +#define __DSIM_CMD_DBMANAGERFORAIRLINES_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// StdAir +#include <stdair/STDAIR_Types.hpp> +#include <stdair/command/CmdAbstract.hpp> + +namespace stdair { + + // Forward declarations + struct AirlineStruct; + + /** Class building the Business Object Model (BOM) from data retrieved + from the database. */ + class DBManagerForAirlines : public CmdAbstract { + public: + /** Update the fields of the database row + corresponding to the given BOM object. + @parameter DBSession_T& + @parameter AirlineStruct& . */ + static void updateAirlineInDB (DBSession_T&, const AirlineStruct&); + + /** Retrieve, from the (MySQL) database, the row corresponding to + the given BOM code, and fill the given BOM object with that retrieved + data. + @parameter DBSession_T& + @parameter const AirlineCode_T& + @parameter AirlineStruct& . */ + static bool retrieveAirline (DBSession_T&, const AirlineCode_T&, + AirlineStruct&); + + + public: + /** Prepare (parse and put in cache) the SQL statement. + @parameter DBSession_T& + @parameter DBRequestStatement_T& + @parameter AirlineStruct& . */ + static void prepareSelectStatement (DBSession_T&, DBRequestStatement_T&, + AirlineStruct&); + + /** Iterate on the SQL statement. + <br>The SQL has to be already prepared. + @parameter DBRequestStatement_T& + @parameter AirlineStruct& . */ + static bool iterateOnStatement (DBRequestStatement_T&, AirlineStruct&); + + + private: + /** Prepare (parse and put in cache) the SQL statement. + @parameter DBSession_T& + @parameter DBRequestStatement_T& + @parameter const AirlineCode_T& + @parameter AirlineStruct& */ + static void prepareSelectOnAirlineCodeStatement (DBSession_T&, + DBRequestStatement_T&, + const AirlineCode_T&, + AirlineStruct&); + + + private: + // /////////////////// Constructors and Destructors ////////////// + /** Default constructors. As all the methods are static, there is no + need to use those constructors. */ + DBManagerForAirlines () {} + DBManagerForAirlines (const DBManagerForAirlines&) {} + /** Destructor. */ + ~DBManagerForAirlines () {} + }; + +} +#endif // __DSIM_CMD_DBMANAGERFORAIRLINES_HPP Added: trunk/stdair/stdair/command/Makefile.am =================================================================== --- trunk/stdair/stdair/command/Makefile.am (rev 0) +++ trunk/stdair/stdair/command/Makefile.am 2010-02-07 19:43:30 UTC (rev 120) @@ -0,0 +1,16 @@ +## command sub-directory +include $(top_srcdir)/Makefile.common +include $(srcdir)/sources.mk + +# +noinst_LTLIBRARIES = libcmd.la + +libcmd_la_SOURCES = $(cmd_h_sources) $(cmd_cc_sources) +libcmd_la_CXXFLAGS = $(BOOST_CFLAGS) $(SOCI_CFLAGS) +libcmd_la_LIBADD = +libcmd_la_LDFLAGS = $(BOOST_LIBS) $(SOCI_LIBS) + + +# Header files +pkgincludedir = $(includedir)/stdair/command +pkginclude_HEADERS = $(cmd_h_sources) Added: trunk/stdair/stdair/command/sources.mk =================================================================== --- trunk/stdair/stdair/command/sources.mk (rev 0) +++ trunk/stdair/stdair/command/sources.mk 2010-02-07 19:43:30 UTC (rev 120) @@ -0,0 +1,6 @@ +cmd_h_sources = \ + $(top_srcdir)/stdair/command/CmdAbstract.hpp \ + $(top_srcdir)/stdair/command/DBManagerForAirlines.hpp +cmd_cc_sources = \ + $(top_srcdir)/stdair/command/CmdAbstract.cpp \ + $(top_srcdir)/stdair/command/DBManagerForAirlines.cpp Modified: trunk/stdair/stdair/core/Makefile.am =================================================================== --- trunk/stdair/stdair/core/Makefile.am 2010-02-07 02:48:33 UTC (rev 119) +++ trunk/stdair/stdair/core/Makefile.am 2010-02-07 19:43:30 UTC (rev 120) @@ -18,6 +18,7 @@ $(top_builddir)/stdair/bom/libbom.la \ $(top_builddir)/stdair/dbadaptor/libdba.la \ $(top_builddir)/stdair/factory/libfac.la \ + $(top_builddir)/stdair/command/libcmd.la \ $(top_builddir)/stdair/service/libsvc.la libstdair_la_LDFLAGS = \ $(BOOST_DATE_TIME_LIB) $(BOOST_PROGRAM_OPTIONS_LIB) \ Modified: trunk/stdair/stdair/service/STDAIR_Service.cpp =================================================================== --- trunk/stdair/stdair/service/STDAIR_Service.cpp 2010-02-07 02:48:33 UTC (rev 119) +++ trunk/stdair/stdair/service/STDAIR_Service.cpp 2010-02-07 19:43:30 UTC (rev 120) @@ -7,8 +7,13 @@ #include <stdair/basic/BasChronometer.hpp> #include <stdair/bom/BomManager.hpp> // for display() #include <stdair/bom/BomRoot.hpp> -#include <stdair/bom/Inventory.hpp> // Child of BomRoot, needed for creation of BomRoot -#include <stdair/bom/Network.hpp> // Child of BomRoot, needed for creation of BomRoot +#include <stdair/bom/AirlineFeatureSet.hpp> +#include <stdair/bom/AirlineFeature.hpp> +// Inventory: child of BomRoot, needed for creation of BomRoot +#include <stdair/bom/Inventory.hpp> +// Network: child of BomRoot, needed for creation of BomRoot +#include <stdair/bom/Network.hpp> +#include <stdair/bom/FlightDate.hpp> #include <stdair/factory/FacSupervisor.hpp> #include <stdair/factory/FacBomContent.hpp> #include <stdair/service/Logger.hpp> @@ -35,6 +40,9 @@ // The root of the BOM tree, on which all of the other BOM objects // will be attached, is being created with the STDAIR_Service constructor. + // Initialise the AirlineFeatureSet object, and attach it to the BomRoot + initAirlineFeatureSet (); + // Set the log file logInit (iLogParams); @@ -49,6 +57,9 @@ // The root of the BOM tree, on which all of the other BOM objects // will be attached, is being created with the STDAIR_Service constructor. + // Initialise the AirlineFeatureSet object, and attach it to the BomRoot + initAirlineFeatureSet (); + // Set the log file logInit (iLogParams); @@ -78,12 +89,92 @@ // ////////////////////////////////////////////////////////////////////// void STDAIR_Service::init () { } + + // ////////////////////////////////////////////////////////////////////// + void STDAIR_Service::initAirlineFeatureSet () { + // Initialise the set of required airline features + stdair::AirlineFeatureSet& lAirlineFeatureSet = + stdair::FacBomContent::instance().create<stdair::AirlineFeatureSet>(); + + // Set the AirlineFeatureSet for the BomRoot. + _bomRoot.setAirlineFeatureSet (&lAirlineFeatureSet); + } // ////////////////////////////////////////////////////////////////////// + void STDAIR_Service:: + addAirlineFeature (const AirlineCode_T& iAirlineCode) const { + + // Initialise an AirlineFeature object + stdair::AirlineFeatureKey_T lAirlineFeatureKey (iAirlineCode); + stdair::AirlineFeature& lAirlineFeature = stdair::FacBomContent:: + instance().create<stdair::AirlineFeature> (lAirlineFeatureKey); + + // Retrieve the AirlineFeatureSet object + stdair::AirlineFeatureSet& lAirlineFeatureSet = + _bomRoot.getAirlineFeatureSet(); + + // Add the AirlineFeature object to its AirlineFeatureSet parent + stdair::FacBomContent:: + linkWithParent<stdair::AirlineFeature> (lAirlineFeature, + lAirlineFeatureSet); + } + + // ////////////////////////////////////////////////////////////////////// void STDAIR_Service::finalise () { - // std::cout << "In STDAIR_Service destructor, before cleaning" << std::endl; + //std::cout << "In STDAIR_Service destructor, before cleaning" << std::endl; FacSupervisor::cleanAll(); - // std::cout << "In STDAIR_Service destructor, after cleaning" << std::endl; + //std::cout << "In STDAIR_Service destructor, after cleaning" << std::endl; } + // ////////////////////////////////////////////////////////////////////// + Inventory& STDAIR_Service:: + getInventory (const AirlineCode_T& iAirlineCode) const { + + Inventory* lInventory_ptr = _bomRoot.getInventory (iAirlineCode); + if (lInventory_ptr == NULL) { + throw ObjectNotFoundException(); + } + assert (lInventory_ptr != NULL); + + return *lInventory_ptr; + } + + // ////////////////////////////////////////////////////////////////////// + Inventory& STDAIR_Service:: + createInventory (const AirlineCode_T& iAirlineCode) const { + Inventory* lInventory_ptr = _bomRoot.getInventory (iAirlineCode); + + // If there is no Inventory object for that airline already, create one + if (lInventory_ptr == NULL) { + const stdair::InventoryKey_T lInventoryKey (iAirlineCode); + + // Instantiate an Inventory object with the given airline code + lInventory_ptr = + &stdair::FacBomContent::instance(). + create<stdair::Inventory> (lInventoryKey); + assert (lInventory_ptr != NULL); + + // Link the created inventory with the bom root. + stdair::FacBomContent::linkWithParent<stdair::Inventory> (*lInventory_ptr, + _bomRoot); + + // Set the AirlineFeature for the inventory. + const stdair::AirlineFeatureSet& lAirlineFeatureSet = + _bomRoot.getAirlineFeatureSet (); + const stdair::AirlineFeature* lAirlineFeature_ptr = + lAirlineFeatureSet.getAirlineFeature (iAirlineCode); + + // TODO: throw an exception? + if (lAirlineFeature_ptr == NULL) { + STDAIR_LOG_ERROR (lAirlineFeatureSet.display() + << "Needed airline code: " << iAirlineCode); + } + + lInventory_ptr->setAirlineFeature (lAirlineFeature_ptr); + } + assert (lInventory_ptr != NULL); + + return *lInventory_ptr; + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qua...@us...> - 2010-02-08 16:32:16
|
Revision: 124 http://stdair.svn.sourceforge.net/stdair/?rev=124&view=rev Author: quannaus Date: 2010-02-08 16:32:09 +0000 (Mon, 08 Feb 2010) Log Message: ----------- [Dev] Added the objects for trademgen use. Still need to refine the code. Modified Paths: -------------- trunk/stdair/stdair/STDAIR_Types.hpp trunk/stdair/stdair/basic/BasConst.cpp trunk/stdair/stdair/basic/BasConst_General.hpp trunk/stdair/stdair/basic/sources.mk trunk/stdair/stdair/bom/BookingRequestStruct.cpp trunk/stdair/stdair/bom/BookingRequestStruct.hpp trunk/stdair/stdair/bom/sources.mk Added Paths: ----------- trunk/stdair/stdair/basic/CategoricalAttribute.hpp trunk/stdair/stdair/basic/ContinuousAttribute.hpp trunk/stdair/stdair/basic/DemandCharacteristics.cpp trunk/stdair/stdair/basic/DemandCharacteristics.hpp trunk/stdair/stdair/basic/DemandDistribution.cpp trunk/stdair/stdair/basic/DemandDistribution.hpp trunk/stdair/stdair/basic/RandomGeneration.cpp trunk/stdair/stdair/basic/RandomGeneration.hpp trunk/stdair/stdair/basic/RandomGenerationContext.cpp trunk/stdair/stdair/basic/RandomGenerationContext.hpp trunk/stdair/stdair/bom/DemandStream.cpp trunk/stdair/stdair/bom/DemandStream.hpp trunk/stdair/stdair/bom/EventQueue.cpp trunk/stdair/stdair/bom/EventQueue.hpp trunk/stdair/stdair/bom/EventStruct.cpp trunk/stdair/stdair/bom/EventStruct.hpp Modified: trunk/stdair/stdair/STDAIR_Types.hpp =================================================================== --- trunk/stdair/stdair/STDAIR_Types.hpp 2010-02-08 09:22:21 UTC (rev 123) +++ trunk/stdair/stdair/STDAIR_Types.hpp 2010-02-08 16:32:09 UTC (rev 124) @@ -7,7 +7,10 @@ // STL #include <string> #include <vector> +#include <list> #include <map> +// Boost Random +#include <boost/random/linear_congruential.hpp> // Boost (Extended STL) #include <boost/date_time/gregorian/gregorian.hpp> #include <boost/date_time/posix_time/posix_time.hpp> @@ -123,6 +126,9 @@ /** Define the Duration (e.g., elapsed in-flight time). */ typedef boost::posix_time::time_duration Duration_T; + /** Time */ + typedef boost::posix_time::time_duration Time_T; + /** Define an accurate time (date +time). */ typedef boost::posix_time::ptime DateTime_T; @@ -388,6 +394,56 @@ /** Pointer on the STDAIR Service handler. */ typedef boost::shared_ptr<STDAIR_Service> STDAIR_ServicePtr_T; + + // ////////////////////////////////////////////////////////////////////// + // Random generation + /** Seed for the random generation, so that it can be reproductible. */ + typedef unsigned long int RandomSeed_T; + /** Random number generator. */ + typedef boost::minstd_rand BaseGenerator_T; + + // ////////////////////////////////////////////////////////////////////// + // Probability + /** Probability */ + typedef float Probability_T; + + // ////////////////////////////////////////////////////////////////////// + // Date / Time + /** Time duration in (integer) number of seconds */ + typedef long int IntDuration_T; + + /** Duration in (float) number of time units */ + typedef float FloatDuration_T; + + // ////////////////////////////////////////////////////////////////////// + // Basic types + /** Event type */ + typedef std::string EventType_T; + + /** Count */ + typedef int Count_T; + + /** Location code */ + typedef std::string LocationCode_T; + + /** Airport code */ + typedef LocationCode_T AirportCode_T; + + /** City code */ + typedef LocationCode_T CityCode_T; + + /** Trip type */ + typedef std::string TripType_T; + + /** Monetary value */ + typedef double MonetaryValue_T; + + /** Real number */ + typedef double RealNumber_T; + + // ////////////////////////////////////////////////////////////////////// + // Demand + typedef int DemandStreamKey_T; } #endif // __STDAIR_STDAIR_TYPES_HPP Modified: trunk/stdair/stdair/basic/BasConst.cpp =================================================================== --- trunk/stdair/stdair/basic/BasConst.cpp 2010-02-08 09:22:21 UTC (rev 123) +++ trunk/stdair/stdair/basic/BasConst.cpp 2010-02-08 16:32:09 UTC (rev 124) @@ -129,22 +129,18 @@ const DateOffSet_T DEFAULT_DATE_OFFSET (0); // // //////// General /////// - // /** Default update date for the General. */ - // const Date_T DEFAULT_WORLD_SCHEDULE_UPDATE_DATE (2007, - // boost::gregorian::Jan, - // 1); + /** Default update date for the General. */ + const Date_T DEFAULT_DATE (2007, boost::gregorian::Jan, 1); + /** Default update date&time. */ + const DateTime_T DEFAULT_DATETIME (DEFAULT_DATE, NULL_BOOST_TIME_DURATION); - // // //////// WholeDemand /////// - // /** Default update date for the WholeDemand. */ - // const Date_T DEFAULT_WHOLE_DEMAND_UPDATE_DATE (2007, - // boost::gregorian::Jan, - // 1); + /** Number of seconds in one day */ + const Count_T SECONDS_IN_ONE_DAY = 86000; + + /** Number of milliseconds in one second */ + const Count_T MILLISECONDS_IN_ONE_SECOND = 1000; - // /** Default update date&time. */ - // const DateTime_T DEFAULT_DEMAND_DATETIME (DEFAULT_WHOLE_DEMAND_UPDATE_DATE, - // NULL_BOOST_TIME_DURATION); - // //////// Fare Rules /////// /** Default saturdayStay value (false). */ const SaturdayStay_T DEFAULT_SATURDAY_STAY = false; Modified: trunk/stdair/stdair/basic/BasConst_General.hpp =================================================================== --- trunk/stdair/stdair/basic/BasConst_General.hpp 2010-02-08 09:22:21 UTC (rev 123) +++ trunk/stdair/stdair/basic/BasConst_General.hpp 2010-02-08 16:32:09 UTC (rev 124) @@ -36,5 +36,16 @@ /** Default booking rate for OnD bookings over overall class bookings. */ extern const BookingRatio_T DEFAULT_OND_BOOKING_RATE; + /** Number of seconds in one day */ + extern const Count_T SECONDS_IN_ONE_DAY; + + /** Number of milliseconds in one second */ + extern const Count_T MILLISECONDS_IN_ONE_SECOND; + + /** Default update date for the General. */ + extern const Date_T DEFAULT_DATE; + + /** Default update date&time. */ + extern const DateTime_T DEFAULT_DATETIME; } #endif // __STDAIR_BAS_BASCONST_GENERAL_HPP Added: trunk/stdair/stdair/basic/CategoricalAttribute.hpp =================================================================== --- trunk/stdair/stdair/basic/CategoricalAttribute.hpp (rev 0) +++ trunk/stdair/stdair/basic/CategoricalAttribute.hpp 2010-02-08 16:32:09 UTC (rev 124) @@ -0,0 +1,98 @@ +#ifndef __STDAIR_BAS_CATEGORICALATTRIBUTE_HPP +#define __STDAIR_BAS_CATEGORICALATTRIBUTE_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <map> +#include <iosfwd> +// STDAIR +#include <stdair/STDAIR_Types.hpp> + +namespace stdair { + + /** Class modeling the distribution of values that can be taken by a + categorical attribute. */ + template <class T> + struct CategoricalAttribute { + + public: + // ///////////// Getters /////////// + /** Get the probability mass function. */ + const std::map<T,Probability_T>& getProbabilityMassFunction() const { + return _probability_mass_function; + } + + /** Get the inverse cumulative distribution. */ + const std::map<Probability_T, T>& getInverseCumulativeDistribution () const { + return _inverse_cumulative_distribution; + } + + // ///////////// Setters /////////// + /** Set the probability mass function */ + void setProbabilityMassFunction (const std::map<T, Probability_T>& iProbabilityMassFunction) { + _probability_mass_function = iProbabilityMassFunction; + determineInverseCumulativeDistributionFromProbabilityMassFunction(); + } + + public: + // /////////////// Business Methods ////////// + /** Get value from inverse cumulative distribution. */ + T getValue(Probability_T iCumulativeProbability) { + return _inverse_cumulative_distribution.lower_bound(iCumulativeProbability)->second; + } + + public: + // ////////////// Display Support Methods ////////// + /** Display inverse cumulative distribution */ + void displayInverseCumulativeDistribution (std::ostream& ioStream) const { + for (typename std::map<Probability_T, T>::const_iterator it = _inverse_cumulative_distribution.begin(); + it != _inverse_cumulative_distribution.end(); ++it) { + ioStream << "cumulative prob: " << it->first + << " value: " << it->second << std::endl; + } + } + + public: + // ////////// Constructors and destructors ///////// + /** Constructor by default */ + CategoricalAttribute (const std::map<T, Probability_T>& iProbabilityMassFunction) + : _probability_mass_function (iProbabilityMassFunction) { + determineInverseCumulativeDistributionFromProbabilityMassFunction(); + } + + /** Destructor */ + virtual ~CategoricalAttribute () { } + + private: + /** Default constructors. */ + CategoricalAttribute (); + CategoricalAttribute (const CategoricalAttribute&); + + /** Determine inverse cumulative distribution from probability mass function (initialisation). */ + void determineInverseCumulativeDistributionFromProbabilityMassFunction () { + Probability_T cumulative_probability_so_far = 0.0; + for (typename std::map<T, Probability_T>::const_iterator itProbabilityMassFunction = _probability_mass_function.begin(); + itProbabilityMassFunction != _probability_mass_function.end(); + ++itProbabilityMassFunction) { + Probability_T attribute_probability_mass = itProbabilityMassFunction->second; + if (attribute_probability_mass > 0) { + T attribute_value = itProbabilityMassFunction->first; + cumulative_probability_so_far += attribute_probability_mass; + _inverse_cumulative_distribution[cumulative_probability_so_far] = attribute_value; + } + } + } + + private: + // ////////// Attributes ////////// + /** Probability mass function */ + std::map<T, Probability_T> _probability_mass_function; + + /** Inverse cumulative distribution */ + std::map<Probability_T, T> _inverse_cumulative_distribution; + + }; +} +#endif // __STDAIR_BAS_CATEGORICALATTRIBUTE_HPP Added: trunk/stdair/stdair/basic/ContinuousAttribute.hpp =================================================================== --- trunk/stdair/stdair/basic/ContinuousAttribute.hpp (rev 0) +++ trunk/stdair/stdair/basic/ContinuousAttribute.hpp 2010-02-08 16:32:09 UTC (rev 124) @@ -0,0 +1,143 @@ +#ifndef __STDAIR_BAS_CONTINUOUSATTRIBUTE_HPP +#define __STDAIR_BAS_CONTINUOUSATTRIBUTE_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <string> +#include <map> +// STDAIR +#include <stdair/STDAIR_Types.hpp> + +namespace stdair { + + /** Class modeling the distribution of values that can be taken by a + continuous attribute. */ + template <class T> + struct ContinuousAttribute { + public: + // ///////////// Getters /////////// + /** Get the cumulative distribution. */ + const std::multimap<T,Probability_T>& getCumulativeDistribution() const { + return _cumulativeDistribution; + } + + /** Get the inverse cumulative distribution. */ + const std::multimap<Probability_T, T>& + getInverseCumulativeDistribution () const { + return _inverseCumulativeDistribution; + } + + public: + // ///////////// Setters /////////// + /** Set the cumulative distribution */ + void setCumulativeDistribution (const std::multimap<T, Probability_T>& iCumulativeDistribution) { + _cumulativeDistribution = iCumulativeDistribution; + determineInverseCumulativeDistributionFromCumulativeDistribution(); + } + + public: + // /////////////// Business Methods ////////// + /** Get value from inverse cumulative distribution. */ + const T getValue(const Probability_T& iCumulativeProbability) const { + typename std::multimap<Probability_T, T>::const_iterator it = + _inverseCumulativeDistribution.lower_bound (iCumulativeProbability); + + Probability_T cumulativeProbabilityNextPoint = it->first; + T valueNextPoint = it->second; + + if (it == _inverseCumulativeDistribution.begin()) { + std::cout << "hello" << std::endl; + return valueNextPoint; + } + --it; + + Probability_T cumulativeProbabilityPreviousPoint = it->first; + T valuePreviousPoint = it->second; + if (cumulativeProbabilityNextPoint == cumulativeProbabilityPreviousPoint) { + //std::cout << "hlelo2" << std::endl; + return valuePreviousPoint; + } + + //std::cout << "cumulativeProbabilityPreviousPoint: " << cumulativeProbabilityPreviousPoint << std::endl; + //std::cout << "cumulativeProbabilityNextPoint: " << cumulativeProbabilityNextPoint << std::endl; + //std::cout << "valuePreviousPoint: " << valuePreviousPoint << std::endl; + //std::cout << "valueNextPoint: " << valueNextPoint << std::endl; + + return valuePreviousPoint + (valueNextPoint - valuePreviousPoint) + * (iCumulativeProbability - cumulativeProbabilityPreviousPoint) + / (cumulativeProbabilityNextPoint - cumulativeProbabilityPreviousPoint); + } + + public: + // ////////////// Display Support Methods ////////// + /** Display cumulative distribution */ + std::string displayCumulativeDistribution() const { + std::ostringstream oStr; + for (typename std::multimap<T, Probability_T>::const_iterator it = + _cumulativeDistribution.begin(); + it != _cumulativeDistribution.end(); ++it) { + oStr << "value: " << it->first + << " cumulative probability: " << it->second << std::endl; + } + return oStr.str(); + } + + /** Display inverse cumulative distribution */ + std::string displayInverseCumulativeDistribution() const { + std::ostringstream oStr; + for (typename std::multimap<Probability_T, T>::const_iterator it = + _inverseCumulativeDistribution.begin(); + it != _inverseCumulativeDistribution.end(); ++it) { + oStr << "cumulative prob: " << it->first + << " value: " << it->second << std::endl; + } + return oStr.str(); + } + + public: + // ////////// Constructors and destructors ///////// + /** Constructor by default */ + ContinuousAttribute () { } + + /** Constructor */ + ContinuousAttribute (const std::multimap<T, Probability_T>& iCumulativeDistribution) : _cumulativeDistribution (iCumulativeDistribution) { + determineInverseCumulativeDistributionFromCumulativeDistribution(); + } + + /** Copy constructor */ + ContinuousAttribute (const ContinuousAttribute& iContinuousAttribute) + : _cumulativeDistribution (iContinuousAttribute._cumulativeDistribution), + _inverseCumulativeDistribution (iContinuousAttribute._inverseCumulativeDistribution) { + } + + /** Destructor */ + virtual ~ContinuousAttribute () { } + + /** Determine inverse cumulative distribution from cumulative + distribution (initialisation). */ + void determineInverseCumulativeDistributionFromCumulativeDistribution () { + for (typename std::multimap<T, Probability_T>::iterator itCumulativeDistribution = + _cumulativeDistribution.begin(); + itCumulativeDistribution != _cumulativeDistribution.end(); + ++itCumulativeDistribution) { + _inverseCumulativeDistribution. + insert ( std::pair<float, float> (itCumulativeDistribution->second, + itCumulativeDistribution->first) ); + } + } + + private: + // ////////// Attributes ////////// + + /** Cumulative distribution */ + std::multimap<T, Probability_T> _cumulativeDistribution; + + /** Inverse cumulative distribution */ + std::multimap<Probability_T, T> _inverseCumulativeDistribution; + + }; + +} +#endif // __STDAIR_BAS_CONTINUOUSATTRIBUTE_HPP Added: trunk/stdair/stdair/basic/DemandCharacteristics.cpp =================================================================== --- trunk/stdair/stdair/basic/DemandCharacteristics.cpp (rev 0) +++ trunk/stdair/stdair/basic/DemandCharacteristics.cpp 2010-02-08 16:32:09 UTC (rev 124) @@ -0,0 +1,50 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +#include <sstream> +// STDAIR +#include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/DemandCharacteristics.hpp> + +namespace stdair { + + // ///////////////////////////////////////////////////// + DemandCharacteristics::DemandCharacteristics () + : _origin ("") { + } + + // ///////////////////////////////////////////////////// + DemandCharacteristics::~DemandCharacteristics () { + } + + // ///////////////////////////////////////////////////// + DemandCharacteristics:: + DemandCharacteristics (const DemandCharacteristics& iDemandCharacteristics) { + _origin = iDemandCharacteristics._origin; + _preferredDepartureDate = iDemandCharacteristics._preferredDepartureDate; + _arrivalPattern = iDemandCharacteristics._arrivalPattern; + } + + // ///////////////////////////////////////////////////// + std::string DemandCharacteristics::display() const { + std::ostringstream oStr; + + // + oStr << "****************** Demand characteristics ******************"; + oStr << "Origin ........................... : " + << _origin << std::endl; + oStr << "Preferred departure date ......... : " + << _preferredDepartureDate << std::endl; + oStr << "Arrival pattern (days from departure, proportion):" + << std::endl; + + // + oStr << _arrivalPattern.displayCumulativeDistribution(); + + return oStr.str(); + } + +} + Added: trunk/stdair/stdair/basic/DemandCharacteristics.hpp =================================================================== --- trunk/stdair/stdair/basic/DemandCharacteristics.hpp (rev 0) +++ trunk/stdair/stdair/basic/DemandCharacteristics.hpp 2010-02-08 16:32:09 UTC (rev 124) @@ -0,0 +1,92 @@ +#ifndef __STDAIR_BAS_DEMAND_CHARACTERISTICS_HPP +#define __STDAIR_BAS_DEMAND_CHARACTERISTICS_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <string> +// STDAIR +#include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/ContinuousAttribute.hpp> + +namespace stdair { + + /** Class modeling the characteristics of a demand type. */ + struct DemandCharacteristics { + public: + + // ///////////// Getters /////////// + /** Get the origin. */ + const LocationCode_T& getOrigin() const { + return _origin; + } + + /** Get the preferred departure date. */ + const Date_T& getPreferredDepartureDate() const { + return _preferredDepartureDate; + } + + /** Get the arrival pattern. */ + const ContinuousAttribute<FloatDuration_T>& getArrivalPattern() const { + return _arrivalPattern; + } + + public: + // ///////////// Setters /////////// + /** Set the origin. */ + void setOrigin (const LocationCode_T& iOrigin) { + _origin = iOrigin; + } + + /** Set the preferred departure date. */ + void setPreferredDepartureDate (const Date_T& iPreferredDepartureDate) { + _preferredDepartureDate = iPreferredDepartureDate; + } + + /** Set the arrival pattern. */ + void setArrivalPattern (const ContinuousAttribute<FloatDuration_T>& iArrivalPattern) { + _arrivalPattern = iArrivalPattern; + } + + public: + // ////////////// Display Support Methods ////////// + /** Display demand characteristics */ + std::string display() const; + + + public: + // ////////// Constructors and destructors ///////// + /** Constructor by default */ + DemandCharacteristics (); + + /** Copy constructor */ + DemandCharacteristics (const DemandCharacteristics&); // Should be private, but well... + + /** Destructor */ + virtual ~DemandCharacteristics (); + + + private: + // ////////// Attributes ////////// + /** Origin */ + LocationCode_T _origin; + + /** Preferred departure date */ + Date_T _preferredDepartureDate; + + /** Arrival pattern (cumulative distribution of timing of arrival + of requests (negative number of days between departure date + and request date)*/ + ContinuousAttribute<FloatDuration_T> _arrivalPattern; + + /** Trip type probability mass */ + //CategoricalAttribute<TripType_T> _tripTypeProbabilityMass; + + /** Willingness-to-pay cumulative distribution */ + //ContinuousAttribute<MonetaryValue_T> _willingnessToPayCumulativeDistribution; + + }; + +} +#endif // __STDAIR_BAS_DEMAND_CHARACTERISTICS_HPP Added: trunk/stdair/stdair/basic/DemandDistribution.cpp =================================================================== --- trunk/stdair/stdair/basic/DemandDistribution.cpp (rev 0) +++ trunk/stdair/stdair/basic/DemandDistribution.cpp 2010-02-08 16:32:09 UTC (rev 124) @@ -0,0 +1,44 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +#include <sstream> +// STDAIR +#include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/DemandDistribution.hpp> + +namespace stdair { + + // ///////////////////////////////////////////////////// + DemandDistribution::DemandDistribution () { + } + + // ///////////////////////////////////////////////////// + DemandDistribution::~DemandDistribution () { + } + + // ///////////////////////////////////////////////////// + DemandDistribution:: + DemandDistribution (const DemandDistribution& iDemandDistribution) { + _meanNumberOfRequests = iDemandDistribution._meanNumberOfRequests; + _standardDeviationNumberOfRequests = + iDemandDistribution._standardDeviationNumberOfRequests; + } + + // ///////////////////////////////////////////////////// + std::string DemandDistribution::display() const { + std::ostringstream oStr; + + oStr << "****************** Demand distribution ******************" + << std::endl; + oStr << "Mean number of requests .......... : " + << _meanNumberOfRequests << std::endl; + oStr << "Std dev of number of requests .... : " + << _standardDeviationNumberOfRequests << std::endl; + + return oStr.str(); + } + +} + Added: trunk/stdair/stdair/basic/DemandDistribution.hpp =================================================================== --- trunk/stdair/stdair/basic/DemandDistribution.hpp (rev 0) +++ trunk/stdair/stdair/basic/DemandDistribution.hpp 2010-02-08 16:32:09 UTC (rev 124) @@ -0,0 +1,70 @@ +#ifndef __STDAIR_BAS_DEMAND_DISTRIBUTION_HPP +#define __STDAIR_BAS_DEMAND_DISTRIBUTION_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <string> +// STDAIR +#include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/ContinuousAttribute.hpp> + +namespace stdair { + + /** Class modeling the distribution of a demand type. */ + struct DemandDistribution { + public: + + // ///////////// Getters /////////// + /** Get the mean number of requests. */ + const RealNumber_T& getMeanNumberOfRequests() const { + return _meanNumberOfRequests; + } + + /** Get the standard deviation of number of requests. */ + const RealNumber_T& getStandardDeviationNumberOfRequests() const { + return _standardDeviationNumberOfRequests; + } + + public: + // ///////////// Setters /////////// + /** Set the mean number of requests. */ + void setMeanNumberOfRequests (const RealNumber_T& iMean) { + _meanNumberOfRequests = iMean; + } + + /** Set the standard deviation of number of requests. */ + void setStandardDeviationNumberOfRequests (const RealNumber_T& iStandardDeviation) { + _standardDeviationNumberOfRequests = iStandardDeviation; + } + + public: + // ////////////// Display Support Methods ////////// + /** Display demand distribution */ + std::string display() const; + + + public: + // ////////// Constructors and destructors ///////// + /** Constructor by default */ + DemandDistribution (); + + /** Copy constructor */ + DemandDistribution (const DemandDistribution&); // Should be private, but well... + + /** Destructor */ + virtual ~DemandDistribution (); + + + private: + // ////////// Attributes ////////// + /** Mean number of requests */ + RealNumber_T _meanNumberOfRequests; + + /** Standard deviation of number of requests */ + RealNumber_T _standardDeviationNumberOfRequests; + }; + +} +#endif // __STDAIR_BAS_DEMAND_DISTRIBUTION_HPP Added: trunk/stdair/stdair/basic/RandomGeneration.cpp =================================================================== --- trunk/stdair/stdair/basic/RandomGeneration.cpp (rev 0) +++ trunk/stdair/stdair/basic/RandomGeneration.cpp 2010-02-08 16:32:09 UTC (rev 124) @@ -0,0 +1,50 @@ +// STL +#include <cassert> +#include <iostream> +// Boost +#include <boost/math/distributions/normal.hpp> +//STDAIR +#include <stdair/basic/RandomGeneration.hpp> + +namespace stdair { + + // ////////////////////////////////////////////////////////////////////// + RandomGeneration::RandomGeneration (const RandomSeed_T& iSeed) + : _seed (iSeed), _generator (iSeed), + _uniformGenerator (_generator, boost::uniform_real<> (0, 1)) { + init (); + } + + // ////////////////////////////////////////////////////////////////////// + RandomGeneration::~RandomGeneration () { + } + + // ////////////////////////////////////////////////////////////////////// + void RandomGeneration::init () { + } + + // ////////////////////////////////////////////////////////////////////// + RealNumber_T RandomGeneration::generateUniform01 () { + const RealNumber_T lVariateUnif = _uniformGenerator(); + return lVariateUnif; + } + + // ////////////////////////////////////////////////////////////////////// + RealNumber_T RandomGeneration:: + generateUniform (const RealNumber_T& iMinValue, const RealNumber_T& iMaxValue){ + const RealNumber_T lVariateUnif = + iMinValue + _uniformGenerator() * (iMaxValue - iMinValue); + return lVariateUnif; + } + + // ////////////////////////////////////////////////////////////////////// + RealNumber_T RandomGeneration:: + generateNormal (const RealNumber_T& mu, const RealNumber_T& sigma) { + const Probability_T lVariateUnif = generateUniform01 (); + const boost::math::normal lNormal (mu, sigma); + const RealNumber_T lRealNumberOfRequestsToBeGenerated = + boost::math::quantile(lNormal, lVariateUnif); + + return lRealNumberOfRequestsToBeGenerated; + } +} Added: trunk/stdair/stdair/basic/RandomGeneration.hpp =================================================================== --- trunk/stdair/stdair/basic/RandomGeneration.hpp (rev 0) +++ trunk/stdair/stdair/basic/RandomGeneration.hpp 2010-02-08 16:32:09 UTC (rev 124) @@ -0,0 +1,74 @@ +#ifndef __STDAIR_BAS_BOM_RANDOMGENERATION_HPP +#define __STDAIR_BAS_BOM_RANDOMGENERATION_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// Boost Random +#include <boost/random/uniform_real.hpp> +#include <boost/random/variate_generator.hpp> +// STDAIR +#include <stdair/STDAIR_Types.hpp> + +namespace stdair { + + /** Random generator. */ + struct RandomGeneration { + public: + // ///////////// Getters /////////// + /** Get the seed of the random generator. */ + const RandomSeed_T& getSeed () const { + return _seed; + } + + // //////////// Business Methods ///////////// + /** Generate a randomized number following a uniform distribution between 0 (included) and 1 (excluded). */ + RealNumber_T generateUniform01 (); + + /** Generate a randomized number following a uniform distribution between a minimum (included) and a maximum (excluded) value. */ + RealNumber_T generateUniform (const RealNumber_T&, const RealNumber_T&); + + /** Generate a randomized number following a normal distribution specified by a mean and a standard deviation. */ + RealNumber_T generateNormal (const RealNumber_T&, const RealNumber_T&); + + public: + // ////////// Constructors and destructors ///////// + /** Constructor. */ + RandomGeneration (const RandomSeed_T&); + + /** Destructor. */ + virtual ~RandomGeneration (); + + private: + /** Default constructors. */ + RandomGeneration (); + RandomGeneration (const RandomGeneration&); + + /** Initialize the random generator. + <br>A uniform random number distribution is defined, which + produces "real" values between 0 and 1 (0 inclusive, 1 + exclusive). */ + void init (); + + + private: + // ////////// Attributes ////////// + /** The seed of the random generator. + <br>The seed is unsigned, otherwise the wrong overload may be + selected when using mt19937 as the boost::base_generator_type. */ + RandomSeed_T _seed; + + /** Random number generator engine. + <br>The random number generator is currently based on boost::minstd_rand. + Alternates are boost::mt19937, boost::ecuyer1988. */ + BaseGenerator_T _generator; + + /** Random number generator. + <br>It is initialized with a reproducible seed and a uniform + distribution. */ + boost::variate_generator<BaseGenerator_T&, + boost::uniform_real<> > _uniformGenerator; + }; + +} +#endif // __STDAIR_BAS_BOM_RANDOMGENERATION_HPP Added: trunk/stdair/stdair/basic/RandomGenerationContext.cpp =================================================================== --- trunk/stdair/stdair/basic/RandomGenerationContext.cpp (rev 0) +++ trunk/stdair/stdair/basic/RandomGenerationContext.cpp 2010-02-08 16:32:09 UTC (rev 124) @@ -0,0 +1,26 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <iosfwd> +// STDAIR +#include <stdair/basic/RandomGenerationContext.hpp> + +namespace stdair { + + // ////////////////////////////////////////////////////////////////////// + RandomGenerationContext::RandomGenerationContext () + : _cumulativeProbabilitySoFar (0.0), + _numberOfRequestsGeneratedSoFar (0) { + } + + // ////////////////////////////////////////////////////////////////////// + RandomGenerationContext::~RandomGenerationContext () { + } + + // ////////////////////////////////////////////////////////////////////// + void RandomGenerationContext::incrementGeneratedRequestsCounter () { + _numberOfRequestsGeneratedSoFar++; + } + +} Added: trunk/stdair/stdair/basic/RandomGenerationContext.hpp =================================================================== --- trunk/stdair/stdair/basic/RandomGenerationContext.hpp (rev 0) +++ trunk/stdair/stdair/basic/RandomGenerationContext.hpp 2010-02-08 16:32:09 UTC (rev 124) @@ -0,0 +1,70 @@ +#ifndef __STDAIR_BAS_RANDOM_GENERATION_CONTEXT_HPP +#define __STDAIR_BAS_RANDOM_GENERATION_CONTEXT_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <iosfwd> +// STDAIR +#include <stdair/STDAIR_Types.hpp> + +namespace stdair { + + /** Structure holding the context necessary for demand random generation. */ + struct RandomGenerationContext { + + public: + // ///////////// Getters /////////// + /** Get the cumulative probability of arrival pattern for last + request generated so far. */ + const Probability_T& getCumulativeProbabilitySoFar () const { + return _cumulativeProbabilitySoFar; + } + + /** Get the number of requests generated so far. */ + const Count_T& getNumberOfRequestsGeneratedSoFar() const { + return _numberOfRequestsGeneratedSoFar; + } + + /** Set the cumulative probability of arrival pattern for last + request generated so far. */ + void setCumulativeProbabilitySoFar (const Probability_T& iCumulativeProbability) { + _cumulativeProbabilitySoFar = iCumulativeProbability; + } + + /** Set the number of requests generated so far. */ + void setNumberOfRequestsGeneratedSoFar (const Count_T& iNumberOfRequests) { + _numberOfRequestsGeneratedSoFar = iNumberOfRequests; + } + + public: + // ////////// Constructors and destructors ///////// + /** Constructor by default */ + RandomGenerationContext (); + + /** Destructor */ + virtual ~RandomGenerationContext (); + + public: + // /////////////// Business Methods ////////// + /** Increment counter of requests generated so far */ + void incrementGeneratedRequestsCounter (); + + private: + /** Default constructors. */ + RandomGenerationContext (const RandomGenerationContext&); + + private: + // ////////// Attributes ////////// + /** Cumulative probability in arrival pattern for last request + generated so far (needed for sequential generation)*/ + Probability_T _cumulativeProbabilitySoFar; + + /** Number of requests generated so far */ + Count_T _numberOfRequestsGeneratedSoFar; + + }; + +} +#endif // __STDAIR_BAS_RANDOM_GENERATION_CONTEXT_HPP Modified: trunk/stdair/stdair/basic/sources.mk =================================================================== --- trunk/stdair/stdair/basic/sources.mk 2010-02-08 09:22:21 UTC (rev 123) +++ trunk/stdair/stdair/basic/sources.mk 2010-02-08 16:32:09 UTC (rev 124) @@ -10,10 +10,20 @@ $(top_srcdir)/stdair/basic/BasChronometer.hpp \ $(top_srcdir)/stdair/basic/BasFileMgr.hpp \ $(top_srcdir)/stdair/basic/BasLogParams.hpp \ - $(top_srcdir)/stdair/basic/BasDBParams.hpp + $(top_srcdir)/stdair/basic/BasDBParams.hpp \ + $(top_srcdir)/stdair/basic/ContinuousAttribute.hpp \ + $(top_srcdir)/stdair/basic/CategoricalAttribute.hpp \ + $(top_srcdir)/stdair/basic/DemandCharacteristics.hpp \ + $(top_srcdir)/stdair/basic/DemandDistribution.hpp \ + $(top_srcdir)/stdair/basic/RandomGeneration.hpp \ + $(top_srcdir)/stdair/basic/RandomGenerationContext.hpp bas_cc_sources = \ $(top_srcdir)/stdair/basic/BasConst.cpp \ $(top_srcdir)/stdair/basic/BasChronometer.cpp \ $(top_srcdir)/stdair/basic/BasFileMgr.cpp \ $(top_srcdir)/stdair/basic/BasLogParams.cpp \ - $(top_srcdir)/stdair/basic/BasDBParams.cpp + $(top_srcdir)/stdair/basic/BasDBParams.cpp \ + $(top_srcdir)/stdair/basic/DemandCharacteristics.cpp \ + $(top_srcdir)/stdair/basic/DemandDistribution.cpp \ + $(top_srcdir)/stdair/basic/RandomGeneration.cpp \ + $(top_srcdir)/stdair/basic/RandomGenerationContext.cpp Modified: trunk/stdair/stdair/bom/BookingRequestStruct.cpp =================================================================== --- trunk/stdair/stdair/bom/BookingRequestStruct.cpp 2010-02-08 09:22:21 UTC (rev 123) +++ trunk/stdair/stdair/bom/BookingRequestStruct.cpp 2010-02-08 16:32:09 UTC (rev 124) @@ -12,17 +12,27 @@ namespace stdair { // ////////////////////////////////////////////////////////////////////// + BookingRequestStruct::BookingRequestStruct () { + } + + // ////////////////////////////////////////////////////////////////////// BookingRequestStruct::BookingRequestStruct (const AirportCode_T& iOrigin, const AirportCode_T& iDestination, const Date_T& iDepartureDate, + const DateTime_T& iRequestDateTime, const PassengerType_T& iPaxType, const NbOfSeats_T& iPartySize) : _origin (iOrigin), _destination (iDestination), - _departureDate (iDepartureDate), _paxType (iPaxType), - _partySize (iPartySize) { + _preferredDepartureDate (iDepartureDate), + _requestDateTime (iRequestDateTime), + _paxType (iPaxType), _partySize (iPartySize) { } - + // ////////////////////////////////////////////////////////////////////// + BookingRequestStruct::~BookingRequestStruct () { + } + + // ////////////////////////////////////////////////////////////////////// void BookingRequestStruct::toStream (std::ostream& ioOut) const { ioOut << describe(); } @@ -34,8 +44,8 @@ // ////////////////////////////////////////////////////////////////////// const std::string BookingRequestStruct::describe() const { std::ostringstream oStr; - oStr << _origin << " - " << _destination << " " << _departureDate - << " " << _paxType << " " << _partySize; + oStr << _origin << " - " << _destination << " " << _preferredDepartureDate + << " " << _requestDateTime << " " << _paxType << " " << _partySize; return oStr.str(); } Modified: trunk/stdair/stdair/bom/BookingRequestStruct.hpp =================================================================== --- trunk/stdair/stdair/bom/BookingRequestStruct.hpp 2010-02-08 09:22:21 UTC (rev 123) +++ trunk/stdair/stdair/bom/BookingRequestStruct.hpp 2010-02-08 16:32:09 UTC (rev 124) @@ -28,10 +28,15 @@ } /** Get the requested departure date. */ - const Date_T& getDepartureDate() const { - return _departureDate; + const Date_T& getPreferedDepartureDate() const { + return _preferredDepartureDate; } + /** Get the request datetime. */ + const DateTime_T& getRequestDateTime() const { + return _requestDateTime; + } + /** Get the passenger type. */ const PassengerType_T& getPaxType() const { return _paxType; @@ -55,10 +60,15 @@ } /** Set the requested departure date. */ - void setDepartureDate (const Date_T& iDepartureDate) { - _departureDate = iDepartureDate; + void setPreferredDepartureDate (const Date_T& iDepartureDate) { + _preferredDepartureDate = iDepartureDate; } - + + /** Set the request datetime */ + void setRequestDateTime (const DateTime_T& iRequestDateTime) { + _requestDateTime = iRequestDateTime; + } + /** Set the passenger type. */ void setPaxType (const PassengerType_T& iPaxType) { _paxType = iPaxType; @@ -84,9 +94,11 @@ public: // /////////////// Constructors and Destructors ///////////////// + BookingRequestStruct (); BookingRequestStruct (const AirportCode_T&, const AirportCode_T&, - const Date_T&, const PassengerType_T&, - const NbOfSeats_T&); + const Date_T&, const DateTime_T&, + const PassengerType_T&, const NbOfSeats_T&); + ~BookingRequestStruct(); private: @@ -96,10 +108,13 @@ /** Destination. */ AirportCode_T _destination; - + /** Departure date. */ - Date_T _departureDate; + Date_T _preferredDepartureDate; + /** Request datetime */ + DateTime_T _requestDateTime; + /** Passenger type. */ PassengerType_T _paxType; Added: trunk/stdair/stdair/bom/DemandStream.cpp =================================================================== --- trunk/stdair/stdair/bom/DemandStream.cpp (rev 0) +++ trunk/stdair/stdair/bom/DemandStream.cpp 2010-02-08 16:32:09 UTC (rev 124) @@ -0,0 +1,132 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +#include <iosfwd> +#include <ostream> +#include <sstream> +// Boost +#include <boost/math/distributions/normal.hpp> +// Math +#include <math.h> +// STDAIR +#include <stdair/basic/BasConst_General.hpp> +#include <stdair/basic/DemandCharacteristics.hpp> +#include <stdair/basic/RandomGeneration.hpp> +#include <stdair/basic/RandomGenerationContext.hpp> +#include <stdair/bom/BookingRequestStruct.hpp> +#include <stdair/bom/DemandStream.hpp> +#include <stdair/service/Logger.hpp> + + +namespace stdair { + + // ////////////////////////////////////////////////////////////////////// + DemandStream::DemandStream(const DemandStreamKey_T& iKey, + const DemandCharacteristics& iDemandCharacteristics, + const DemandDistribution& iDemandDistribution, + const RandomSeed_T& iNumberOfRequestsSeed, + const RandomSeed_T& iRequestDateTimeSeed, + const RandomSeed_T& iDemandCharacteristicsSeed) + : _key (iKey), + _demandCharacteristics (iDemandCharacteristics), + _demandDistribution (iDemandDistribution), + _totalNumberOfRequestsToBeGenerated (0), + _numberOfRequestsRandomGenerator (iNumberOfRequestsSeed), + _requestDateTimeRandomGenerator (iRequestDateTimeSeed), + _demandCharacteristicsRandomGenerator (iDemandCharacteristicsSeed) { + init(); + } + + // ////////////////////////////////////////////////////////////////////// + DemandStream::~DemandStream () { + } + + // ////////////////////////////////////////////////////////////////////// + void DemandStream::init() { + // Generate the number of requests + const RealNumber_T lMu = _demandDistribution.getMeanNumberOfRequests (); + const RealNumber_T lSigma = + _demandDistribution.getStandardDeviationNumberOfRequests (); + const RealNumber_T lRealNumberOfRequestsToBeGenerated = + _numberOfRequestsRandomGenerator.generateNormal (lMu, lSigma); + Count_T lIntegerNumberOfRequestsToBeGenerated = 0; + if (lRealNumberOfRequestsToBeGenerated < 0.5) { + lIntegerNumberOfRequestsToBeGenerated = 0; + } else { + lIntegerNumberOfRequestsToBeGenerated = + static_cast<Count_T> (lRealNumberOfRequestsToBeGenerated + 0.5); + } + _totalNumberOfRequestsToBeGenerated = lIntegerNumberOfRequestsToBeGenerated; + } + + // ////////////////////////////////////////////////////////////////////// + bool DemandStream::generateNext (BookingRequestStruct& ioRequest) { + // Check whether enough requests have already been generated + const Count_T lNbOfRequestsGeneratedSoFar = + _randomGenerationContext.getNumberOfRequestsGeneratedSoFar (); + const Count_T lRemainingNumberOfRequestsToBeGenerated = + _totalNumberOfRequestsToBeGenerated - lNbOfRequestsGeneratedSoFar; + + if (lRemainingNumberOfRequestsToBeGenerated <= 0) { + return false; + } + // DEBUG + STDAIR_LOG_DEBUG ("Here"); + + // Origin + ioRequest.setOrigin (_demandCharacteristics.getOrigin ()); + + // Preferred departure date + const Date_T lPreferredDepartureDate = + _demandCharacteristics.getPreferredDepartureDate (); + ioRequest.setPreferredDepartureDate (lPreferredDepartureDate); + + // Request datetime, determined from departure date and arrival pattern + // Sequential generation + const Probability_T lCumulativeProbabilitySoFar = + _randomGenerationContext.getCumulativeProbabilitySoFar (); + + const Probability_T lVariate = + _requestDateTimeRandomGenerator.generateUniform01 (); + + const Probability_T lCumulativeProbabilityThisRequest = + 1.0 - (1.0 - lCumulativeProbabilitySoFar) * pow(1 - lVariate, 1.0 / static_cast<float> (lRemainingNumberOfRequestsToBeGenerated)); + + const FloatDuration_T lNumberOfDaysBetweenDepartureAndThisRequest = + _demandCharacteristics.getArrivalPattern().getValue (lCumulativeProbabilityThisRequest); + + // convert the number of days in number of seconds + number of milliseconds + const FloatDuration_T lNumberOfSeconds = + lNumberOfDaysBetweenDepartureAndThisRequest*static_cast<float> (SECONDS_IN_ONE_DAY); + + const IntDuration_T lIntNumberOfSeconds = floor(lNumberOfSeconds); + + const FloatDuration_T lNumberOfMilliseconds = + (lNumberOfSeconds - lIntNumberOfSeconds) * static_cast<float> (MILLISECONDS_IN_ONE_SECOND); + + const IntDuration_T lIntNumberOfMilliseconds = + floor(lNumberOfMilliseconds) + 1; // +1 is a trick to ensure that the next event is strictly later than the current one + + const Duration_T lDifferenceBetweenDepartureAndThisRequest = + boost::posix_time::seconds(lIntNumberOfSeconds) + boost::posix_time::millisec(lIntNumberOfMilliseconds); + + const Time_T lHardcodedReferenceDepartureTime = boost::posix_time::hours(8); + +const DateTime_T lDepartureDateTime = + boost::posix_time::ptime(lPreferredDepartureDate, lHardcodedReferenceDepartureTime); + + const DateTime_T lDateTimeThisRequest = + lDepartureDateTime + lDifferenceBetweenDepartureAndThisRequest; + ioRequest.setRequestDateTime (lDateTimeThisRequest); + + // Update random generation context + _randomGenerationContext.setCumulativeProbabilitySoFar (lCumulativeProbabilityThisRequest); + _randomGenerationContext.incrementGeneratedRequestsCounter (); + + return true; + + } + +} Added: trunk/stdair/stdair/bom/DemandStream.hpp =================================================================== --- trunk/stdair/stdair/bom/DemandStream.hpp (rev 0) +++ trunk/stdair/stdair/bom/DemandStream.hpp 2010-02-08 16:32:09 UTC (rev 124) @@ -0,0 +1,94 @@ +#ifndef __STDAIR_BAS_DEMAND_STREAM_HPP +#define __STDAIR_BAS_DEMAND_STREAM_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <iosfwd> +// STDAIR +#include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/DemandCharacteristics.hpp> +#include <stdair/basic/DemandDistribution.hpp> +#include <stdair/basic/RandomGeneration.hpp> +#include <stdair/basic/RandomGenerationContext.hpp> +#include <stdair/bom/BookingRequestStruct.hpp> + +namespace stdair { + + /** Class modeling a demand stream. */ + class DemandStream { + + public: + // ///////////// Getters /////////// + /** Get the key */ + const DemandStreamKey_T& getKey () const { + return _key; + } + + /** Get the total number of requests to be generated. */ + const Count_T& getTotalNumberOfRequestsToBeGenerated() const { + return _totalNumberOfRequestsToBeGenerated; + } + + public: + // ///////////// Setters /////////// + /** Set the demand characteristics */ + void setKey (const DemandStreamKey_T& iKey) { + _key = iKey; + } + + public: + // /////////////// Business Methods ////////// + /** Generate the next request. */ + bool generateNext (BookingRequestStruct&); + + public: + // ////////// Constructors and destructors ///////// + /** Constructor by default */ + DemandStream (const DemandStreamKey_T&, const DemandCharacteristics&, + const DemandDistribution&, const RandomSeed_T&, + const RandomSeed_T&, const RandomSeed_T&); + + /** Destructor */ + virtual ~DemandStream (); + + private: + /** Default constructors. */ + DemandStream (); + DemandStream (const DemandStream&); + + /** Initialization. */ + void init(); + + private: + // ////////// Attributes ////////// + + /** Key */ + DemandStreamKey_T _key; + + /** Demand characteristics */ + DemandCharacteristics _demandCharacteristics; + + /** Demand distribution */ + DemandDistribution _demandDistribution; + + /** Total number of requests to be generated*/ + Count_T _totalNumberOfRequestsToBeGenerated; + + /** Random generation context */ + RandomGenerationContext _randomGenerationContext; + + /** Random generator for number of requests */ + RandomGeneration _numberOfRequestsRandomGenerator; + + /** Random generator for request datetime */ + RandomGeneration _requestDateTimeRandomGenerator; + + /** Random generator for demand characteristics */ + RandomGeneration _demandCharacteristicsRandomGenerator; + + }; + +} +#endif // __STDAIR_BAS_DEMAND_STREAM_HPP Added: trunk/stdair/stdair/bom/EventQueue.cpp =================================================================== --- trunk/stdair/stdair/bom/EventQueue.cpp (rev 0) +++ trunk/stdair/stdair/bom/EventQueue.cpp 2010-02-08 16:32:09 UTC (rev 124) @@ -0,0 +1,87 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STDAIR +#include <stdair/bom/EventQueue.hpp> + +namespace stdair { + + // ////////////////////////////////////////////////////////////////////// + EventQueue::EventQueue (const DateTime_T& iEarliestDateTime) { + // Earliest time is necessary in order to set _currentEvent + // "before" any event. Without it, _currentEvent would need to be + // set to the first event, the first an event is added + EventStruct lEarliestEvent (iEarliestDateTime); + _eventList.insert(EventListElement_T (iEarliestDateTime, lEarliestEvent)); + _currentEvent = _eventList.begin (); + } + + // ////////////////////////////////////////////////////////////////////// + EventQueue::~EventQueue () { + } + + // ////////////////////////////////////////////////////////////////////// + EventStruct* EventQueue::popEvent () { + EventStruct* oEventStruct_ptr = NULL; + if (!isQueueDone ()) { + ++_currentEvent; + oEventStruct_ptr = &(_currentEvent->second); + } + return oEventStruct_ptr; + } + + // ////////////////////////////////////////////////////////////////////// + void EventQueue::addEvent (const EventStruct& iEventStruct) { + DateTime_T lEventDateTime = iEventStruct.getEventDateTime (); + _eventList.insert( std::pair<DateTime_T, EventStruct> (lEventDateTime, iEventStruct) ); + } + + // ////////////////////////////////////////////////////////////////////// + const bool EventQueue::isQueueDone () const { + bool oFlagDone = false; + if (_currentEvent == _eventList.end ()) { + oFlagDone = true; + } else { + EventList_T::iterator lNextEvent = _currentEvent; + ++lNextEvent; + if (lNextEvent == _eventList.end ()) { + oFlagDone = true; + } + } + return oFlagDone; + } + + // ////////////////////////////////////////////////////////////////////// + const Count_T EventQueue::getQueueSize () const { + if (_eventList.empty ()) { + return 0; + } else { + return _eventList.size (); + } + } + + // ////////////////////////////////////////////////////////////////////// + const bool EventQueue::isQueueEmpty () const { + return _eventList.empty (); + } + + // ////////////////////////////////////////////////////////////////////// + const Count_T EventQueue::getPositionOfCurrent () const { + int i = 0; + bool flag = false; + for (EventList_T::const_iterator it = _eventList.begin (); + it != _eventList.end (); ++it) { + if (it == _currentEvent) { + flag = true; + break; + } + ++i; + } + if (flag) { + return i; + } else { + return -1; + } + } + +} Added: trunk/stdair/stdair/bom/EventQueue.hpp =================================================================== --- trunk/stdair/stdair/bom/EventQueue.hpp (rev 0) +++ trunk/stdair/stdair/bom/EventQueue.hpp 2010-02-08 16:32:09 UTC (rev 124) @@ -0,0 +1,73 @@ +#ifndef __STDAIR_BAS_EVENTQUEUE_HPP +#define __STDAIR_BAS_EVENTQUEUE_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STDAIR +#include <stdair/STDAIR_Types.hpp> +#include <stdair/bom/EventStruct.hpp> + +namespace stdair { + + /** Event queue. */ + class EventQueue { + + public: + typedef std::pair<DateTime_T, EventStruct> EventListElement_T; + typedef std::multimap<DateTime_T, EventStruct> EventList_T; + + public: + // ///////////// Getters /////////// + // /** Get the event type */ + //const EventType_T& getEventType () const { + // return _eventType; + //} + + public: + // ////////// Constructors and destructors ///////// + /** Constructor. */ + EventQueue (const DateTime_T&); + + /** Destructor. */ + virtual ~EventQueue (); + + public: + // ////////// Business methods ///////// + /** Pop event */ + EventStruct* popEvent (); + + /** Add event */ + void addEvent (const EventStruct&); + + /** Is queue done */ + const bool isQueueDone () const; + + + // ////////// Debug methods ///////// + /** Queue size */ + const Count_T getQueueSize () const; + + /** Is queue empty */ + const bool isQueueEmpty () const; + + /** Get position of current */ + const Count_T getPositionOfCurrent () const; + + private: + /** Default constructors. */ + EventQueue (const EventQueue&); + + private: + // ////////// Attributes ////////// + + /** Event list */ + EventList_T _eventList; + + /** Pointer to current event */ + EventList_T::iterator _currentEvent; + + }; + +} +#endif // __STDAIR_BAS_EVENTQUEUE_HPP Added: trunk/stdair/stdair/bom/EventStruct.cpp =================================================================== --- trunk/stdair/stdair/bom/EventStruct.cpp (rev 0) +++ trunk/stdair/stdair/bom/EventStruct.cpp 2010-02-08 16:32:09 UTC (rev 124) @@ -0,0 +1,43 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STDAIR +#include <stdair/bom/BookingRequestStruct.hpp> +#include <stdair/bom/EventStruct.hpp> + +namespace stdair { + + // ////////////////////////////////////////////////////////////////////// + EventStruct:: + EventStruct(const EventType_T& iEventType, const DateTime_T& iDateTime, + DemandStream& ioDemandStream, BookingRequestStruct* const iRequest) + : _eventType (iEventType), + _eventDateTime (iDateTime), + _demandStream (&ioDemandStream), + _request (NULL) { + if (iEventType == "Request") { + _request = iRequest; + } + } + + // ////////////////////////////////////////////////////////////////////// + EventStruct:: + EventStruct (const EventStruct& iEventStruct) + : _eventType (iEventStruct._eventType), + _eventDateTime (iEventStruct._eventDateTime), + _demandStream (iEventStruct._demandStream), + _request (iEventStruct._request) { + } + + // ////////////////////////////////////////////////////////////////////// + EventStruct::EventStruct (const DateTime_T& iDateTime) + : _eventType (""), + _eventDateTime (iDateTime), + _request (NULL) { + } + + // ////////////////////////////////////////////////////////////////////// + EventStruct::~EventStruct () { + } + +} Added: trunk/stdair/stdair/bom/EventStruct.hpp =================================================================== --- trunk/stdair/stdair/bom/EventStruct.hpp (rev 0) +++ trunk/stdair/stdair/bom/EventStruct.hpp 2010-02-08 16:32:09 UTC (rev 124) @@ -0,0 +1,78 @@ +#ifndef __STDAIR_BAS_EVENTSTRUCT_HPP +#define __STDAIR_BAS_EVENTSTRUCT_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STDAIR +#include <stdair/STDAIR_Types.hpp> + +namespace stdair { + + /** Forward declaration */ + struct BookingRequestStruct; + class DemandStream; + + /** Event struct. */ + struct EventStruct { + + public: + // ///////////// Getters /////////// + /** Get the event type */ + const EventType_T& getEventType () const { + return _eventType; + } + + /** Get the event datetime */ + const DateTime_T& getEventDateTime () const { + return _eventDateTime; + } + + /** Get the pointer Request event. */ + const BookingRequestStruct* getPointerToRequestEvent () const { + return _request; + } + + /** Get the demand stream of the event. */ + DemandStream& getDemandStream () const { + assert (_demandStream != NULL); + return *_demandStream; + } + + public: + // ////////// Constructors and destructors ///////// + /** Constructor. */ + EventStruct (const EventType_T&, const DateTime_T&, + DemandStream&, BookingRequestStruct* const); + EventStruct (const DateTime_T&); + + /** Copy constructor. */ + EventStruct (const EventStruct&); + + /** Destructor. */ + virtual ~EventStruct (); + + private: + /** Default constructors. */ + EventStruct (); + + + private: + // ////////// Attributes ////////// + + /** Event type */ + EventType_T _eventType; + + /** Event datetime */ + DateTime_T _eventDateTime; + + /** The demand stream which generated this event. */ + DemandStream* _demandStream; + + /** Pointer to Request event */ + BookingRequestStruct* _request; + + }; + +} +#endif // __STDAIR_BAS_EVENTSTRUCT_HPP Modified: trunk/stdair/stdair/bom/sources.mk =================================================================== --- trunk/stdair/stdair/bom/sources.mk 2010-02-08 09:22:21 UTC (rev 123) +++ trunk/stdair/stdair/bom/sources.mk 2010-02-08 16:32:09 UTC (rev 124) @@ -86,6 +86,9 @@ $(top_srcdir)/stdair/bom/TravelSolutionTypes.hpp \ $(top_srcdir)/stdair/bom/BookingRequestStruct.hpp \ $(top_srcdir)/stdair/bom/AirlineStruct.hpp \ + $(top_srcdir)/stdair/bom/DemandStream.hpp \ + $(top_srcdir)/stdair/bom/EventStruct.hpp \ + $(top_srcdir)/stdair/bom/EventQueue.hpp \ $(top_srcdir)/stdair/bom/BomManager.hpp bom_cc_sources = \ $(top_srcdir)/stdair/bom/BomRootKey.cpp \ @@ -135,4 +138,7 @@ $(top_srcdir)/stdair/bom/TravelSolutionStruct.cpp \ $(top_srcdir)/stdair/bom/BookingRequestStruct.cpp \ $(top_srcdir)/stdair/bom/AirlineStruct.cpp \ + $(top_srcdir)/stdair/bom/DemandStream.cpp \ + $(top_srcdir)/stdair/bom/EventStruct.cpp \ + $(top_srcdir)/stdair/bom/EventQueue.cpp \ $(top_srcdir)/stdair/bom/BomManager.cpp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qua...@us...> - 2010-02-10 17:13:46
|
Revision: 126 http://stdair.svn.sourceforge.net/stdair/?rev=126&view=rev Author: quannaus Date: 2010-02-10 17:13:38 +0000 (Wed, 10 Feb 2010) Log Message: ----------- [Dev] Moved the demand stream to trademgen. Modified Paths: -------------- trunk/stdair/stdair/basic/BasConst.cpp trunk/stdair/stdair/basic/BasConst_General.hpp trunk/stdair/stdair/basic/RandomGeneration.cpp trunk/stdair/stdair/basic/RandomGeneration.hpp trunk/stdair/stdair/basic/RandomGenerationContext.cpp trunk/stdair/stdair/basic/RandomGenerationContext.hpp trunk/stdair/stdair/bom/BookingRequestStruct.hpp trunk/stdair/stdair/bom/EventQueue.cpp trunk/stdair/stdair/bom/EventQueue.hpp trunk/stdair/stdair/bom/EventStruct.cpp trunk/stdair/stdair/bom/EventStruct.hpp trunk/stdair/stdair/bom/sources.mk trunk/stdair/stdair/factory/FacBomContent.cpp trunk/stdair/stdair/factory/FacBomContent.hpp Added Paths: ----------- trunk/stdair/stdair/bom/BookingRequestTypes.hpp trunk/stdair/stdair/bom/EventTypes.hpp Removed Paths: ------------- trunk/stdair/stdair/bom/DemandStream.cpp trunk/stdair/stdair/bom/DemandStream.hpp Modified: trunk/stdair/stdair/basic/BasConst.cpp =================================================================== --- trunk/stdair/stdair/basic/BasConst.cpp 2010-02-10 10:14:09 UTC (rev 125) +++ trunk/stdair/stdair/basic/BasConst.cpp 2010-02-10 17:13:38 UTC (rev 126) @@ -129,12 +129,15 @@ const DateOffSet_T DEFAULT_DATE_OFFSET (0); // // //////// General /////// - /** Default update date for the General. */ + /** Default date for the General. */ const Date_T DEFAULT_DATE (2007, boost::gregorian::Jan, 1); - /** Default update date&time. */ + /** Default date&time. */ const DateTime_T DEFAULT_DATETIME (DEFAULT_DATE, NULL_BOOST_TIME_DURATION); + /** Default epsilon duration (1 nanosecond). */ + const Duration_T DEFAULT_EPSILON_DURATION = Duration_T (0, 0, 0, 1); + /** Number of seconds in one day */ const Count_T SECONDS_IN_ONE_DAY = 86000; Modified: trunk/stdair/stdair/basic/BasConst_General.hpp =================================================================== --- trunk/stdair/stdair/basic/BasConst_General.hpp 2010-02-10 10:14:09 UTC (rev 125) +++ trunk/stdair/stdair/basic/BasConst_General.hpp 2010-02-10 17:13:38 UTC (rev 126) @@ -42,10 +42,13 @@ /** Number of milliseconds in one second */ extern const Count_T MILLISECONDS_IN_ONE_SECOND; - /** Default update date for the General. */ + /** Default date for the General. */ extern const Date_T DEFAULT_DATE; - /** Default update date&time. */ + /** Default date&time. */ extern const DateTime_T DEFAULT_DATETIME; + + /** Default epsilon duration. */ + extern const Duration_T DEFAULT_EPSILON_DURATION; } #endif // __STDAIR_BAS_BASCONST_GENERAL_HPP Modified: trunk/stdair/stdair/basic/RandomGeneration.cpp =================================================================== --- trunk/stdair/stdair/basic/RandomGeneration.cpp 2010-02-10 10:14:09 UTC (rev 125) +++ trunk/stdair/stdair/basic/RandomGeneration.cpp 2010-02-10 17:13:38 UTC (rev 126) @@ -16,6 +16,13 @@ } // ////////////////////////////////////////////////////////////////////// + RandomGeneration::RandomGeneration (const RandomGeneration& iRandomGeneration) + : _seed (iRandomGeneration._seed), + _generator (iRandomGeneration._generator), + _uniformGenerator (iRandomGeneration._uniformGenerator) { + } + + // ////////////////////////////////////////////////////////////////////// RandomGeneration::~RandomGeneration () { } Modified: trunk/stdair/stdair/basic/RandomGeneration.hpp =================================================================== --- trunk/stdair/stdair/basic/RandomGeneration.hpp 2010-02-10 10:14:09 UTC (rev 125) +++ trunk/stdair/stdair/basic/RandomGeneration.hpp 2010-02-10 17:13:38 UTC (rev 126) @@ -39,7 +39,7 @@ /** Destructor. */ virtual ~RandomGeneration (); - private: + public : /** Default constructors. */ RandomGeneration (); RandomGeneration (const RandomGeneration&); Modified: trunk/stdair/stdair/basic/RandomGenerationContext.cpp =================================================================== --- trunk/stdair/stdair/basic/RandomGenerationContext.cpp 2010-02-10 10:14:09 UTC (rev 125) +++ trunk/stdair/stdair/basic/RandomGenerationContext.cpp 2010-02-10 17:13:38 UTC (rev 126) @@ -15,6 +15,12 @@ } // ////////////////////////////////////////////////////////////////////// + RandomGenerationContext::RandomGenerationContext (const RandomGenerationContext& iRandomGenerationContext) + : _cumulativeProbabilitySoFar (iRandomGenerationContext._cumulativeProbabilitySoFar), + _numberOfRequestsGeneratedSoFar (iRandomGenerationContext._numberOfRequestsGeneratedSoFar) { + } + + // ////////////////////////////////////////////////////////////////////// RandomGenerationContext::~RandomGenerationContext () { } Modified: trunk/stdair/stdair/basic/RandomGenerationContext.hpp =================================================================== --- trunk/stdair/stdair/basic/RandomGenerationContext.hpp 2010-02-10 10:14:09 UTC (rev 125) +++ trunk/stdair/stdair/basic/RandomGenerationContext.hpp 2010-02-10 17:13:38 UTC (rev 126) @@ -42,6 +42,8 @@ // ////////// Constructors and destructors ///////// /** Constructor by default */ RandomGenerationContext (); + /** Default constructors. */ + RandomGenerationContext (const RandomGenerationContext&); /** Destructor */ virtual ~RandomGenerationContext (); @@ -51,9 +53,6 @@ /** Increment counter of requests generated so far */ void incrementGeneratedRequestsCounter (); - private: - /** Default constructors. */ - RandomGenerationContext (const RandomGenerationContext&); private: // ////////// Attributes ////////// Modified: trunk/stdair/stdair/bom/BookingRequestStruct.hpp =================================================================== --- trunk/stdair/stdair/bom/BookingRequestStruct.hpp 2010-02-10 10:14:09 UTC (rev 125) +++ trunk/stdair/stdair/bom/BookingRequestStruct.hpp 2010-02-10 17:13:38 UTC (rev 126) @@ -15,7 +15,6 @@ /** Structure holding the elements of a booking request. */ struct BookingRequestStruct : public StructAbstract { - friend class DemandStream; public: // /////////////// Getters ///////////////// @@ -94,13 +93,13 @@ /** Display of the structure. */ const std::string describe() const; - private : // /////////////// Constructors and Destructors ///////////////// - BookingRequestStruct (); public : BookingRequestStruct (const AirportCode_T&, const AirportCode_T&, const Date_T&, const DateTime_T&, const PassengerType_T&, const NbOfSeats_T&); + public : + BookingRequestStruct (); BookingRequestStruct (const BookingRequestStruct&); public: ~BookingRequestStruct(); Added: trunk/stdair/stdair/bom/BookingRequestTypes.hpp =================================================================== --- trunk/stdair/stdair/bom/BookingRequestTypes.hpp (rev 0) +++ trunk/stdair/stdair/bom/BookingRequestTypes.hpp 2010-02-10 17:13:38 UTC (rev 126) @@ -0,0 +1,22 @@ +// ////////////////////////////////////////////////////////////////////// +#ifndef __STDAIR_BOM_BOOKINGCLASSTYPES_HPP +#define __STDAIR_BOM_BOOKINGCLASSTYPES_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// Boost +#include <boost/shared_ptr.hpp> + +namespace stdair { + + // Forward declarations. + struct BookingRequestStruct; + + // Type definitions. + /** Define the smart pointer to a booking request. */ + typedef boost::shared_ptr<BookingRequestStruct> BookingRequestPtr_T; + +} +#endif // __STDAIR_BOM_BOOKINGCLASSTYPES_HPP + Deleted: trunk/stdair/stdair/bom/DemandStream.cpp =================================================================== --- trunk/stdair/stdair/bom/DemandStream.cpp 2010-02-10 10:14:09 UTC (rev 125) +++ trunk/stdair/stdair/bom/DemandStream.cpp 2010-02-10 17:13:38 UTC (rev 126) @@ -1,157 +0,0 @@ -// ////////////////////////////////////////////////////////////////////// -// Import section -// ////////////////////////////////////////////////////////////////////// -// STL -#include <cassert> -#include <iosfwd> -#include <ostream> -#include <sstream> -// Boost -#include <boost/math/distributions/normal.hpp> -// Math -#include <math.h> -// STDAIR -#include <stdair/basic/BasConst_General.hpp> -#include <stdair/basic/DemandCharacteristics.hpp> -#include <stdair/basic/RandomGeneration.hpp> -#include <stdair/basic/RandomGenerationContext.hpp> -#include <stdair/bom/BookingRequestStruct.hpp> -#include <stdair/bom/DemandStream.hpp> -#include <stdair/service/Logger.hpp> - - -namespace stdair { - - // ////////////////////////////////////////////////////////////////////// - DemandStream::DemandStream(const DemandStreamKey_T& iKey, - const DemandCharacteristics& iDemandCharacteristics, - const DemandDistribution& iDemandDistribution, - const RandomSeed_T& iNumberOfRequestsSeed, - const RandomSeed_T& iRequestDateTimeSeed, - const RandomSeed_T& iDemandCharacteristicsSeed) - : _key (iKey), - _demandCharacteristics (iDemandCharacteristics), - _demandDistribution (iDemandDistribution), - _totalNumberOfRequestsToBeGenerated (0), - _numberOfRequestsRandomGenerator (iNumberOfRequestsSeed), - _requestDateTimeRandomGenerator (iRequestDateTimeSeed), - _demandCharacteristicsRandomGenerator (iDemandCharacteristicsSeed) { - init(); - } - - // ////////////////////////////////////////////////////////////////////// - DemandStream::~DemandStream () { - } - - // ////////////////////////////////////////////////////////////////////// - void DemandStream::init() { - // Generate the number of requests - const RealNumber_T lMu = _demandDistribution.getMeanNumberOfRequests (); - const RealNumber_T lSigma = - _demandDistribution.getStandardDeviationNumberOfRequests (); - const RealNumber_T lRealNumberOfRequestsToBeGenerated = - _numberOfRequestsRandomGenerator.generateNormal (lMu, lSigma); - Count_T lIntegerNumberOfRequestsToBeGenerated = 0; - if (lRealNumberOfRequestsToBeGenerated < 0.5) { - lIntegerNumberOfRequestsToBeGenerated = 0; - } else { - lIntegerNumberOfRequestsToBeGenerated = - static_cast<Count_T> (lRealNumberOfRequestsToBeGenerated + 0.5); - } - _totalNumberOfRequestsToBeGenerated = lIntegerNumberOfRequestsToBeGenerated; - } - - // //////////////////////////////////////////////////////////////////// - const bool DemandStream::stillHavingRequestsToBeGenerated () const { - // Check whether enough requests have already been generated - const Count_T lNbOfRequestsGeneratedSoFar = - _randomGenerationContext.getNumberOfRequestsGeneratedSoFar (); - const Count_T lRemainingNumberOfRequestsToBeGenerated = - _totalNumberOfRequestsToBeGenerated - lNbOfRequestsGeneratedSoFar; - - if (lRemainingNumberOfRequestsToBeGenerated <= 0) { - return false; - } - - return true; - - } - - // ////////////////////////////////////////////////////////////////////// - BookingRequestPtr_T DemandStream::generateNext () { - // Assert that there are requests to be generated. - const Count_T lNbOfRequestsGeneratedSoFar = - _randomGenerationContext.getNumberOfRequestsGeneratedSoFar (); - const Count_T lRemainingNumberOfRequestsToBeGenerated = - _totalNumberOfRequestsToBeGenerated - lNbOfRequestsGeneratedSoFar; - assert (lRemainingNumberOfRequestsToBeGenerated > 0); - - - // Origin - const AirportCode_T& lOrigin = _demandCharacteristics.getOrigin (); - // Destination - const AirportCode_T& lDestination = _demandCharacteristics.getDestination (); - // Preferred departure date - const Date_T& lPreferredDepartureDate = - _demandCharacteristics.getPreferredDepartureDate (); - // Passenger type. - const PassengerType_T& lPassengerType = _demandCharacteristics.getPaxType(); - - // Request datetime, determined from departure date and arrival pattern - // Sequential generation - const Probability_T lCumulativeProbabilitySoFar = - _randomGenerationContext.getCumulativeProbabilitySoFar (); - - const Probability_T lVariate = - _requestDateTimeRandomGenerator.generateUniform01 (); - - const Probability_T lCumulativeProbabilityThisRequest = - 1.0 - (1.0 - lCumulativeProbabilitySoFar) * pow(1 - lVariate, 1.0 / static_cast<float> (lRemainingNumberOfRequestsToBeGenerated)); - - const FloatDuration_T lNumberOfDaysBetweenDepartureAndThisRequest = - _demandCharacteristics.getArrivalPattern().getValue (lCumulativeProbabilityThisRequest); - - // convert the number of days in number of seconds + number of milliseconds - const FloatDuration_T lNumberOfSeconds = - lNumberOfDaysBetweenDepartureAndThisRequest - * static_cast<float> (SECONDS_IN_ONE_DAY); - - const IntDuration_T lIntNumberOfSeconds = floor(lNumberOfSeconds); - - const FloatDuration_T lNumberOfMilliseconds = - (lNumberOfSeconds - lIntNumberOfSeconds) - * static_cast<float> (MILLISECONDS_IN_ONE_SECOND); - - const IntDuration_T lIntNumberOfMilliseconds = - floor(lNumberOfMilliseconds) + 1; // +1 is a trick to ensure that the next - // event is strictly later than the current one - - const Duration_T lDifferenceBetweenDepartureAndThisRequest = - boost::posix_time::seconds(lIntNumberOfSeconds) - + boost::posix_time::millisec(lIntNumberOfMilliseconds); - - const Time_T lHardcodedReferenceDepartureTime = boost::posix_time::hours(8); - - const DateTime_T lDepartureDateTime = - boost::posix_time::ptime (lPreferredDepartureDate, - lHardcodedReferenceDepartureTime); - - const DateTime_T lDateTimeThisRequest = - lDepartureDateTime + lDifferenceBetweenDepartureAndThisRequest; - - // Update random generation context - _randomGenerationContext.setCumulativeProbabilitySoFar (lCumulativeProbabilityThisRequest); - _randomGenerationContext.incrementGeneratedRequestsCounter (); - - - // Create the booking request with a hardcoded party size. - BookingRequestPtr_T oBookingRequest_ptr = - BookingRequestPtr_T (new BookingRequestStruct (lOrigin, lDestination, - lPreferredDepartureDate, - lDateTimeThisRequest, - lPassengerType, 1)); - assert (oBookingRequest_ptr != NULL); - return oBookingRequest_ptr; - } - -} Deleted: trunk/stdair/stdair/bom/DemandStream.hpp =================================================================== --- trunk/stdair/stdair/bom/DemandStream.hpp 2010-02-10 10:14:09 UTC (rev 125) +++ trunk/stdair/stdair/bom/DemandStream.hpp 2010-02-10 17:13:38 UTC (rev 126) @@ -1,125 +0,0 @@ -#ifndef __STDAIR_BAS_DEMAND_STREAM_HPP -#define __STDAIR_BAS_DEMAND_STREAM_HPP - -// ////////////////////////////////////////////////////////////////////// -// Import section -// ////////////////////////////////////////////////////////////////////// -// Boost -#include <boost/shared_ptr.hpp> -// STL -#include <iosfwd> -// STDAIR -#include <stdair/STDAIR_Types.hpp> -#include <stdair/basic/DemandCharacteristics.hpp> -#include <stdair/basic/DemandDistribution.hpp> -#include <stdair/basic/RandomGeneration.hpp> -#include <stdair/basic/RandomGenerationContext.hpp> -#include <stdair/bom/BomContent.hpp> -#include <stdair/bom/BookingRequestStruct.hpp> - -namespace stdair { - - // Type definitions. - /** Define the smart pointer to a booking request. */ - typedef boost::shared_ptr<BookingRequestStruct> BookingRequestPtr_T; - - /** Class modeling a demand stream. */ - class DemandStream : public BomContent { - friend class FacBomContent; - - public: - // ///////////// Getters /////////// - /** Get the key */ - const DemandStreamKey_T& getKey () const { - return _key; - } - - /** Get the total number of requests to be generated. */ - const Count_T& getTotalNumberOfRequestsToBeGenerated() const { - return _totalNumberOfRequestsToBeGenerated; - } - - public: - // ///////////// Setters /////////// - /** Set the demand characteristics */ - void setKey (const DemandStreamKey_T& iKey) { - _key = iKey; - } - - public: - // /////////// Display support methods ///////// - /** Dump a Business Object into an output stream. - @param ostream& the output stream. */ - void toStream (std::ostream& ioOut) const { ioOut << toString(); } - - /** Read a Business Object from an input stream. - @param istream& the input stream. */ - void fromStream (std::istream& ioIn) { } - - /** Get the serialised version of the Business Object. */ - std::string toString() const { return describeKey(); } - - /** Get a string describing the whole key (differentiating two objects - at any level). */ - const std::string describeKey() const { return std::string (""); } - - /** Get a string describing the short key (differentiating two objects - at the same level). */ - const std::string describeShortKey() const { return std::string (""); } - - public: - // /////////////// Business Methods ////////////// - /** Check whether enough requests have already been generated. */ - const bool stillHavingRequestsToBeGenerated () const; - - /** Generate the next request. */ - BookingRequestPtr_T generateNext (); - - private: - // ////////// Constructors and destructors ///////// - /** Constructor by default */ - DemandStream (const DemandStreamKey_T&, const DemandCharacteristics&, - const DemandDistribution&, const RandomSeed_T&, - const RandomSeed_T&, const RandomSeed_T&); - - /** Destructor */ - virtual ~DemandStream (); - - /** Default constructors. */ - DemandStream (); - DemandStream (const DemandStream&); - - /** Initialization. */ - void init(); - - private: - // ////////// Attributes ////////// - - /** Key */ - DemandStreamKey_T _key; - - /** Demand characteristics */ - DemandCharacteristics _demandCharacteristics; - - /** Demand distribution */ - DemandDistribution _demandDistribution; - - /** Total number of requests to be generated*/ - Count_T _totalNumberOfRequestsToBeGenerated; - - /** Random generation context */ - RandomGenerationContext _randomGenerationContext; - - /** Random generator for number of requests */ - RandomGeneration _numberOfRequestsRandomGenerator; - - /** Random generator for request datetime */ - RandomGeneration _requestDateTimeRandomGenerator; - - /** Random generator for demand characteristics */ - RandomGeneration _demandCharacteristicsRandomGenerator; - - }; - -} -#endif // __STDAIR_BAS_DEMAND_STREAM_HPP Modified: trunk/stdair/stdair/bom/EventQueue.cpp =================================================================== --- trunk/stdair/stdair/bom/EventQueue.cpp 2010-02-10 10:14:09 UTC (rev 125) +++ trunk/stdair/stdair/bom/EventQueue.cpp 2010-02-10 17:13:38 UTC (rev 126) @@ -2,18 +2,13 @@ // Import section // ////////////////////////////////////////////////////////////////////// // STDAIR +#include <stdair/bom/EventStruct.hpp> #include <stdair/bom/EventQueue.hpp> namespace stdair { // ////////////////////////////////////////////////////////////////////// - EventQueue::EventQueue (const DateTime_T& iEarliestDateTime) { - // Earliest time is necessary in order to set _currentEvent - // "before" any event. Without it, _currentEvent would need to be - // set to the first event, the first an event is added - EventStruct lEarliestEvent (iEarliestDateTime); - _eventList.insert(EventListElement_T (iEarliestDateTime, lEarliestEvent)); - _currentEvent = _eventList.begin (); + EventQueue::EventQueue () { } // ////////////////////////////////////////////////////////////////////// @@ -21,34 +16,33 @@ } // ////////////////////////////////////////////////////////////////////// - EventStruct* EventQueue::popEvent () { - EventStruct* oEventStruct_ptr = NULL; - if (!isQueueDone ()) { - ++_currentEvent; - oEventStruct_ptr = &(_currentEvent->second); - } - return oEventStruct_ptr; + EventStruct& EventQueue::popEvent () { + assert (isQueueDone() == false); + return _eventList.begin()->second; } // ////////////////////////////////////////////////////////////////////// - void EventQueue::addEvent (const EventStruct& iEventStruct) { - DateTime_T lEventDateTime = iEventStruct.getEventDateTime (); - _eventList.insert( std::pair<DateTime_T, EventStruct> (lEventDateTime, iEventStruct) ); + void EventQueue::addEvent (EventStruct& ioEventStruct) { + const DateTime_T& lEventDateTime = ioEventStruct.getEventDateTime (); + const bool insertionSucceeded = + _eventList.insert (EventListElement_T (lEventDateTime, ioEventStruct)).second; + + // If the insertion is not succeded. + if (insertionSucceeded == false) { + ioEventStruct.moveForwardInTime(); + addEvent (ioEventStruct); + } } + // //////////////////////////////////////////////////////////////////// + void EventQueue::eraseLastUsedEvent () { + assert (isQueueDone () == false); + _eventList.erase (_eventList.begin()); + } + // ////////////////////////////////////////////////////////////////////// const bool EventQueue::isQueueDone () const { - bool oFlagDone = false; - if (_currentEvent == _eventList.end ()) { - oFlagDone = true; - } else { - EventList_T::iterator lNextEvent = _currentEvent; - ++lNextEvent; - if (lNextEvent == _eventList.end ()) { - oFlagDone = true; - } - } - return oFlagDone; + return _eventList.begin() == _eventList.end(); } // ////////////////////////////////////////////////////////////////////// @@ -65,23 +59,4 @@ return _eventList.empty (); } - // ////////////////////////////////////////////////////////////////////// - const Count_T EventQueue::getPositionOfCurrent () const { - int i = 0; - bool flag = false; - for (EventList_T::const_iterator it = _eventList.begin (); - it != _eventList.end (); ++it) { - if (it == _currentEvent) { - flag = true; - break; - } - ++i; - } - if (flag) { - return i; - } else { - return -1; - } - } - } Modified: trunk/stdair/stdair/bom/EventQueue.hpp =================================================================== --- trunk/stdair/stdair/bom/EventQueue.hpp 2010-02-10 10:14:09 UTC (rev 125) +++ trunk/stdair/stdair/bom/EventQueue.hpp 2010-02-10 17:13:38 UTC (rev 126) @@ -1,49 +1,43 @@ -#ifndef __STDAIR_BAS_EVENTQUEUE_HPP -#define __STDAIR_BAS_EVENTQUEUE_HPP +#ifndef __STDAIR_BOM_EVENTQUEUE_HPP +#define __STDAIR_BOM_EVENTQUEUE_HPP // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// // STDAIR #include <stdair/STDAIR_Types.hpp> -#include <stdair/bom/EventStruct.hpp> +#include <stdair/bom/StructAbstract.hpp> +#include <stdair/bom/EventTypes.hpp> namespace stdair { /** Event queue. */ - class EventQueue { - + struct EventQueue : public StructAbstract { + public: - typedef std::pair<DateTime_T, EventStruct> EventListElement_T; - typedef std::multimap<DateTime_T, EventStruct> EventList_T; - - public: - // ///////////// Getters /////////// - // /** Get the event type */ - //const EventType_T& getEventType () const { - // return _eventType; - //} + /** Read a Business Object from an input stream. + @param istream& the input stream. */ + void fromStream (std::istream& ioIn) {} + + /** Display of the structure. */ + const std::string describe() const { return ""; } public: - // ////////// Constructors and destructors ///////// - /** Constructor. */ - EventQueue (const DateTime_T&); - - /** Destructor. */ - virtual ~EventQueue (); - - public: // ////////// Business methods ///////// - /** Pop event */ - EventStruct* popEvent (); + /** Pop event. */ + EventStruct& popEvent (); - /** Add event */ - void addEvent (const EventStruct&); + /** Add event. + <br>If there already is an event with the same datetime, move the given + event one nanosecond forward and retry the insertion until succeed. */ + void addEvent (EventStruct&); + + /** Erase the last used event. */ + void eraseLastUsedEvent (); /** Is queue done */ const bool isQueueDone () const; - - + // ////////// Debug methods ///////// /** Queue size */ const Count_T getQueueSize () const; @@ -51,23 +45,20 @@ /** Is queue empty */ const bool isQueueEmpty () const; - /** Get position of current */ - const Count_T getPositionOfCurrent () const; - - private: + public: + // ////////// Constructors and destructors ///////// /** Default constructors. */ + EventQueue (); + /** Copy constructor. */ EventQueue (const EventQueue&); + /** Destructor. */ + ~EventQueue (); private: // ////////// Attributes ////////// - /** Event list */ EventList_T _eventList; - - /** Pointer to current event */ - EventList_T::iterator _currentEvent; - }; } -#endif // __STDAIR_BAS_EVENTQUEUE_HPP +#endif // __STDAIR_BOM_EVENTQUEUE_HPP Modified: trunk/stdair/stdair/bom/EventStruct.cpp =================================================================== --- trunk/stdair/stdair/bom/EventStruct.cpp 2010-02-10 10:14:09 UTC (rev 125) +++ trunk/stdair/stdair/bom/EventStruct.cpp 2010-02-10 17:13:38 UTC (rev 126) @@ -2,6 +2,7 @@ // Import section // ////////////////////////////////////////////////////////////////////// // STDAIR +#include <stdair/basic/BasConst_General.hpp> #include <stdair/bom/BookingRequestStruct.hpp> #include <stdair/bom/EventStruct.hpp> @@ -10,10 +11,11 @@ // ////////////////////////////////////////////////////////////////////// EventStruct:: EventStruct(const EventType_T& iEventType, const DateTime_T& iDateTime, - DemandStream& ioDemandStream, BookingRequestPtr_T ioRequestPtr) + const DemandStreamKey_T& iDemandStreamKey, + BookingRequestPtr_T ioRequestPtr) : _eventType (iEventType), _eventDateTime (iDateTime), - _demandStream (&ioDemandStream) { + _demandStreamKey (iDemandStreamKey) { _request = ioRequestPtr; } @@ -22,7 +24,7 @@ EventStruct (const EventStruct& iEventStruct) : _eventType (iEventStruct._eventType), _eventDateTime (iEventStruct._eventDateTime), - _demandStream (iEventStruct._demandStream) { + _demandStreamKey (iEventStruct._demandStreamKey) { _request = iEventStruct._request; } @@ -30,11 +32,16 @@ EventStruct::EventStruct (const DateTime_T& iDateTime) : _eventType (""), _eventDateTime (iDateTime), - _demandStream (NULL) { + _demandStreamKey (-1) { } // ////////////////////////////////////////////////////////////////////// EventStruct::~EventStruct () { } + // //////////////////////////////////////////////////////////////////// + void EventStruct::moveForwardInTime () { + _eventDateTime += DEFAULT_EPSILON_DURATION; + } + } Modified: trunk/stdair/stdair/bom/EventStruct.hpp =================================================================== --- trunk/stdair/stdair/bom/EventStruct.hpp 2010-02-10 10:14:09 UTC (rev 125) +++ trunk/stdair/stdair/bom/EventStruct.hpp 2010-02-10 17:13:38 UTC (rev 126) @@ -4,21 +4,12 @@ // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// -// Boost -#include <boost/shared_ptr.hpp> // STDAIR #include <stdair/STDAIR_Types.hpp> +#include <stdair/bom/BookingRequestTypes.hpp> namespace stdair { - - /** Forward declaration */ - struct BookingRequestStruct; - class DemandStream; - // Type definitions. - /** Define the smart pointer to a booking request. */ - typedef boost::shared_ptr<BookingRequestStruct> BookingRequestPtr_T; - /** Event struct. */ struct EventStruct { @@ -41,16 +32,19 @@ } /** Get the demand stream of the event. */ - DemandStream& getDemandStream () const { - assert (_demandStream != NULL); - return *_demandStream; + const DemandStreamKey_T& getDemandStreamKey () const { + return _demandStreamKey; } + + // ///////////////// Business Methods ///////////////// + /** Move the event forward in time by one nanosecond. */ + void moveForwardInTime (); public: // ////////// Constructors and destructors ///////// /** Constructor. */ EventStruct (const EventType_T&, const DateTime_T&, - DemandStream&, BookingRequestPtr_T); + const DemandStreamKey_T&, BookingRequestPtr_T); EventStruct (const DateTime_T&); /** Copy constructor. */ @@ -74,7 +68,7 @@ DateTime_T _eventDateTime; /** The demand stream which generated this event. */ - DemandStream* _demandStream; + DemandStreamKey_T _demandStreamKey; /** Pointer to Request event */ BookingRequestPtr_T _request; Copied: trunk/stdair/stdair/bom/EventTypes.hpp (from rev 124, trunk/stdair/stdair/bom/InventoryTypes.hpp) =================================================================== --- trunk/stdair/stdair/bom/EventTypes.hpp (rev 0) +++ trunk/stdair/stdair/bom/EventTypes.hpp 2010-02-10 17:13:38 UTC (rev 126) @@ -0,0 +1,26 @@ +// ////////////////////////////////////////////////////////////////////// +#ifndef __STDAIR_BOM_EVENTTYPES_HPP +#define __STDAIR_BOM_EVENTTYPES_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <map> +// STDAIR +#include <stdair/STDAIR_Types.hpp> + +namespace stdair { + + // Forward declarations. + struct EventStruct; + + // Define a list of events. + typedef std::map<const DateTime_T, EventStruct> EventList_T; + + // Define an element of a event list. + typedef std::pair<const DateTime_T, EventStruct> EventListElement_T; + +} +#endif // __STDAIR_BOM_EVENTTYPES_HPP + Modified: trunk/stdair/stdair/bom/sources.mk =================================================================== --- trunk/stdair/stdair/bom/sources.mk 2010-02-10 10:14:09 UTC (rev 125) +++ trunk/stdair/stdair/bom/sources.mk 2010-02-10 17:13:38 UTC (rev 126) @@ -86,9 +86,9 @@ $(top_srcdir)/stdair/bom/TravelSolutionTypes.hpp \ $(top_srcdir)/stdair/bom/BookingRequestStruct.hpp \ $(top_srcdir)/stdair/bom/AirlineStruct.hpp \ - $(top_srcdir)/stdair/bom/DemandStream.hpp \ $(top_srcdir)/stdair/bom/EventStruct.hpp \ $(top_srcdir)/stdair/bom/EventQueue.hpp \ + $(top_srcdir)/stdair/bom/EventTypes.hpp \ $(top_srcdir)/stdair/bom/BomManager.hpp bom_cc_sources = \ $(top_srcdir)/stdair/bom/BomRootKey.cpp \ @@ -138,7 +138,6 @@ $(top_srcdir)/stdair/bom/TravelSolutionStruct.cpp \ $(top_srcdir)/stdair/bom/BookingRequestStruct.cpp \ $(top_srcdir)/stdair/bom/AirlineStruct.cpp \ - $(top_srcdir)/stdair/bom/DemandStream.cpp \ $(top_srcdir)/stdair/bom/EventStruct.cpp \ $(top_srcdir)/stdair/bom/EventQueue.cpp \ $(top_srcdir)/stdair/bom/BomManager.cpp Modified: trunk/stdair/stdair/factory/FacBomContent.cpp =================================================================== --- trunk/stdair/stdair/factory/FacBomContent.cpp 2010-02-10 10:14:09 UTC (rev 125) +++ trunk/stdair/stdair/factory/FacBomContent.cpp 2010-02-10 17:13:38 UTC (rev 126) @@ -5,7 +5,6 @@ #include <cassert> // STDAIR #include <stdair/bom/BomStructure.hpp> -#include <stdair/bom/DemandStream.hpp> #include <stdair/bom/BomContent.hpp> #include <stdair/factory/FacSupervisor.hpp> #include <stdair/factory/FacBomContent.hpp> @@ -48,27 +47,4 @@ _instance = NULL; } - // //////////////////////////////////////////////////////////////////// - DemandStream& FacBomContent:: - createDemandStream (const DemandStreamKey_T& iKey, - const DemandCharacteristics& iDemandCharacteristics, - const DemandDistribution& iDemandDistribution, - const RandomSeed_T& iNumberOfRequestsSeed, - const RandomSeed_T& iRequestDateTimeSeed, - const RandomSeed_T& iDemandCharacteristicsSeed) { - DemandStream* aDemandStream_ptr = NULL; - - aDemandStream_ptr = new DemandStream (iKey, iDemandCharacteristics, - iDemandDistribution, - iNumberOfRequestsSeed, - iRequestDateTimeSeed, - iDemandCharacteristicsSeed); - assert (aDemandStream_ptr != NULL); - - // The new object is added to the BOM pool - _contentPool.push_back (aDemandStream_ptr); - - return *aDemandStream_ptr; - } - } Modified: trunk/stdair/stdair/factory/FacBomContent.hpp =================================================================== --- trunk/stdair/stdair/factory/FacBomContent.hpp 2010-02-10 10:14:09 UTC (rev 125) +++ trunk/stdair/stdair/factory/FacBomContent.hpp 2010-02-10 17:13:38 UTC (rev 126) @@ -20,7 +20,7 @@ template<typename BOM> struct BomList_T; class BomStructure; class BomContent; - class DemandStream; + class EventQueue; struct OptimizerStruct_T; struct DemandCharacteristics; struct DemandDistribution; @@ -173,16 +173,6 @@ iReferenceOutboundPath._flightPathCode; } - // ////////////////////////////////////////////////////////////////// - // //////////////////////// Normal Factory ////////////////////////// - // ////////////////////////////////////////////////////////////////// - /** Create the DemandStream object. */ - DemandStream& createDemandStream (const DemandStreamKey_T&, - const DemandCharacteristics&, - const DemandDistribution&, - const RandomSeed_T&, - const RandomSeed_T&, const RandomSeed_T&); - public: /** Provide the unique instance. <br>The singleton is instantiated when first used. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qua...@us...> - 2010-02-11 14:05:05
|
Revision: 127 http://stdair.svn.sourceforge.net/stdair/?rev=127&view=rev Author: quannaus Date: 2010-02-11 12:59:00 +0000 (Thu, 11 Feb 2010) Log Message: ----------- [dev] Re-added DemandStream. Modified Paths: -------------- trunk/stdair/stdair/basic/RandomGeneration.cpp trunk/stdair/stdair/basic/RandomGeneration.hpp trunk/stdair/stdair/bom/BookingRequestTypes.hpp trunk/stdair/stdair/bom/sources.mk trunk/stdair/stdair/factory/FacBomContent.hpp Added Paths: ----------- trunk/stdair/stdair/bom/DemandStream.cpp trunk/stdair/stdair/bom/DemandStream.hpp trunk/stdair/stdair/bom/DemandStreamTypes.hpp Modified: trunk/stdair/stdair/basic/RandomGeneration.cpp =================================================================== --- trunk/stdair/stdair/basic/RandomGeneration.cpp 2010-02-10 17:13:38 UTC (rev 126) +++ trunk/stdair/stdair/basic/RandomGeneration.cpp 2010-02-11 12:59:00 UTC (rev 127) @@ -23,6 +23,13 @@ } // ////////////////////////////////////////////////////////////////////// + RandomGeneration::RandomGeneration () + : _seed (0), _generator (0), + _uniformGenerator (_generator, boost::uniform_real<> (0, 1)) { + assert (false); + } + + // ////////////////////////////////////////////////////////////////////// RandomGeneration::~RandomGeneration () { } Modified: trunk/stdair/stdair/basic/RandomGeneration.hpp =================================================================== --- trunk/stdair/stdair/basic/RandomGeneration.hpp 2010-02-10 17:13:38 UTC (rev 126) +++ trunk/stdair/stdair/basic/RandomGeneration.hpp 2010-02-11 12:59:00 UTC (rev 127) @@ -22,28 +22,30 @@ } // //////////// Business Methods ///////////// - /** Generate a randomized number following a uniform distribution between 0 (included) and 1 (excluded). */ + /** Generate a randomized number following a uniform distribution + between 0 (included) and 1 (excluded). */ RealNumber_T generateUniform01 (); - /** Generate a randomized number following a uniform distribution between a minimum (included) and a maximum (excluded) value. */ + /** Generate a randomized number following a uniform distribution + between a minimum (included) and a maximum (excluded) + value. */ RealNumber_T generateUniform (const RealNumber_T&, const RealNumber_T&); - /** Generate a randomized number following a normal distribution specified by a mean and a standard deviation. */ + /** Generate a randomized number following a normal distribution + specified by a mean and a standard deviation. */ RealNumber_T generateNormal (const RealNumber_T&, const RealNumber_T&); public: // ////////// Constructors and destructors ///////// /** Constructor. */ RandomGeneration (const RandomSeed_T&); - + /** Default constructors. */ + RandomGeneration (); + RandomGeneration (const RandomGeneration&); + /** Destructor. */ virtual ~RandomGeneration (); - public : - /** Default constructors. */ - RandomGeneration (); - RandomGeneration (const RandomGeneration&); - /** Initialize the random generator. <br>A uniform random number distribution is defined, which produces "real" values between 0 and 1 (0 inclusive, 1 Modified: trunk/stdair/stdair/bom/BookingRequestTypes.hpp =================================================================== --- trunk/stdair/stdair/bom/BookingRequestTypes.hpp 2010-02-10 17:13:38 UTC (rev 126) +++ trunk/stdair/stdair/bom/BookingRequestTypes.hpp 2010-02-11 12:59:00 UTC (rev 127) @@ -1,6 +1,6 @@ // ////////////////////////////////////////////////////////////////////// -#ifndef __STDAIR_BOM_BOOKINGCLASSTYPES_HPP -#define __STDAIR_BOM_BOOKINGCLASSTYPES_HPP +#ifndef __STDAIR_BOM_BOOKINGREQUESTTYPES_HPP +#define __STDAIR_BOM_BOOKINGREQUESTTYPES_HPP // ////////////////////////////////////////////////////////////////////// // Import section @@ -18,5 +18,5 @@ typedef boost::shared_ptr<BookingRequestStruct> BookingRequestPtr_T; } -#endif // __STDAIR_BOM_BOOKINGCLASSTYPES_HPP +#endif // __STDAIR_BOM_BOOKINGREQUESTTYPES_HPP Added: trunk/stdair/stdair/bom/DemandStream.cpp =================================================================== --- trunk/stdair/stdair/bom/DemandStream.cpp (rev 0) +++ trunk/stdair/stdair/bom/DemandStream.cpp 2010-02-11 12:59:00 UTC (rev 127) @@ -0,0 +1,66 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +#include <iosfwd> +#include <ostream> +#include <sstream> +// Boost +#include <boost/math/distributions/normal.hpp> +// Math +#include <math.h> +// STDAIR +#include <stdair/basic/BasConst_General.hpp> +#include <stdair/basic/DemandCharacteristics.hpp> +#include <stdair/basic/RandomGeneration.hpp> +#include <stdair/basic/RandomGenerationContext.hpp> +#include <stdair/bom/BookingRequestStruct.hpp> +#include <stdair/bom/DemandStream.hpp> +#include <stdair/service/Logger.hpp> + + +namespace stdair { + + // ////////////////////////////////////////////////////////////////////// + DemandStream:: + DemandStream (const DemandStreamKey_T& iKey, + const DemandCharacteristics& iDemandCharacteristics, + const DemandDistribution& iDemandDistribution, + const RandomSeed_T& iNumberOfRequestsSeed, + const RandomSeed_T& iRequestDateTimeSeed, + const RandomSeed_T& iDemandCharacteristicsSeed) + : _key (iKey), + _demandCharacteristics (iDemandCharacteristics), + _demandDistribution (iDemandDistribution), + _totalNumberOfRequestsToBeGenerated (0), + _numberOfRequestsRandomGenerator (iNumberOfRequestsSeed), + _requestDateTimeRandomGenerator (iRequestDateTimeSeed), + _demandCharacteristicsRandomGenerator (iDemandCharacteristicsSeed) { + init(); + } + + // ////////////////////////////////////////////////////////////////////// + DemandStream::~DemandStream () { + } + + // ////////////////////////////////////////////////////////////////////// + void DemandStream::init() { + // Generate the number of requests + const RealNumber_T lMu = + _demandDistribution.getMeanNumberOfRequests (); + const RealNumber_T lSigma = + _demandDistribution.getStandardDeviationNumberOfRequests (); + const RealNumber_T lRealNumberOfRequestsToBeGenerated = + _numberOfRequestsRandomGenerator.generateNormal (lMu, lSigma); + Count_T lIntegerNumberOfRequestsToBeGenerated = 0; + if (lRealNumberOfRequestsToBeGenerated < 0.5) { + lIntegerNumberOfRequestsToBeGenerated = 0; + } else { + lIntegerNumberOfRequestsToBeGenerated = + static_cast<Count_T> (lRealNumberOfRequestsToBeGenerated + 0.5); + } + _totalNumberOfRequestsToBeGenerated = lIntegerNumberOfRequestsToBeGenerated; + } + +} Added: trunk/stdair/stdair/bom/DemandStream.hpp =================================================================== --- trunk/stdair/stdair/bom/DemandStream.hpp (rev 0) +++ trunk/stdair/stdair/bom/DemandStream.hpp 2010-02-11 12:59:00 UTC (rev 127) @@ -0,0 +1,229 @@ +#ifndef __STDAIR_BOM_DEMANDSTREAM_HPP +#define __STDAIR_BOM_DEMANDSTREAM_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// Boost +#include <boost/shared_ptr.hpp> +// STL +#include <iosfwd> +// STDAIR +#include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/DemandCharacteristics.hpp> +#include <stdair/basic/DemandDistribution.hpp> +#include <stdair/basic/RandomGeneration.hpp> +#include <stdair/basic/RandomGenerationContext.hpp> +#include <stdair/bom/BomContent.hpp> +#include <stdair/bom/BookingRequestTypes.hpp> +#include <stdair/bom/DemandStreamTypes.hpp> + +namespace stdair { + + /** Class modeling a demand stream. */ + class DemandStream : public BomContent { + friend class FacBomContent; + + public: + // ///////////// Getters /////////// + /** Get the key */ + const DemandStreamKey_T& getKey () const { + return _key; + } + + /** Get the total number of requests to be generated. */ + const Count_T& getTotalNumberOfRequestsToBeGenerated() const { + return _totalNumberOfRequestsToBeGenerated; + } + + /** Get the origin. */ + const AirportCode_T& getOrigin() const { + return _demandCharacteristics.getOrigin(); + } + + /** Get the destination. */ + const AirportCode_T& getDestination() const { + return _demandCharacteristics.getDestination(); + } + + /** Get the preferred departure date. */ + const Date_T& getPreferredDepartureDate() const { + return _demandCharacteristics.getPreferredDepartureDate(); + } + + /** Get the passenger type. */ + const PassengerType_T& getPaxType() const { + return _demandCharacteristics.getPaxType(); + } + + /** Get the arrival pattern. */ + const ContinuousAttribute<FloatDuration_T>& getArrivalPattern() const { + return _demandCharacteristics.getArrivalPattern(); + } + + /** Get the mean number of requests. */ + const RealNumber_T& getMeanNumberOfRequests() const { + return _demandDistribution.getMeanNumberOfRequests(); + } + + /** Get the standard deviation of number of requests. */ + const RealNumber_T& getStandardDeviationNumberOfRequests() const { + return _demandDistribution.getStandardDeviationNumberOfRequests(); + } + + /** Get the cumulative probability of arrival pattern for last + request generated so far. */ + const Probability_T& getCumulativeProbabilitySoFar () const { + return _randomGenerationContext.getCumulativeProbabilitySoFar(); + } + + /** Get the number of requests generated so far. */ + const Count_T getNumberOfRequestsGeneratedSoFar() const { + return _randomGenerationContext.getCumulativeProbabilitySoFar();; + } + + /** Get the seed of the random generator for the number of requests. */ + const RandomSeed_T& getNumberOfRequestsRandomGeneratorSeed () const { + return _numberOfRequestsRandomGenerator.getSeed(); + } + + /** Get the seed of the random generator for the request datetime. */ + const RandomSeed_T& getRequestDateTimeRandomGeneratorSeed () const { + return _requestDateTimeRandomGenerator.getSeed(); + } + + /** Get the seed of the random generator for the demand characteristics. */ + const RandomSeed_T& getDemandCharacteristicsRandomGeneratorSeed () const { + return _demandCharacteristicsRandomGenerator.getSeed(); + } + + public: + // //////////////// Setters ////////////////// + /** Set the cumulative probability of arrival pattern for last + request generated so far. */ + void setCumulativeProbabilitySoFar (const Probability_T& iCumulativeProbability) { + _randomGenerationContext. + setCumulativeProbabilitySoFar (iCumulativeProbability); + } + + /** Set the number of requests generated so far. */ + void setNumberOfRequestsGeneratedSoFar (const Count_T& iNumberOfRequests) { + _randomGenerationContext. + setNumberOfRequestsGeneratedSoFar (iNumberOfRequests); + } + + public: + // /////////// Display support methods ///////// + /** Dump a Business Object into an output stream. + @param ostream& the output stream. */ + void toStream (std::ostream& ioOut) const { ioOut << toString(); } + + /** Read a Business Object from an input stream. + @param istream& the input stream. */ + void fromStream (std::istream& ioIn) { } + + /** Get the serialised version of the Business Object. */ + std::string toString() const { return describeKey(); } + + /** Get a string describing the whole key (differentiating two objects + at any level). */ + const std::string describeKey() const { return std::string (""); } + + /** Get a string describing the short key (differentiating two objects + at the same level). */ + const std::string describeShortKey() const { return std::string (""); } + + + public: + // /////////////// Business Methods ////////// + /** Increment counter of requests generated so far */ + void incrementGeneratedRequestsCounter () { + _randomGenerationContext.incrementGeneratedRequestsCounter(); + } + + + /** Generate a randomized number following a uniform distribution + between 0 (included) and 1 (excluded). */ + RealNumber_T generateUniform01WithNumberOfRequestRandomGenerator () { + return _numberOfRequestsRandomGenerator.generateUniform01(); + } + RealNumber_T generateUniform01WithRequestDateTimeRandomGenerator() { + return _requestDateTimeRandomGenerator.generateUniform01(); + } + RealNumber_T generateUniform01WithDemandCharacteristicsRandomGenerator() { + return _demandCharacteristicsRandomGenerator.generateUniform01(); + } + + /** Generate a randomized number following a uniform distribution + between a minimum (included) and a maximum (excluded) + value. */ + RealNumber_T generateUniformWithNumberOfRequestRandomGenerator (const RealNumber_T& iMinValue, const RealNumber_T& iMaxValue) { + return _numberOfRequestsRandomGenerator.generateUniform (iMinValue, + iMaxValue); + } + RealNumber_T generateUniformWithRequestDateTimeRandomGenerator(const RealNumber_T& iMinValue, const RealNumber_T& iMaxValue) { + return _requestDateTimeRandomGenerator.generateUniform (iMinValue, + iMaxValue); + } + RealNumber_T generateUniformWithDemandCharacteristicsRandomGenerator(const RealNumber_T& iMinValue, const RealNumber_T& iMaxValue) { + return _demandCharacteristicsRandomGenerator.generateUniform (iMinValue, + iMaxValue); + } + + /** Generate a randomized number following a normal distribution + specified by a mean and a standard deviation. */ + RealNumber_T generateNormalWithNumberOfRequestRandomGenerator (const RealNumber_T& mu, const RealNumber_T& sigma) { + return _numberOfRequestsRandomGenerator.generateNormal (mu, sigma); + } + RealNumber_T generateNormalWithRequestDateTimeRandomGenerator(const RealNumber_T& mu, const RealNumber_T& sigma) { + return _requestDateTimeRandomGenerator.generateNormal (mu, sigma); + } + RealNumber_T generateNormalWithDemandCharacteristicsRandomGenerator(const RealNumber_T& mu, const RealNumber_T& sigma) { + return _demandCharacteristicsRandomGenerator.generateNormal (mu, sigma); + } + + protected: + // ////////// Constructors and destructors ///////// + /** Constructor by default */ + DemandStream (const DemandStreamKey_T&, + const DemandCharacteristics&, + const DemandDistribution&, const RandomSeed_T&, + const RandomSeed_T&, const RandomSeed_T&); + /** Default constructors. */ + DemandStream (); + DemandStream (const DemandStream&); + /** Initialization. */ + void init(); + /** Destructor. */ + ~DemandStream (); + + + protected: + // ////////// Attributes ////////// + /** Key */ + DemandStreamKey_T _key; + + /** Demand characteristics */ + DemandCharacteristics _demandCharacteristics; + + /** Demand distribution */ + DemandDistribution _demandDistribution; + + /** Total number of requests to be generated*/ + Count_T _totalNumberOfRequestsToBeGenerated; + + /** Random generation context */ + RandomGenerationContext _randomGenerationContext; + + /** Random generator for number of requests */ + RandomGeneration _numberOfRequestsRandomGenerator; + + /** Random generator for request datetime */ + RandomGeneration _requestDateTimeRandomGenerator; + + /** Random generator for demand characteristics */ + RandomGeneration _demandCharacteristicsRandomGenerator; + }; + +} +#endif // __STDAIR_BOM_DEMANDSTREAM_HPP Added: trunk/stdair/stdair/bom/DemandStreamTypes.hpp =================================================================== --- trunk/stdair/stdair/bom/DemandStreamTypes.hpp (rev 0) +++ trunk/stdair/stdair/bom/DemandStreamTypes.hpp 2010-02-11 12:59:00 UTC (rev 127) @@ -0,0 +1,21 @@ +#ifndef __STDAIR_BOM_DEMANDSTREAMTYPES_HPP +#define __STDAIR_BOM_DEMANDSTREAMTYPES_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <map> +// STDAIR +#include <stdair/STDAIR_Types.hpp> + +namespace stdair { + + // Forward declaration + class DemandStream; + + /** Define a map of demand strams. */ + typedef std::map<const DemandStreamKey_T, DemandStream*> DemandStreamList_T; + +} +#endif // __STDAIR_BOM_DEMANDSTREAMTYPES_HPP Modified: trunk/stdair/stdair/bom/sources.mk =================================================================== --- trunk/stdair/stdair/bom/sources.mk 2010-02-10 17:13:38 UTC (rev 126) +++ trunk/stdair/stdair/bom/sources.mk 2010-02-11 12:59:00 UTC (rev 127) @@ -86,6 +86,8 @@ $(top_srcdir)/stdair/bom/TravelSolutionTypes.hpp \ $(top_srcdir)/stdair/bom/BookingRequestStruct.hpp \ $(top_srcdir)/stdair/bom/AirlineStruct.hpp \ + $(top_srcdir)/stdair/bom/DemandStream.hpp \ + $(top_srcdir)/stdair/bom/DemandStreamTypes.hpp \ $(top_srcdir)/stdair/bom/EventStruct.hpp \ $(top_srcdir)/stdair/bom/EventQueue.hpp \ $(top_srcdir)/stdair/bom/EventTypes.hpp \ @@ -138,6 +140,7 @@ $(top_srcdir)/stdair/bom/TravelSolutionStruct.cpp \ $(top_srcdir)/stdair/bom/BookingRequestStruct.cpp \ $(top_srcdir)/stdair/bom/AirlineStruct.cpp \ + $(top_srcdir)/stdair/bom/DemandStream.cpp \ $(top_srcdir)/stdair/bom/EventStruct.cpp \ $(top_srcdir)/stdair/bom/EventQueue.cpp \ $(top_srcdir)/stdair/bom/BomManager.cpp Modified: trunk/stdair/stdair/factory/FacBomContent.hpp =================================================================== --- trunk/stdair/stdair/factory/FacBomContent.hpp 2010-02-10 17:13:38 UTC (rev 126) +++ trunk/stdair/stdair/factory/FacBomContent.hpp 2010-02-11 12:59:00 UTC (rev 127) @@ -173,6 +173,29 @@ iReferenceOutboundPath._flightPathCode; } + // ////////////////////////////////////////////////////////////////// + // /////////////////////// Dedicated factories ////////////////////// + // ////////////////////////////////////////////////////////////////// + template <typename DEMAND_STREAM> + DEMAND_STREAM& create (const DemandStreamKey_T& iKey, + const DemandCharacteristics& iDemandCharacteristics, + const DemandDistribution& iDemandDistribution, + const RandomSeed_T& iNumberOfRequestsSeed, + const RandomSeed_T& iRequestDateTimeSeed, + const RandomSeed_T& iDemandCharacteristicsSeed) { + DEMAND_STREAM* aDemandStream_ptr = + new DEMAND_STREAM (iKey, iDemandCharacteristics, iDemandDistribution, + iNumberOfRequestsSeed, iRequestDateTimeSeed, + iDemandCharacteristicsSeed); + assert (aDemandStream_ptr != NULL); + + // The new object is added to the pool of content objects + _contentPool.push_back (aDemandStream_ptr); + + return *aDemandStream_ptr; + } + + public: /** Provide the unique instance. <br>The singleton is instantiated when first used. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-02-15 01:20:35
|
Revision: 133 http://stdair.svn.sourceforge.net/stdair/?rev=133&view=rev Author: denis_arnaud Date: 2010-02-15 01:20:27 +0000 (Mon, 15 Feb 2010) Log Message: ----------- [Demand] Added support for Demand-related object creation from the new demand input file parser. Modified Paths: -------------- trunk/stdair/stdair/STDAIR_Service.hpp trunk/stdair/stdair/STDAIR_Types.hpp trunk/stdair/stdair/basic/ContinuousAttribute.hpp trunk/stdair/stdair/basic/DemandCharacteristics.cpp trunk/stdair/stdair/basic/DemandCharacteristics.hpp trunk/stdair/stdair/basic/DemandDistribution.cpp trunk/stdair/stdair/basic/DemandDistribution.hpp trunk/stdair/stdair/basic/sources.mk trunk/stdair/stdair/bom/BomRoot.cpp trunk/stdair/stdair/bom/BomRoot.hpp trunk/stdair/stdair/bom/BookingRequestStruct.cpp trunk/stdair/stdair/bom/BookingRequestStruct.hpp trunk/stdair/stdair/bom/DemandStream.cpp trunk/stdair/stdair/bom/DemandStream.hpp trunk/stdair/stdair/bom/DemandStreamTypes.hpp trunk/stdair/stdair/bom/EventStruct.cpp trunk/stdair/stdair/bom/EventStruct.hpp trunk/stdair/stdair/bom/InventoryKey.hpp trunk/stdair/stdair/bom/sources.mk trunk/stdair/stdair/command/CmdBomManager.cpp trunk/stdair/stdair/command/CmdBomManager.hpp trunk/stdair/stdair/factory/FacBomContent.hpp trunk/stdair/stdair/service/STDAIR_Service.cpp Added Paths: ----------- trunk/stdair/stdair/basic/ArrivalPattern.hpp trunk/stdair/stdair/basic/PassengerType.cpp trunk/stdair/stdair/basic/PassengerType.hpp trunk/stdair/stdair/bom/DemandStreamKey.cpp trunk/stdair/stdair/bom/DemandStreamKey.hpp Modified: trunk/stdair/stdair/STDAIR_Service.hpp =================================================================== --- trunk/stdair/stdair/STDAIR_Service.hpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/STDAIR_Service.hpp 2010-02-15 01:20:27 UTC (rev 133) @@ -97,6 +97,10 @@ BomRoot. */ void initAirlineFeatureSet (); + /** Initialise the DemandStreamList object, and attach it to the + BomRoot. */ + void initDemandStreamList (); + /** Finalise. */ void finalise (); Modified: trunk/stdair/stdair/STDAIR_Types.hpp =================================================================== --- trunk/stdair/stdair/STDAIR_Types.hpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/STDAIR_Types.hpp 2010-02-15 01:20:27 UTC (rev 133) @@ -47,6 +47,15 @@ class MemoryAllocationException : public RootException { }; + class ParserException : public RootException { + }; + + class CodeConversionException : public ParserException { + }; + + class CodeDuplicationException : public ParserException { + }; + class ObjectNotFoundException : public RootException { }; @@ -438,9 +447,5 @@ /** Real number */ typedef double RealNumber_T; - - // ////////////////////////////////////////////////////////////////////// - // Demand - typedef int DemandStreamKey_T; } #endif // __STDAIR_STDAIR_TYPES_HPP Added: trunk/stdair/stdair/basic/ArrivalPattern.hpp =================================================================== --- trunk/stdair/stdair/basic/ArrivalPattern.hpp (rev 0) +++ trunk/stdair/stdair/basic/ArrivalPattern.hpp 2010-02-15 01:20:27 UTC (rev 133) @@ -0,0 +1,27 @@ +#ifndef __STDAIR_BAS_ARRIVALPATTERN_HPP +#define __STDAIR_BAS_ARRIVALPATTERN_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// StdAir +#include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/ContinuousAttribute.hpp> + +namespace stdair { + + /** Type definition for the continuous distribition of the duration + (as a float number). */ + typedef ContinuousAttribute<FloatDuration_T> ContinuousFloatDuration_T; + + /** Type definition for the arrival pattern. */ + typedef ContinuousFloatDuration_T::ContinuousDistribution_T ArrivalPattern_T; + + /** Type definition for the arrival pattern cumulative distribution. */ + typedef std::multimap<FloatDuration_T, Probability_T> ArrivalPatternCumulativeDistribution_T; + + /** Type definition for the arrival pattern inverse cumulative distribution. */ + typedef std::multimap<Probability_T, FloatDuration_T> ArrivalPatternInverseCumulativeDistribution_T; + +} +#endif // __STDAIR_BAS_ARRIVALPATTERN_HPP Modified: trunk/stdair/stdair/basic/ContinuousAttribute.hpp =================================================================== --- trunk/stdair/stdair/basic/ContinuousAttribute.hpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/basic/ContinuousAttribute.hpp 2010-02-15 01:20:27 UTC (rev 133) @@ -9,6 +9,7 @@ #include <map> // STDAIR #include <stdair/STDAIR_Types.hpp> +#include <stdair/service/Logger.hpp> namespace stdair { @@ -17,22 +18,28 @@ template <class T> struct ContinuousAttribute { public: + + // ///////////// Type definitions ////////////// + /** */ + typedef std::multimap<T, Probability_T> ContinuousDistribution_T; + typedef std::multimap<Probability_T, T> ContinuousInverseDistribution_T; + + // ///////////// Getters /////////// /** Get the cumulative distribution. */ - const std::multimap<T,Probability_T>& getCumulativeDistribution() const { + const ContinuousDistribution_T& getCumulativeDistribution() const { return _cumulativeDistribution; } /** Get the inverse cumulative distribution. */ - const std::multimap<Probability_T, T>& - getInverseCumulativeDistribution () const { + const ContinuousInverseDistribution_T& getInverseCumulativeDistribution () const { return _inverseCumulativeDistribution; } public: // ///////////// Setters /////////// /** Set the cumulative distribution */ - void setCumulativeDistribution (const std::multimap<T, Probability_T>& iCumulativeDistribution) { + void setCumulativeDistribution (const ContinuousDistribution_T& iCumulativeDistribution) { _cumulativeDistribution = iCumulativeDistribution; determineInverseCumulativeDistributionFromCumulativeDistribution(); } @@ -40,15 +47,15 @@ public: // /////////////// Business Methods ////////// /** Get value from inverse cumulative distribution. */ - const T getValue(const Probability_T& iCumulativeProbability) const { - typename std::multimap<Probability_T, T>::const_iterator it = + const T getValue (const Probability_T& iCumulativeProbability) const { + typename ContinuousDistribution_T::const_iterator it = _inverseCumulativeDistribution.lower_bound (iCumulativeProbability); Probability_T cumulativeProbabilityNextPoint = it->first; T valueNextPoint = it->second; if (it == _inverseCumulativeDistribution.begin()) { - std::cout << "hello" << std::endl; + STDAIR_LOG_DEBUG ("Last element"); return valueNextPoint; } --it; @@ -75,11 +82,14 @@ /** Display cumulative distribution */ std::string displayCumulativeDistribution() const { std::ostringstream oStr; - for (typename std::multimap<T, Probability_T>::const_iterator it = + unsigned int idx = 0; + for (typename ContinuousDistribution_T::const_iterator it = _cumulativeDistribution.begin(); - it != _cumulativeDistribution.end(); ++it) { - oStr << "value: " << it->first - << " cumulative probability: " << it->second << std::endl; + it != _cumulativeDistribution.end(); ++it, ++idx) { + if (idx != 0) { + oStr << ", "; + } + oStr << it->first << ":" << it->second; } return oStr.str(); } @@ -87,7 +97,7 @@ /** Display inverse cumulative distribution */ std::string displayInverseCumulativeDistribution() const { std::ostringstream oStr; - for (typename std::multimap<Probability_T, T>::const_iterator it = + for (typename ContinuousInverseDistribution_T::const_iterator it = _inverseCumulativeDistribution.begin(); it != _inverseCumulativeDistribution.end(); ++it) { oStr << "cumulative prob: " << it->first @@ -102,7 +112,8 @@ ContinuousAttribute () { } /** Constructor */ - ContinuousAttribute (const std::multimap<T, Probability_T>& iCumulativeDistribution) : _cumulativeDistribution (iCumulativeDistribution) { + ContinuousAttribute (const ContinuousDistribution_T& iCumulativeDistribution) + : _cumulativeDistribution (iCumulativeDistribution) { determineInverseCumulativeDistributionFromCumulativeDistribution(); } @@ -118,13 +129,13 @@ /** Determine inverse cumulative distribution from cumulative distribution (initialisation). */ void determineInverseCumulativeDistributionFromCumulativeDistribution () { - for (typename std::multimap<T, Probability_T>::iterator itCumulativeDistribution = + for (typename ContinuousDistribution_T::iterator itCumulativeDistribution = _cumulativeDistribution.begin(); itCumulativeDistribution != _cumulativeDistribution.end(); ++itCumulativeDistribution) { _inverseCumulativeDistribution. - insert ( std::pair<float, float> (itCumulativeDistribution->second, - itCumulativeDistribution->first) ); + insert (std::pair<float, float> (itCumulativeDistribution->second, + itCumulativeDistribution->first)); } } @@ -132,11 +143,10 @@ // ////////// Attributes ////////// /** Cumulative distribution */ - std::multimap<T, Probability_T> _cumulativeDistribution; + ContinuousDistribution_T _cumulativeDistribution; /** Inverse cumulative distribution */ - std::multimap<Probability_T, T> _inverseCumulativeDistribution; - + ContinuousInverseDistribution_T _inverseCumulativeDistribution; }; } Modified: trunk/stdair/stdair/basic/DemandCharacteristics.cpp =================================================================== --- trunk/stdair/stdair/basic/DemandCharacteristics.cpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/basic/DemandCharacteristics.cpp 2010-02-15 01:20:27 UTC (rev 133) @@ -4,15 +4,21 @@ // STL #include <cassert> #include <sstream> -// STDAIR +// StdAir #include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/BasConst_General.hpp> #include <stdair/basic/DemandCharacteristics.hpp> namespace stdair { // ///////////////////////////////////////////////////// + DemandCharacteristics::DemandCharacteristics (const DemandStreamKey_T& iKey) + : _key (iKey) { + } + + // ///////////////////////////////////////////////////// DemandCharacteristics::DemandCharacteristics () - : _origin ("") { + : _key (DemandStreamKey_T("", "", DEFAULT_DATE, PassengerType::LAST_VALUE)) { } // ///////////////////////////////////////////////////// @@ -22,28 +28,49 @@ // ///////////////////////////////////////////////////// DemandCharacteristics:: DemandCharacteristics (const DemandCharacteristics& iDemandCharacteristics) - : _origin (iDemandCharacteristics._origin), - _destination (iDemandCharacteristics._destination), - _preferredDepartureDate (iDemandCharacteristics._preferredDepartureDate), - _paxType (iDemandCharacteristics._paxType), + : _key (iDemandCharacteristics._key), _arrivalPattern (iDemandCharacteristics._arrivalPattern) { } // ///////////////////////////////////////////////////// + const AirportCode_T& DemandCharacteristics::getOrigin() const { + return _key.getOrigin(); + } + + // ///////////////////////////////////////////////////// + const AirportCode_T& DemandCharacteristics::getDestination() const { + return _key.getDestination(); + } + + // ///////////////////////////////////////////////////// + const Date_T& DemandCharacteristics::getPreferredDepartureDate() const { + return _key.getPreferredDepartureDate(); + } + + // ///////////////////////////////////////////////////// + const PassengerType& DemandCharacteristics::getPaxType() const { + return _key.getPassengerType(); + } + + // ///////////////////////////////////////////////////// std::string DemandCharacteristics::display() const { std::ostringstream oStr; // - oStr << "****************** Demand characteristics ******************"; - oStr << "Origin ........................... : " - << _origin << std::endl; + oStr << "****************** Demand characteristics ******************" + << std::endl; + oStr << "Origin ........................... : " << _key.getOrigin() + << std::endl; + oStr << "Destination ...................... : " << _key.getDestination() + << std::endl; oStr << "Preferred departure date ......... : " - << _preferredDepartureDate << std::endl; - oStr << "Arrival pattern (days from departure, proportion):" - << std::endl; + << _key.getPreferredDepartureDate() << std::endl; + oStr << "Passenger type ................... : " << _key.getPassengerType() + << std::endl; + oStr << "Arrival pattern (days from departure, proportion): "; // - oStr << _arrivalPattern.displayCumulativeDistribution(); + oStr << _arrivalPattern.displayCumulativeDistribution() << std::endl; return oStr.str(); } Modified: trunk/stdair/stdair/basic/DemandCharacteristics.hpp =================================================================== --- trunk/stdair/stdair/basic/DemandCharacteristics.hpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/basic/DemandCharacteristics.hpp 2010-02-15 01:20:27 UTC (rev 133) @@ -6,9 +6,10 @@ // ////////////////////////////////////////////////////////////////////// // STL #include <string> -// STDAIR +// StdAir #include <stdair/STDAIR_Types.hpp> -#include <stdair/basic/ContinuousAttribute.hpp> +#include <stdair/basic/ArrivalPattern.hpp> +#include <stdair/bom/DemandStreamKey.hpp> namespace stdair { @@ -17,58 +18,37 @@ public: // ///////////// Getters /////////// - /** Get the origin. */ - const AirportCode_T& getOrigin() const { - return _origin; + /** Get the key. */ + const DemandStreamKey_T& getKey() const { + return _key; } + /** Get the origin. */ + const AirportCode_T& getOrigin() const; + /** Get the destination. */ - const AirportCode_T& getDestination() const { - return _destination; - } + const AirportCode_T& getDestination() const; /** Get the preferred departure date. */ - const Date_T& getPreferredDepartureDate() const { - return _preferredDepartureDate; - } + const Date_T& getPreferredDepartureDate() const; /** Get the passenger type. */ - const PassengerType_T& getPaxType() const { - return _paxType; - } + const PassengerType& getPaxType() const; /** Get the arrival pattern. */ - const ContinuousAttribute<FloatDuration_T>& getArrivalPattern() const { + const ContinuousFloatDuration_T& getArrivalPattern() const { return _arrivalPattern; } + public: // ///////////// Setters /////////// - /** Set the origin. */ - void setOrigin (const AirportCode_T& iOrigin) { - _origin = iOrigin; - } - - /** Set the destination. */ - void setDestination (const AirportCode_T& iDestination) { - _destination = iDestination; - } - - /** Set the preferred departure date. */ - void setPreferredDepartureDate (const Date_T& iPreferredDepartureDate) { - _preferredDepartureDate = iPreferredDepartureDate; - } - - /** Set the passenger type. */ - void setPaxType (const PassengerType_T& iPaxType) { - _paxType = iPaxType; - } - /** Set the arrival pattern. */ - void setArrivalPattern (const ContinuousAttribute<FloatDuration_T>& iArrivalPattern) { + void setArrivalPattern (const ContinuousFloatDuration_T& iArrivalPattern) { _arrivalPattern = iArrivalPattern; } + public: // ////////////// Display Support Methods ////////// /** Display demand characteristics */ @@ -77,34 +57,30 @@ public: // ////////// Constructors and destructors ///////// - /** Constructor by default */ + /** Default constructor. */ + DemandCharacteristics (const DemandStreamKey_T& iKey); + + /** Default constructor. */ + // TODO: That copy constructor should be private DemandCharacteristics (); - /** Copy constructor */ - DemandCharacteristics (const DemandCharacteristics&); // Should be private, but well... + /** Copy constructor. */ + // TODO: That copy constructor should be private + DemandCharacteristics (const DemandCharacteristics&); /** Destructor */ virtual ~DemandCharacteristics (); - + private: - // ////////// Attributes ////////// - /** Origin */ - AirportCode_T _origin; + // //////////////////// Attributes ///////////////////// + /** DemandStream Key */ + const DemandStreamKey_T& _key; - /** Origin */ - AirportCode_T _destination; - - /** Preferred departure date */ - Date_T _preferredDepartureDate; - - /** Passenger type. */ - PassengerType_T _paxType; - /** Arrival pattern (cumulative distribution of timing of arrival of requests (negative number of days between departure date - and request date)*/ - ContinuousAttribute<FloatDuration_T> _arrivalPattern; + and request date). */ + ContinuousFloatDuration_T _arrivalPattern; /** Trip type probability mass */ // CategoricalAttribute<TripType_T> _tripTypeProbabilityMass; Modified: trunk/stdair/stdair/basic/DemandDistribution.cpp =================================================================== --- trunk/stdair/stdair/basic/DemandDistribution.cpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/basic/DemandDistribution.cpp 2010-02-15 01:20:27 UTC (rev 133) @@ -9,6 +9,14 @@ #include <stdair/basic/DemandDistribution.hpp> namespace stdair { + + // ///////////////////////////////////////////////////// + DemandDistribution:: + DemandDistribution (const NbOfRequests_T& iMean, + const StandardDeviationValue_T& iStandardDeviation) + : _meanNumberOfRequests (iMean), + _standardDeviationNumberOfRequests (iStandardDeviation){ + } // ///////////////////////////////////////////////////// DemandDistribution::DemandDistribution () { @@ -20,10 +28,9 @@ // ///////////////////////////////////////////////////// DemandDistribution:: - DemandDistribution (const DemandDistribution& iDemandDistribution) { - _meanNumberOfRequests = iDemandDistribution._meanNumberOfRequests; - _standardDeviationNumberOfRequests = - iDemandDistribution._standardDeviationNumberOfRequests; + DemandDistribution (const DemandDistribution& iDemandDistribution) + : _meanNumberOfRequests (iDemandDistribution._meanNumberOfRequests), + _standardDeviationNumberOfRequests (iDemandDistribution._standardDeviationNumberOfRequests) { } // ///////////////////////////////////////////////////// @@ -31,11 +38,11 @@ std::ostringstream oStr; oStr << "****************** Demand distribution ******************" - << std::endl; + << std::endl; oStr << "Mean number of requests .......... : " - << _meanNumberOfRequests << std::endl; + << _meanNumberOfRequests << std::endl; oStr << "Std dev of number of requests .... : " - << _standardDeviationNumberOfRequests << std::endl; + << _standardDeviationNumberOfRequests << std::endl; return oStr.str(); } Modified: trunk/stdair/stdair/basic/DemandDistribution.hpp =================================================================== --- trunk/stdair/stdair/basic/DemandDistribution.hpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/basic/DemandDistribution.hpp 2010-02-15 01:20:27 UTC (rev 133) @@ -18,24 +18,24 @@ // ///////////// Getters /////////// /** Get the mean number of requests. */ - const RealNumber_T& getMeanNumberOfRequests() const { + const NbOfRequests_T& getMeanNumberOfRequests() const { return _meanNumberOfRequests; } /** Get the standard deviation of number of requests. */ - const RealNumber_T& getStandardDeviationNumberOfRequests() const { + const StandardDeviationValue_T& getStandardDeviationNumberOfRequests() const { return _standardDeviationNumberOfRequests; } public: // ///////////// Setters /////////// /** Set the mean number of requests. */ - void setMeanNumberOfRequests (const RealNumber_T& iMean) { + void setMeanNumberOfRequests (const NbOfRequests_T& iMean) { _meanNumberOfRequests = iMean; } /** Set the standard deviation of number of requests. */ - void setStandardDeviationNumberOfRequests (const RealNumber_T& iStandardDeviation) { + void setStandardDeviationNumberOfRequests (const StandardDeviationValue_T& iStandardDeviation) { _standardDeviationNumberOfRequests = iStandardDeviation; } @@ -47,23 +47,29 @@ public: // ////////// Constructors and destructors ///////// - /** Constructor by default */ + /** Constructor. */ + DemandDistribution (const NbOfRequests_T& iMean, + const StandardDeviationValue_T& iStandardDeviation); + + /** Default constructor. */ + // TODO: That constructor should be private DemandDistribution (); - /** Copy constructor */ - DemandDistribution (const DemandDistribution&); // Should be private, but well... + /** Copy constructor. */ + // TODO: That constructor should be private + DemandDistribution (const DemandDistribution&); - /** Destructor */ + /** Destructor. */ virtual ~DemandDistribution (); - - + + private: // ////////// Attributes ////////// /** Mean number of requests */ - RealNumber_T _meanNumberOfRequests; + NbOfRequests_T _meanNumberOfRequests; /** Standard deviation of number of requests */ - RealNumber_T _standardDeviationNumberOfRequests; + StandardDeviationValue_T _standardDeviationNumberOfRequests; }; } Added: trunk/stdair/stdair/basic/PassengerType.cpp =================================================================== --- trunk/stdair/stdair/basic/PassengerType.cpp (rev 0) +++ trunk/stdair/stdair/basic/PassengerType.cpp 2010-02-15 01:20:27 UTC (rev 133) @@ -0,0 +1,78 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +#include <sstream> +// StdAir +#include <stdair/service/Logger.hpp> +// Stdair +#include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/PassengerType.hpp> + +namespace stdair { + + // ////////////////////////////////////////////////////////////////////// + const std::string PassengerType::_labels[LAST_VALUE] = + { "Leisure", "Business", "First" }; + + const char PassengerType::_typeLabels[LAST_VALUE] = { 'L', 'B', 'F' }; + + + // ////////////////////////////////////////////////////////////////////// + PassengerType::PassengerType (const EN_PassengerType& iPassengerType) + : _type (iPassengerType) { + } + + // ////////////////////////////////////////////////////////////////////// + PassengerType::PassengerType (const char iType) { + switch (iType) { + case 'L': _type = LEISURE; break; + case 'B': _type = BUSINESS; break; + case 'F': _type = FIRST; break; + default: _type = LAST_VALUE; break; + } + + if (_type == LAST_VALUE) { + const std::string& lLabels = describeLabels(); + STDAIR_LOG_ERROR ("The passenger type '" << iType + << "' is not known. Known passenger types: " << lLabels); + throw CodeConversionException(); + } + } + + // ////////////////////////////////////////////////////////////////////// + const std::string& PassengerType::getLabel (const EN_PassengerType& iType) { + return _labels[iType]; + } + + // ////////////////////////////////////////////////////////////////////// + char PassengerType::getTypeLabel(const EN_PassengerType& iType) { + return _typeLabels[iType]; + } + + // ////////////////////////////////////////////////////////////////////// + std::string PassengerType::describeLabels() { + std::ostringstream ostr; + for (unsigned short idx = 0; idx != LAST_VALUE; ++idx) { + if (idx != 0) { + ostr << ", "; + } + ostr << _labels[idx]; + } + return ostr.str(); + } + + // ////////////////////////////////////////////////////////////////////// + PassengerType::EN_PassengerType PassengerType::getType() const { + return _type; + } + + // ////////////////////////////////////////////////////////////////////// + const std::string PassengerType::describe() const { + std::ostringstream ostr; + ostr << _labels[_type]; + return ostr.str(); + } + +} Added: trunk/stdair/stdair/basic/PassengerType.hpp =================================================================== --- trunk/stdair/stdair/basic/PassengerType.hpp (rev 0) +++ trunk/stdair/stdair/basic/PassengerType.hpp 2010-02-15 01:20:27 UTC (rev 133) @@ -0,0 +1,61 @@ +#ifndef __STDAIR_BAS_PASSENGERTYPE_HPP +#define __STDAIR_BAS_PASSENGERTYPE_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <string> +// StdAir +#include <stdair/bom/StructAbstract.hpp> + +namespace stdair { + + /** Enumeration of Frequent Flyer types. */ + struct PassengerType : public StructAbstract { + public: + typedef enum { + LEISURE = 0, + BUSINESS, + FIRST, + LAST_VALUE + } EN_PassengerType; + + /** Get the label as a string. */ + static const std::string& getLabel (const EN_PassengerType&); + + /** Get the label as a single char. */ + static char getTypeLabel (const EN_PassengerType&); + + /** List the labels. */ + static std::string describeLabels(); + + /** Get the enumerated value. */ + EN_PassengerType getType() const; + + /** Give a description of the structure (for display purposes). */ + const std::string describe() const; + + + public: + /** Constructor. */ + PassengerType (const EN_PassengerType&); + /** Constructor. */ + PassengerType (const char iType); + + + private: + /** String version of the enumeration. */ + static const std::string _labels[LAST_VALUE]; + /** Type version of the enumeration. */ + static const char _typeLabels[LAST_VALUE]; + + + private: + // //////// Attributes ///////// + /** Frequent flyer type. */ + EN_PassengerType _type; + }; + +} +#endif // __STDAIR_BAS_PASSENGERTYPE_HPP Modified: trunk/stdair/stdair/basic/sources.mk =================================================================== --- trunk/stdair/stdair/basic/sources.mk 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/basic/sources.mk 2010-02-15 01:20:27 UTC (rev 133) @@ -11,7 +11,9 @@ $(top_srcdir)/stdair/basic/BasFileMgr.hpp \ $(top_srcdir)/stdair/basic/BasLogParams.hpp \ $(top_srcdir)/stdair/basic/BasDBParams.hpp \ + $(top_srcdir)/stdair/basic/PassengerType.hpp \ $(top_srcdir)/stdair/basic/ContinuousAttribute.hpp \ + $(top_srcdir)/stdair/basic/ArrivalPattern.hpp \ $(top_srcdir)/stdair/basic/CategoricalAttribute.hpp \ $(top_srcdir)/stdair/basic/DemandCharacteristics.hpp \ $(top_srcdir)/stdair/basic/DemandDistribution.hpp \ @@ -23,6 +25,7 @@ $(top_srcdir)/stdair/basic/BasFileMgr.cpp \ $(top_srcdir)/stdair/basic/BasLogParams.cpp \ $(top_srcdir)/stdair/basic/BasDBParams.cpp \ + $(top_srcdir)/stdair/basic/PassengerType.cpp \ $(top_srcdir)/stdair/basic/DemandCharacteristics.cpp \ $(top_srcdir)/stdair/basic/DemandDistribution.cpp \ $(top_srcdir)/stdair/basic/RandomGeneration.cpp \ Modified: trunk/stdair/stdair/bom/BomRoot.cpp =================================================================== --- trunk/stdair/stdair/bom/BomRoot.cpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/bom/BomRoot.cpp 2010-02-15 01:20:27 UTC (rev 133) @@ -10,6 +10,8 @@ #include <stdair/bom/BomMap.hpp> #include <stdair/bom/Inventory.hpp> #include <stdair/bom/Network.hpp> +#include <stdair/bom/DemandStream.hpp> +#include <stdair/service/Logger.hpp> namespace stdair { @@ -75,5 +77,31 @@ assert (_airlineFeatureSet != NULL); return *_airlineFeatureSet; } + + // //////////////////////////////////////////////////////////////////// + DemandStreamList_T& BomRoot::getDemandStreamListRef() const { + // TODO: check that the Boost smart pointer is not NULL + STDAIR_LOG_ERROR ("!!!!TODO: check that the Boost smart pointer is not NULL!!!!"); + return *_demandStreamList; + } + // //////////////////////////////////////////////////////////////////// + void BomRoot::addDemandStream (const DemandStreamKeyStr_T& iKeyStr, + DemandStream& ioDemandStream) { + // TODO: check that the Boost smart pointer is not NULL + STDAIR_LOG_ERROR ("!!!!TODO: check that the Boost smart pointer is not NULL!!!!"); + + // Insert the reference on the given DemandStream object into the + // dedicated list + const bool hasInsertBeenSuccessfull = + _demandStreamList->insert (DemandStreamList_T:: + value_type (iKeyStr, &ioDemandStream)).second; + if (hasInsertBeenSuccessfull == false) { + STDAIR_LOG_ERROR ("The DemandStream object with key: " << iKeyStr + << " can not be inserted into the dedicated list"); + STDAIR_LOG_ERROR ("DemandStream object: " << ioDemandStream); + assert (false); + } + } + } Modified: trunk/stdair/stdair/bom/BomRoot.hpp =================================================================== --- trunk/stdair/stdair/bom/BomRoot.hpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/bom/BomRoot.hpp 2010-02-15 01:20:27 UTC (rev 133) @@ -12,6 +12,7 @@ #include <stdair/bom/BomRootTypes.hpp> #include <stdair/bom/InventoryTypes.hpp> #include <stdair/bom/NetworkTypes.hpp> +#include <stdair/bom/DemandStreamTypes.hpp> namespace stdair { // Forward declarations. @@ -102,6 +103,7 @@ at the same level). */ const std::string describeShortKey() const { return std::string (""); } + public: // /////////// Getters ///////////// /** Get a InventoryList_T for iteration methods. */ @@ -119,6 +121,14 @@ /** Get the reference of the AirlineFeatureSet object. */ AirlineFeatureSet& getAirlineFeatureSet() const; + /** Get the reference of the list of DemandStream objects. */ + DemandStreamListPtr_T getDemandStreamList() const { + return _demandStreamList; + } + + /** Get the reference of the list of DemandStream objects. */ + DemandStreamList_T& getDemandStreamListRef() const; + /** Retrieve, if existing, the Inventory corresponding to the given airline code (Inventory key). <br>If not existing, return the NULL pointer. */ @@ -128,6 +138,7 @@ given airline code (Network key). <br>If not existing, return the NULL pointer. */ Network* getNetwork (const NetworkID_T&) const; + public: // //////////// Setters ////////////// @@ -136,6 +147,17 @@ _airlineFeatureSet = ioAirlineFeatureSet_ptr; } + /** Set the reference to the DemandStreamList object. */ + void setDemandStreamList (DemandStreamListPtr_T ioDemandStreamList_ptr) { + _demandStreamList = ioDemandStreamList_ptr; + } + + /** Add a demand stream object to the dedicated list. + @param const DemandStreamKeyStr_T& (String) Key of the DemandStream + object to be added. + @param DemandStreamList_T& List of DemandStream objects. */ + void addDemandStream (const DemandStreamKeyStr_T&, DemandStream&); + private: /** Retrieve the BOM structure object. */ BomStructure_T& getBomStructure () { @@ -157,8 +179,11 @@ /** Reference structure. */ BomStructure_T& _bomRootStructure; - /** Set of all AirlineFeatures.*/ + /** Set of all AirlineFeatures. */ AirlineFeatureSet* _airlineFeatureSet; + + /** Set of all DemandStream objects. */ + DemandStreamListPtr_T _demandStreamList; }; } Modified: trunk/stdair/stdair/bom/BookingRequestStruct.cpp =================================================================== --- trunk/stdair/stdair/bom/BookingRequestStruct.cpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/bom/BookingRequestStruct.cpp 2010-02-15 01:20:27 UTC (rev 133) @@ -16,7 +16,7 @@ const AirportCode_T& iDestination, const Date_T& iDepartureDate, const DateTime_T& iRequestDateTime, - const PassengerType_T& iPaxType, + const PassengerType& iPaxType, const NbOfSeats_T& iPartySize) : _origin (iOrigin), _destination (iDestination), _preferredDepartureDate (iDepartureDate), Modified: trunk/stdair/stdair/bom/BookingRequestStruct.hpp =================================================================== --- trunk/stdair/stdair/bom/BookingRequestStruct.hpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/bom/BookingRequestStruct.hpp 2010-02-15 01:20:27 UTC (rev 133) @@ -8,14 +8,14 @@ #include <iosfwd> #include <string> // StdAir +#include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/PassengerType.hpp> #include <stdair/bom/StructAbstract.hpp> -#include <stdair/STDAIR_Types.hpp> namespace stdair { /** Structure holding the elements of a booking request. */ struct BookingRequestStruct : public StructAbstract { - public: // /////////////// Getters ///////////////// /** Get the requested origin. */ @@ -39,7 +39,7 @@ } /** Get the passenger type. */ - const PassengerType_T& getPaxType() const { + const PassengerType& getPaxType() const { return _paxType; } @@ -71,7 +71,7 @@ } /** Set the passenger type. */ - void setPaxType (const PassengerType_T& iPaxType) { + void setPaxType (const PassengerType& iPaxType) { _paxType = iPaxType; } @@ -93,15 +93,20 @@ /** Display of the structure. */ const std::string describe() const; + // /////////////// Constructors and Destructors ///////////////// public : + /** Constructor. */ BookingRequestStruct (const AirportCode_T&, const AirportCode_T&, const Date_T&, const DateTime_T&, - const PassengerType_T&, const NbOfSeats_T&); + const PassengerType&, const NbOfSeats_T&); public : + /** Default constructor. */ BookingRequestStruct (); + /** Copy constructor. */ BookingRequestStruct (const BookingRequestStruct&); public: + /** Destructor. */ ~BookingRequestStruct(); @@ -120,7 +125,7 @@ DateTime_T _requestDateTime; /** Passenger type. */ - PassengerType_T _paxType; + PassengerType _paxType; /** Party size. */ NbOfSeats_T _partySize; Modified: trunk/stdair/stdair/bom/DemandStream.cpp =================================================================== --- trunk/stdair/stdair/bom/DemandStream.cpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/bom/DemandStream.cpp 2010-02-15 01:20:27 UTC (rev 133) @@ -47,19 +47,22 @@ // ////////////////////////////////////////////////////////////////////// void DemandStream::init() { // Generate the number of requests - const RealNumber_T lMu = - _demandDistribution.getMeanNumberOfRequests (); + const RealNumber_T lMu = _demandDistribution.getMeanNumberOfRequests (); const RealNumber_T lSigma = _demandDistribution.getStandardDeviationNumberOfRequests (); + const RealNumber_T lRealNumberOfRequestsToBeGenerated = _numberOfRequestsRandomGenerator.generateNormal (lMu, lSigma); - Count_T lIntegerNumberOfRequestsToBeGenerated = 0; + + NbOfRequests_T lIntegerNumberOfRequestsToBeGenerated = 0; if (lRealNumberOfRequestsToBeGenerated < 0.5) { lIntegerNumberOfRequestsToBeGenerated = 0; + } else { - lIntegerNumberOfRequestsToBeGenerated = - static_cast<Count_T> (lRealNumberOfRequestsToBeGenerated + 0.5); + lIntegerNumberOfRequestsToBeGenerated = + static_cast<NbOfRequests_T> (lRealNumberOfRequestsToBeGenerated + 0.5); } + _totalNumberOfRequestsToBeGenerated = lIntegerNumberOfRequestsToBeGenerated; } Modified: trunk/stdair/stdair/bom/DemandStream.hpp =================================================================== --- trunk/stdair/stdair/bom/DemandStream.hpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/bom/DemandStream.hpp 2010-02-15 01:20:27 UTC (rev 133) @@ -16,6 +16,7 @@ #include <stdair/basic/RandomGenerationContext.hpp> #include <stdair/bom/BomContent.hpp> #include <stdair/bom/BookingRequestTypes.hpp> +#include <stdair/bom/DemandStreamKey.hpp> #include <stdair/bom/DemandStreamTypes.hpp> namespace stdair { @@ -32,7 +33,7 @@ } /** Get the total number of requests to be generated. */ - const Count_T& getTotalNumberOfRequestsToBeGenerated() const { + const NbOfRequests_T& getTotalNumberOfRequestsToBeGenerated() const { return _totalNumberOfRequestsToBeGenerated; } @@ -52,22 +53,22 @@ } /** Get the passenger type. */ - const PassengerType_T& getPaxType() const { + const PassengerType& getPaxType() const { return _demandCharacteristics.getPaxType(); } /** Get the arrival pattern. */ - const ContinuousAttribute<FloatDuration_T>& getArrivalPattern() const { + const ContinuousFloatDuration_T& getArrivalPattern() const { return _demandCharacteristics.getArrivalPattern(); } /** Get the mean number of requests. */ - const RealNumber_T& getMeanNumberOfRequests() const { + const NbOfRequests_T& getMeanNumberOfRequests() const { return _demandDistribution.getMeanNumberOfRequests(); } /** Get the standard deviation of number of requests. */ - const RealNumber_T& getStandardDeviationNumberOfRequests() const { + const StandardDeviationValue_T& getStandardDeviationNumberOfRequests() const { return _demandDistribution.getStandardDeviationNumberOfRequests(); } @@ -185,10 +186,11 @@ protected: // ////////// Constructors and destructors ///////// /** Constructor by default */ - DemandStream (const DemandStreamKey_T&, - const DemandCharacteristics&, - const DemandDistribution&, const RandomSeed_T&, - const RandomSeed_T&, const RandomSeed_T&); + DemandStream (const DemandStreamKey_T&, const DemandCharacteristics&, + const DemandDistribution&, + const RandomSeed_T& iNumberOfRequestsSeed, + const RandomSeed_T& iRequestDateTimeSeed, + const RandomSeed_T& iDemandCharacteristicsSeed); /** Default constructors. */ DemandStream (); DemandStream (const DemandStream&); @@ -210,7 +212,7 @@ DemandDistribution _demandDistribution; /** Total number of requests to be generated*/ - Count_T _totalNumberOfRequestsToBeGenerated; + NbOfRequests_T _totalNumberOfRequestsToBeGenerated; /** Random generation context */ RandomGenerationContext _randomGenerationContext; Copied: trunk/stdair/stdair/bom/DemandStreamKey.cpp (from rev 129, trunk/stdair/stdair/bom/FlightDateKey.cpp) =================================================================== --- trunk/stdair/stdair/bom/DemandStreamKey.cpp (rev 0) +++ trunk/stdair/stdair/bom/DemandStreamKey.cpp 2010-02-15 01:20:27 UTC (rev 133) @@ -0,0 +1,58 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STDAIR +#include <stdair/bom/DemandStreamKey.hpp> + +namespace stdair { + + // //////////////////////////////////////////////////////////////////// + DemandStreamKey_T::DemandStreamKey_T () + : _paxType (PassengerType::LAST_VALUE) { + } + + // //////////////////////////////////////////////////////////////////// + DemandStreamKey_T::DemandStreamKey_T (const AirportCode_T& iOrigin, + const AirportCode_T& iDestination, + const Date_T& iPreferredDepartureDate, + const PassengerType& iPaxType) + : _origin (iOrigin), _destination (iDestination), + _preferredDepartureDate (iPreferredDepartureDate), _paxType (iPaxType) { + } + + // //////////////////////////////////////////////////////////////////// + DemandStreamKey_T::DemandStreamKey_T (const DemandStreamKey_T& iKey) + : _origin (iKey._origin), _destination (iKey._destination), + _preferredDepartureDate (iKey._preferredDepartureDate), + _paxType (iKey._paxType) { + } + + // //////////////////////////////////////////////////////////////////// + DemandStreamKey_T::~DemandStreamKey_T () { + } + + // //////////////////////////////////////////////////////////////////// + void DemandStreamKey_T::toStream (std::ostream& ioOut) const { + ioOut << "DemandStreamKey: " << toString() << std::endl; + } + + // //////////////////////////////////////////////////////////////////// + void DemandStreamKey_T::fromStream (std::istream& ioIn) { + } + + // //////////////////////////////////////////////////////////////////// + const std::string DemandStreamKey_T::toString() const { + std::ostringstream oStr; + oStr << _origin << "-" << _destination << " " << _preferredDepartureDate + << " " << _paxType; + return oStr.str(); + } + + // //////////////////////////////////////////////////////////////////// + const std::string DemandStreamKey_T::describe() const { + std::ostringstream oStr; + oStr << toString(); + return oStr.str(); + } + +} Copied: trunk/stdair/stdair/bom/DemandStreamKey.hpp (from rev 129, trunk/stdair/stdair/bom/FlightDateKey.hpp) =================================================================== --- trunk/stdair/stdair/bom/DemandStreamKey.hpp (rev 0) +++ trunk/stdair/stdair/bom/DemandStreamKey.hpp 2010-02-15 01:20:27 UTC (rev 133) @@ -0,0 +1,97 @@ +#ifndef __STDAIR_BOM_DEMANDSTREAMKEY_HPP +#define __STDAIR_BOM_DEMANDSTREAMKEY_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// StdAir +#include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/PassengerType.hpp> +#include <stdair/bom/BomKey.hpp> +#include <stdair/bom/BomRootKey.hpp> + +namespace stdair { + + /** Key of demand-stream. */ + struct DemandStreamKey_T : public BomKey_T { + public: + // /////////// Typedefs //////////// + /** Definition allowing to retrieve the parent key type. */ + typedef BomRootKey_T ParentKey_T; + + public: + // /////////// Construction /////////// + /** Constructors. */ + DemandStreamKey_T (const AirportCode_T& iOrigin, + const AirportCode_T& iDestination, + const Date_T& iPreferredDepartureDate, + const PassengerType& iPaxType); + DemandStreamKey_T (const DemandStreamKey_T&); + + /** Destructor. */ + ~DemandStreamKey_T (); + + public: + /** Default constructor */ + // TODO: that constructor should be private + DemandStreamKey_T (); + + + // /////////// Getters ////////// + /** Get the origin. */ + const AirportCode_T& getOrigin() const { + return _origin; + } + + /** Get the destination. */ + const AirportCode_T& getDestination() const { + return _destination; + } + + /** Get the preferred departure date. */ + const Date_T& getPreferredDepartureDate () const { + return _preferredDepartureDate; + } + + /** Get the passenger type. */ + const PassengerType& getPassengerType() const { + return _paxType; + } + + + // /////////// Display support methods ///////// + /** Dump a Business Object Key into an output stream. + @param ostream& the output stream. */ + void toStream (std::ostream& ioOut) const; + + /** Read a Business Object Key from an input stream. + @param istream& the input stream. */ + void fromStream (std::istream& ioIn); + + /** Get the serialised version of the Business Object Key. + <br>That string is unique, at the level of a given Business Object, + when among children of a given parent Business Object. + <br>For instance, "H" and "K" allow to differentiate among two + marketing classes for the same segment-stream. */ + const std::string toString() const; + + /** Display of the key. */ + const std::string describe() const; + + private: + // Attributes + /** Origin */ + AirportCode_T _origin; + + /** Origin */ + AirportCode_T _destination; + + /** Preferred departure date */ + Date_T _preferredDepartureDate; + + /** Passenger type. */ + PassengerType _paxType; + }; + +} +#endif // __STDAIR_BOM_DEMANDSTREAMKEY_HPP Modified: trunk/stdair/stdair/bom/DemandStreamTypes.hpp =================================================================== --- trunk/stdair/stdair/bom/DemandStreamTypes.hpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/bom/DemandStreamTypes.hpp 2010-02-15 01:20:27 UTC (rev 133) @@ -6,6 +6,8 @@ // ////////////////////////////////////////////////////////////////////// // STL #include <map> +// Boost +#include <boost/shared_ptr.hpp> // STDAIR #include <stdair/STDAIR_Types.hpp> @@ -13,9 +15,14 @@ // Forward declaration class DemandStream; + + /** Type definition for the hashed key of the DemandStreamKey object. */ + typedef std::string DemandStreamKeyStr_T; /** Define a map of demand strams. */ - typedef std::map<const DemandStreamKey_T, DemandStream*> DemandStreamList_T; + typedef std::map<const DemandStreamKeyStr_T, DemandStream*> DemandStreamList_T; + /** Type definition for a reference on a list of DemandStream objects. */ + typedef boost::shared_ptr<DemandStreamList_T> DemandStreamListPtr_T; } #endif // __STDAIR_BOM_DEMANDSTREAMTYPES_HPP Modified: trunk/stdair/stdair/bom/EventStruct.cpp =================================================================== --- trunk/stdair/stdair/bom/EventStruct.cpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/bom/EventStruct.cpp 2010-02-15 01:20:27 UTC (rev 133) @@ -13,8 +13,7 @@ EventStruct(const EventType_T& iEventType, const DateTime_T& iDateTime, const DemandStreamKey_T& iDemandStreamKey, BookingRequestPtr_T ioRequestPtr) - : _eventType (iEventType), - _eventDateTime (iDateTime), + : _eventType (iEventType), _eventDateTime (iDateTime), _demandStreamKey (iDemandStreamKey) { _request = ioRequestPtr; } @@ -30,9 +29,8 @@ // ////////////////////////////////////////////////////////////////////// EventStruct::EventStruct (const DateTime_T& iDateTime) - : _eventType (""), - _eventDateTime (iDateTime), - _demandStreamKey (-1) { + : _eventType (""), _eventDateTime (iDateTime), + _demandStreamKey ("", "", DEFAULT_DATE, PassengerType::LAST_VALUE) { } // ////////////////////////////////////////////////////////////////////// Modified: trunk/stdair/stdair/bom/EventStruct.hpp =================================================================== --- trunk/stdair/stdair/bom/EventStruct.hpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/bom/EventStruct.hpp 2010-02-15 01:20:27 UTC (rev 133) @@ -7,6 +7,7 @@ // STDAIR #include <stdair/STDAIR_Types.hpp> #include <stdair/bom/BookingRequestTypes.hpp> +#include <stdair/bom/DemandStreamKey.hpp> namespace stdair { Modified: trunk/stdair/stdair/bom/InventoryKey.hpp =================================================================== --- trunk/stdair/stdair/bom/InventoryKey.hpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/bom/InventoryKey.hpp 2010-02-15 01:20:27 UTC (rev 133) @@ -10,10 +10,10 @@ #include <stdair/bom/BomRootKey.hpp> namespace stdair { + /** Key of inventory. */ struct InventoryKey_T : public BomKey_T { friend struct FlightDateKey_T; - public: // /////////// Typedefs //////////// /** Definition allowing to retrieve the parent key type. */ Modified: trunk/stdair/stdair/bom/sources.mk =================================================================== --- trunk/stdair/stdair/bom/sources.mk 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/bom/sources.mk 2010-02-15 01:20:27 UTC (rev 133) @@ -17,6 +17,7 @@ $(top_srcdir)/stdair/bom/OutboundPathKey.hpp \ $(top_srcdir)/stdair/bom/AirlineFeatureSetKey.hpp \ $(top_srcdir)/stdair/bom/AirlineFeatureKey.hpp \ + $(top_srcdir)/stdair/bom/DemandStreamKey.hpp \ $(top_srcdir)/stdair/bom/BomRootTypes.hpp \ $(top_srcdir)/stdair/bom/BomRoot.hpp \ $(top_srcdir)/stdair/bom/BomContent.hpp \ @@ -107,6 +108,7 @@ $(top_srcdir)/stdair/bom/OutboundPathKey.cpp \ $(top_srcdir)/stdair/bom/AirlineFeatureSetKey.cpp \ $(top_srcdir)/stdair/bom/AirlineFeatureKey.cpp \ + $(top_srcdir)/stdair/bom/DemandStreamKey.cpp \ $(top_srcdir)/stdair/bom/BomRoot.cpp \ $(top_srcdir)/stdair/bom/BomRootContent.cpp \ $(top_srcdir)/stdair/bom/Inventory.cpp \ Modified: trunk/stdair/stdair/command/CmdBomManager.cpp =================================================================== --- trunk/stdair/stdair/command/CmdBomManager.cpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/command/CmdBomManager.cpp 2010-02-15 01:20:27 UTC (rev 133) @@ -3,10 +3,13 @@ // ////////////////////////////////////////////////////////////////////// // STL #include <cassert> +// Boost +#include <boost/make_shared.hpp> // StdAir #include <stdair/bom/BomRoot.hpp> #include <stdair/bom/AirlineFeatureSet.hpp> #include <stdair/bom/AirlineFeature.hpp> +#include <stdair/bom/DemandStreamTypes.hpp> // Inventory: child of BomRoot, needed for creation of BomRoot #include <stdair/bom/Inventory.hpp> // Network: child of BomRoot, needed for creation of BomRoot @@ -30,9 +33,8 @@ } // ////////////////////////////////////////////////////////////////////// - void CmdBomManager:: - addAirlineFeature (BomRoot& ioBomRoot, - const AirlineCode_T& iAirlineCode) { + void CmdBomManager::addAirlineFeature (BomRoot& ioBomRoot, + const AirlineCode_T& iAirlineCode) { // Initialise an AirlineFeature object AirlineFeatureKey_T lAirlineFeatureKey (iAirlineCode); @@ -48,6 +50,16 @@ } // ////////////////////////////////////////////////////////////////////// + void CmdBomManager::initDemandStreamList (BomRoot& ioBomRoot) { + // Initialise the set of required airline features + DemandStreamListPtr_T lDemandStreamList_ptr = + boost::make_shared<DemandStreamList_T>(); + + // Set the AirlineFeatureSet for the BomRoot. + ioBomRoot.setDemandStreamList (lDemandStreamList_ptr); + } + + // ////////////////////////////////////////////////////////////////////// Inventory& CmdBomManager:: createInventoryInternal (BomRoot& ioBomRoot, const AirlineCode_T& iAirlineCode) { Modified: trunk/stdair/stdair/command/CmdBomManager.hpp =================================================================== --- trunk/stdair/stdair/command/CmdBomManager.hpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/command/CmdBomManager.hpp 2010-02-15 01:20:27 UTC (rev 133) @@ -30,8 +30,7 @@ created . */ static Inventory& getOrCreateInventory (BomRoot&, const AirlineCode_T&); - /** Initialise the AirlineFeatureSet object, and attach it to the - BomRoot. + /** Initialise the AirlineFeatureSet object, and attach it to the BomRoot. @param BomRoot& Root of the BOM tree. */ static void initAirlineFeatureSet (BomRoot&); @@ -41,6 +40,11 @@ @param const AirlineCode_T& Airline code for the inventory to be created . */ static void addAirlineFeature (BomRoot&, const AirlineCode_T& iAirlineCode); + + /** Initialise the DemandStreamList object, and attach it to the BomRoot. + @param BomRoot& Root of the BOM tree. */ + static void initDemandStreamList (BomRoot&); + private: // ///////////////////// Internal support methods //////////////////////// Modified: trunk/stdair/stdair/factory/FacBomContent.hpp =================================================================== --- trunk/stdair/stdair/factory/FacBomContent.hpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/factory/FacBomContent.hpp 2010-02-15 01:20:27 UTC (rev 133) @@ -24,6 +24,7 @@ struct OptimizerStruct_T; struct DemandCharacteristics; struct DemandDistribution; + struct DemandStreamKey_T; /** Base class for Factory layer. */ class FacBomContent { Modified: trunk/stdair/stdair/service/STDAIR_Service.cpp =================================================================== --- trunk/stdair/stdair/service/STDAIR_Service.cpp 2010-02-14 16:21:47 UTC (rev 132) +++ trunk/stdair/stdair/service/STDAIR_Service.cpp 2010-02-15 01:20:27 UTC (rev 133) @@ -38,6 +38,8 @@ // Initialise the AirlineFeatureSet object, and attach it to the BomRoot initAirlineFeatureSet (); + // Initialise the DemandStreamList object, and attach it to the BomRoot + initDemandStreamList (); // Set the log file logInit (iLogParams); @@ -55,6 +57,8 @@ // Initialise the AirlineFeatureSet object, and attach it to the BomRoot initAirlineFeatureSet (); + // Initialise the DemandStreamList object, and attach it to the BomRoot + initDemandStreamList (); // Set the log file logInit (iLogParams); @@ -91,6 +95,12 @@ // Delegate to the dedicated command CmdBomManager::initAirlineFeatureSet (_bomRoot); } + + // ////////////////////////////////////////////////////////////////////// + void STDAIR_Service::initDemandStreamList () { + // Delegate to the dedicated command + CmdBomManager::initDemandStreamList (_bomRoot); + } // ////////////////////////////////////////////////////////////////////// void STDAIR_Service:: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-02-15 12:35:13
|
Revision: 135 http://stdair.svn.sourceforge.net/stdair/?rev=135&view=rev Author: denis_arnaud Date: 2010-02-15 12:35:06 +0000 (Mon, 15 Feb 2010) Log Message: ----------- [Dev] Suppressed the duplicated bom/StructAbstract (as there is already one in the basic layer). Modified Paths: -------------- trunk/stdair/stdair/basic/PassengerType.cpp trunk/stdair/stdair/basic/PassengerType.hpp trunk/stdair/stdair/bom/AirlineStruct.hpp trunk/stdair/stdair/bom/BookingRequestStruct.hpp trunk/stdair/stdair/bom/DoWStruct.hpp trunk/stdair/stdair/bom/EventQueue.hpp trunk/stdair/stdair/bom/TravelSolutionStruct.hpp trunk/stdair/stdair/bom/sources.mk trunk/stdair/stdair/command/DBManagerForAirlines.cpp Removed Paths: ------------- trunk/stdair/stdair/bom/StructAbstract.hpp Modified: trunk/stdair/stdair/basic/PassengerType.cpp =================================================================== --- trunk/stdair/stdair/basic/PassengerType.cpp 2010-02-15 01:22:24 UTC (rev 134) +++ trunk/stdair/stdair/basic/PassengerType.cpp 2010-02-15 12:35:06 UTC (rev 135) @@ -47,11 +47,18 @@ } // ////////////////////////////////////////////////////////////////////// - char PassengerType::getTypeLabel(const EN_PassengerType& iType) { + char PassengerType::getTypeLabel (const EN_PassengerType& iType) { return _typeLabels[iType]; } // ////////////////////////////////////////////////////////////////////// + std::string PassengerType::getTypeLabelAsString(const EN_PassengerType& iType){ + std::ostringstream oStr; + oStr << _typeLabels[iType]; + return oStr.str(); + } + + // ////////////////////////////////////////////////////////////////////// std::string PassengerType::describeLabels() { std::ostringstream ostr; for (unsigned short idx = 0; idx != LAST_VALUE; ++idx) { @@ -69,10 +76,22 @@ } // ////////////////////////////////////////////////////////////////////// + std::string PassengerType::getTypeAsString() const { + std::ostringstream oStr; + oStr << _typeLabels[_type]; + return oStr.str(); + } + + // ////////////////////////////////////////////////////////////////////// const std::string PassengerType::describe() const { std::ostringstream ostr; ostr << _labels[_type]; return ostr.str(); } + // ////////////////////////////////////////////////////////////////////// + bool PassengerType::operator== (const EN_PassengerType& iType) const { + return (_type == iType); + } + } Modified: trunk/stdair/stdair/basic/PassengerType.hpp =================================================================== --- trunk/stdair/stdair/basic/PassengerType.hpp 2010-02-15 01:22:24 UTC (rev 134) +++ trunk/stdair/stdair/basic/PassengerType.hpp 2010-02-15 12:35:06 UTC (rev 135) @@ -7,7 +7,7 @@ // STL #include <string> // StdAir -#include <stdair/bom/StructAbstract.hpp> +#include <stdair/basic/StructAbstract.hpp> namespace stdair { @@ -21,21 +21,30 @@ LAST_VALUE } EN_PassengerType; - /** Get the label as a string. */ + /** Get the label as a string (e.g., "Leisure" or "Business"). */ static const std::string& getLabel (const EN_PassengerType&); - /** Get the label as a single char. */ + /** Get the label as a single char (e.g., 'L' or 'B'). */ static char getTypeLabel (const EN_PassengerType&); + /** Get the label as a single char (e.g., 'L' or 'B'). */ + static std::string getTypeLabelAsString (const EN_PassengerType&); + /** List the labels. */ static std::string describeLabels(); /** Get the enumerated value. */ EN_PassengerType getType() const; - /** Give a description of the structure (for display purposes). */ + /** Get the enumerated value as a short string (e.g., 'L' or 'B'). */ + std::string getTypeAsString() const; + + /** Give a description of the structure (e.g., "Leisure" or "Business"). */ const std::string describe() const; + public: + /** Comparison operator. */ + bool operator== (const EN_PassengerType&) const; public: /** Constructor. */ Modified: trunk/stdair/stdair/bom/AirlineStruct.hpp =================================================================== --- trunk/stdair/stdair/bom/AirlineStruct.hpp 2010-02-15 01:22:24 UTC (rev 134) +++ trunk/stdair/stdair/bom/AirlineStruct.hpp 2010-02-15 12:35:06 UTC (rev 135) @@ -10,7 +10,7 @@ #include <vector> // StdAir #include <stdair/STDAIR_Types.hpp> -#include <stdair/bom/StructAbstract.hpp> +#include <stdair/basic/StructAbstract.hpp> namespace stdair { Modified: trunk/stdair/stdair/bom/BookingRequestStruct.hpp =================================================================== --- trunk/stdair/stdair/bom/BookingRequestStruct.hpp 2010-02-15 01:22:24 UTC (rev 134) +++ trunk/stdair/stdair/bom/BookingRequestStruct.hpp 2010-02-15 12:35:06 UTC (rev 135) @@ -9,8 +9,8 @@ #include <string> // StdAir #include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/StructAbstract.hpp> #include <stdair/basic/PassengerType.hpp> -#include <stdair/bom/StructAbstract.hpp> namespace stdair { Modified: trunk/stdair/stdair/bom/DoWStruct.hpp =================================================================== --- trunk/stdair/stdair/bom/DoWStruct.hpp 2010-02-15 01:22:24 UTC (rev 134) +++ trunk/stdair/stdair/bom/DoWStruct.hpp 2010-02-15 12:35:06 UTC (rev 135) @@ -8,7 +8,7 @@ #include <string> #include <vector> // STDAIR -#include <stdair/bom/StructAbstract.hpp> +#include <stdair/basic/StructAbstract.hpp> namespace stdair { Modified: trunk/stdair/stdair/bom/EventQueue.hpp =================================================================== --- trunk/stdair/stdair/bom/EventQueue.hpp 2010-02-15 01:22:24 UTC (rev 134) +++ trunk/stdair/stdair/bom/EventQueue.hpp 2010-02-15 12:35:06 UTC (rev 135) @@ -4,9 +4,11 @@ // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// -// STDAIR +// STL +#include <iosfwd> +// StdAir #include <stdair/STDAIR_Types.hpp> -#include <stdair/bom/StructAbstract.hpp> +#include <stdair/basic/StructAbstract.hpp> #include <stdair/bom/EventTypes.hpp> namespace stdair { Deleted: trunk/stdair/stdair/bom/StructAbstract.hpp =================================================================== --- trunk/stdair/stdair/bom/StructAbstract.hpp 2010-02-15 01:22:24 UTC (rev 134) +++ trunk/stdair/stdair/bom/StructAbstract.hpp 2010-02-15 12:35:06 UTC (rev 135) @@ -1,83 +0,0 @@ -#ifndef __STDAIR_BOM_STRUCTABSTRACT_HPP -#define __STDAIR_BOM_STRUCTABSTRACT_HPP - -// ////////////////////////////////////////////////////////////////////// -// Import section -// ////////////////////////////////////////////////////////////////////// -// STL -#include <iosfwd> - -namespace stdair { - - /** Base class for the Structures of the Business Object Model (BOM) - layer. */ - struct StructAbstract { - public: - - /** Destructor. */ - virtual ~StructAbstract() {} - - /** Dump a Business Object into an output stream. - @param ostream& the output stream. */ - void toStream (std::ostream& ioOut) const { - ioOut << describe(); - } - - /** Read a Business Object from an input stream. - @param istream& the input stream. */ - virtual void fromStream (std::istream& ioIn) {} - - /** Display of the structure. */ - virtual const std::string describe() const = 0; - - protected: - /** Protected Default Constructor to ensure this class is abtract. */ - StructAbstract() {} - }; -} - -/** - Piece of code given by Nicolai M. Josuttis, Section 13.12.1 "Implementing - Output Operators" (p653) of his book "The C++ Standard Library: A Tutorial - and Reference", published by Addison-Wesley. -*/ -template <class charT, class traits> -inline -std::basic_ostream<charT, traits>& -operator<< (std::basic_ostream<charT, traits>& ioOut, - const stdair::StructAbstract& iStruct) { - /** - string stream: - - with same format - - without special field width - */ - std::basic_ostringstream<charT,traits> ostr; - ostr.copyfmt (ioOut); - ostr.width (0); - - // Fill string stream - iStruct.toStream (ostr); - - // Print string stream - ioOut << ostr.str(); - - return ioOut; -} - -/** - Piece of code given by Nicolai M. Josuttis, Section 13.12.1 "Implementing - Output Operators" (pp655-657) of his book "The C++ Standard Library: - A Tutorial and Reference", published by Addison-Wesley. -*/ -template <class charT, class traits> -inline -std::basic_istream<charT, traits>& -operator>> (std::basic_istream<charT, traits>& ioIn, - stdair::StructAbstract& ioStruct) { - // Fill the Structure object with the input stream. - ioStruct.fromStream (ioIn); - return ioIn; - -} - -#endif // __STDAIR_BOM_STRUCTABSTRACT_HPP Modified: trunk/stdair/stdair/bom/TravelSolutionStruct.hpp =================================================================== --- trunk/stdair/stdair/bom/TravelSolutionStruct.hpp 2010-02-15 01:22:24 UTC (rev 134) +++ trunk/stdair/stdair/bom/TravelSolutionStruct.hpp 2010-02-15 12:35:06 UTC (rev 135) @@ -9,7 +9,7 @@ #include <string> #include <vector> // StdAir -#include <stdair/bom/StructAbstract.hpp> +#include <stdair/basic/StructAbstract.hpp> #include <stdair/bom/BookingClassTypes.hpp> namespace stdair { Modified: trunk/stdair/stdair/bom/sources.mk =================================================================== --- trunk/stdair/stdair/bom/sources.mk 2010-02-15 01:22:24 UTC (rev 134) +++ trunk/stdair/stdair/bom/sources.mk 2010-02-15 12:35:06 UTC (rev 135) @@ -1,5 +1,4 @@ bom_h_sources = \ - $(top_srcdir)/stdair/bom/StructAbstract.hpp \ $(top_srcdir)/stdair/bom/BomList.hpp \ $(top_srcdir)/stdair/bom/BomMap.hpp \ $(top_srcdir)/stdair/bom/BomKey.hpp \ Modified: trunk/stdair/stdair/command/DBManagerForAirlines.cpp =================================================================== --- trunk/stdair/stdair/command/DBManagerForAirlines.cpp 2010-02-15 01:22:24 UTC (rev 134) +++ trunk/stdair/stdair/command/DBManagerForAirlines.cpp 2010-02-15 12:35:06 UTC (rev 135) @@ -143,14 +143,14 @@ prepareSelectOnAirlineCodeStatement (ioSociSession, lSelectStatement, iAirlineCode, ioAirline); - const bool shouldDoReset = true; + // const bool shouldDoReset = true; bool hasStillData = iterateOnStatement (lSelectStatement, ioAirline); if (hasStillData == true) { oHasRetrievedAirline = true; } // Sanity check - const bool shouldNotDoReset = false; + // const bool shouldNotDoReset = false; hasStillData = iterateOnStatement (lSelectStatement, ioAirline); // Debug This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qua...@us...> - 2010-02-15 12:53:39
|
Revision: 136 http://stdair.svn.sourceforge.net/stdair/?rev=136&view=rev Author: quannaus Date: 2010-02-15 12:53:32 +0000 (Mon, 15 Feb 2010) Log Message: ----------- [dev] Some small changes. Modified Paths: -------------- trunk/stdair/stdair/STDAIR_Types.hpp trunk/stdair/stdair/basic/DemandCharacteristics.hpp trunk/stdair/stdair/bom/BomRoot.cpp trunk/stdair/stdair/bom/BomRoot.hpp trunk/stdair/stdair/bom/DemandStream.hpp trunk/stdair/stdair/bom/DemandStreamTypes.hpp trunk/stdair/stdair/bom/EventStruct.cpp trunk/stdair/stdair/bom/EventStruct.hpp trunk/stdair/stdair/command/CmdBomManager.cpp Modified: trunk/stdair/stdair/STDAIR_Types.hpp =================================================================== --- trunk/stdair/stdair/STDAIR_Types.hpp 2010-02-15 12:35:06 UTC (rev 135) +++ trunk/stdair/stdair/STDAIR_Types.hpp 2010-02-15 12:53:32 UTC (rev 136) @@ -447,5 +447,8 @@ /** Real number */ typedef double RealNumber_T; + + /** Type definition for the hashed key of the DemandStreamKey object. */ + typedef std::string DemandStreamKeyStr_T; } #endif // __STDAIR_STDAIR_TYPES_HPP Modified: trunk/stdair/stdair/basic/DemandCharacteristics.hpp =================================================================== --- trunk/stdair/stdair/basic/DemandCharacteristics.hpp 2010-02-15 12:35:06 UTC (rev 135) +++ trunk/stdair/stdair/basic/DemandCharacteristics.hpp 2010-02-15 12:53:32 UTC (rev 136) @@ -75,7 +75,7 @@ private: // //////////////////// Attributes ///////////////////// /** DemandStream Key */ - const DemandStreamKey_T& _key; + const DemandStreamKey_T _key; /** Arrival pattern (cumulative distribution of timing of arrival of requests (negative number of days between departure date Modified: trunk/stdair/stdair/bom/BomRoot.cpp =================================================================== --- trunk/stdair/stdair/bom/BomRoot.cpp 2010-02-15 12:35:06 UTC (rev 135) +++ trunk/stdair/stdair/bom/BomRoot.cpp 2010-02-15 12:53:32 UTC (rev 136) @@ -79,23 +79,13 @@ } // //////////////////////////////////////////////////////////////////// - DemandStreamList_T& BomRoot::getDemandStreamListRef() const { - // TODO: check that the Boost smart pointer is not NULL - STDAIR_LOG_ERROR ("!!!!TODO: check that the Boost smart pointer is not NULL!!!!"); - return *_demandStreamList; - } - - // //////////////////////////////////////////////////////////////////// void BomRoot::addDemandStream (const DemandStreamKeyStr_T& iKeyStr, DemandStream& ioDemandStream) { - // TODO: check that the Boost smart pointer is not NULL - STDAIR_LOG_ERROR ("!!!!TODO: check that the Boost smart pointer is not NULL!!!!"); - // Insert the reference on the given DemandStream object into the // dedicated list const bool hasInsertBeenSuccessfull = - _demandStreamList->insert (DemandStreamList_T:: - value_type (iKeyStr, &ioDemandStream)).second; + _demandStreamList.insert (DemandStreamList_T:: + value_type (iKeyStr, &ioDemandStream)).second; if (hasInsertBeenSuccessfull == false) { STDAIR_LOG_ERROR ("The DemandStream object with key: " << iKeyStr << " can not be inserted into the dedicated list"); Modified: trunk/stdair/stdair/bom/BomRoot.hpp =================================================================== --- trunk/stdair/stdair/bom/BomRoot.hpp 2010-02-15 12:35:06 UTC (rev 135) +++ trunk/stdair/stdair/bom/BomRoot.hpp 2010-02-15 12:53:32 UTC (rev 136) @@ -122,13 +122,10 @@ AirlineFeatureSet& getAirlineFeatureSet() const; /** Get the reference of the list of DemandStream objects. */ - DemandStreamListPtr_T getDemandStreamList() const { - return _demandStreamList; + DemandStreamList_T& getDemandStreamList() { + return _demandStreamList; } - /** Get the reference of the list of DemandStream objects. */ - DemandStreamList_T& getDemandStreamListRef() const; - /** Retrieve, if existing, the Inventory corresponding to the given airline code (Inventory key). <br>If not existing, return the NULL pointer. */ @@ -147,11 +144,6 @@ _airlineFeatureSet = ioAirlineFeatureSet_ptr; } - /** Set the reference to the DemandStreamList object. */ - void setDemandStreamList (DemandStreamListPtr_T ioDemandStreamList_ptr) { - _demandStreamList = ioDemandStreamList_ptr; - } - /** Add a demand stream object to the dedicated list. @param const DemandStreamKeyStr_T& (String) Key of the DemandStream object to be added. @@ -183,7 +175,7 @@ AirlineFeatureSet* _airlineFeatureSet; /** Set of all DemandStream objects. */ - DemandStreamListPtr_T _demandStreamList; + DemandStreamList_T _demandStreamList; }; } Modified: trunk/stdair/stdair/bom/DemandStream.hpp =================================================================== --- trunk/stdair/stdair/bom/DemandStream.hpp 2010-02-15 12:35:06 UTC (rev 135) +++ trunk/stdair/stdair/bom/DemandStream.hpp 2010-02-15 12:53:32 UTC (rev 136) @@ -18,6 +18,7 @@ #include <stdair/bom/BookingRequestTypes.hpp> #include <stdair/bom/DemandStreamKey.hpp> #include <stdair/bom/DemandStreamTypes.hpp> +#include <stdair/service/Logger.hpp> namespace stdair { Modified: trunk/stdair/stdair/bom/DemandStreamTypes.hpp =================================================================== --- trunk/stdair/stdair/bom/DemandStreamTypes.hpp 2010-02-15 12:35:06 UTC (rev 135) +++ trunk/stdair/stdair/bom/DemandStreamTypes.hpp 2010-02-15 12:53:32 UTC (rev 136) @@ -16,13 +16,9 @@ // Forward declaration class DemandStream; - /** Type definition for the hashed key of the DemandStreamKey object. */ - typedef std::string DemandStreamKeyStr_T; /** Define a map of demand strams. */ typedef std::map<const DemandStreamKeyStr_T, DemandStream*> DemandStreamList_T; - /** Type definition for a reference on a list of DemandStream objects. */ - typedef boost::shared_ptr<DemandStreamList_T> DemandStreamListPtr_T; } #endif // __STDAIR_BOM_DEMANDSTREAMTYPES_HPP Modified: trunk/stdair/stdair/bom/EventStruct.cpp =================================================================== --- trunk/stdair/stdair/bom/EventStruct.cpp 2010-02-15 12:35:06 UTC (rev 135) +++ trunk/stdair/stdair/bom/EventStruct.cpp 2010-02-15 12:53:32 UTC (rev 136) @@ -11,7 +11,7 @@ // ////////////////////////////////////////////////////////////////////// EventStruct:: EventStruct(const EventType_T& iEventType, const DateTime_T& iDateTime, - const DemandStreamKey_T& iDemandStreamKey, + const DemandStreamKeyStr_T& iDemandStreamKey, BookingRequestPtr_T ioRequestPtr) : _eventType (iEventType), _eventDateTime (iDateTime), _demandStreamKey (iDemandStreamKey) { @@ -30,7 +30,7 @@ // ////////////////////////////////////////////////////////////////////// EventStruct::EventStruct (const DateTime_T& iDateTime) : _eventType (""), _eventDateTime (iDateTime), - _demandStreamKey ("", "", DEFAULT_DATE, PassengerType::LAST_VALUE) { + _demandStreamKey ("") { } // ////////////////////////////////////////////////////////////////////// Modified: trunk/stdair/stdair/bom/EventStruct.hpp =================================================================== --- trunk/stdair/stdair/bom/EventStruct.hpp 2010-02-15 12:35:06 UTC (rev 135) +++ trunk/stdair/stdair/bom/EventStruct.hpp 2010-02-15 12:53:32 UTC (rev 136) @@ -33,7 +33,7 @@ } /** Get the demand stream of the event. */ - const DemandStreamKey_T& getDemandStreamKey () const { + const DemandStreamKeyStr_T& getDemandStreamKey () const { return _demandStreamKey; } @@ -45,7 +45,7 @@ // ////////// Constructors and destructors ///////// /** Constructor. */ EventStruct (const EventType_T&, const DateTime_T&, - const DemandStreamKey_T&, BookingRequestPtr_T); + const DemandStreamKeyStr_T&, BookingRequestPtr_T); EventStruct (const DateTime_T&); /** Copy constructor. */ @@ -69,7 +69,7 @@ DateTime_T _eventDateTime; /** The demand stream which generated this event. */ - DemandStreamKey_T _demandStreamKey; + DemandStreamKeyStr_T _demandStreamKey; /** Pointer to Request event */ BookingRequestPtr_T _request; Modified: trunk/stdair/stdair/command/CmdBomManager.cpp =================================================================== --- trunk/stdair/stdair/command/CmdBomManager.cpp 2010-02-15 12:35:06 UTC (rev 135) +++ trunk/stdair/stdair/command/CmdBomManager.cpp 2010-02-15 12:53:32 UTC (rev 136) @@ -51,12 +51,6 @@ // ////////////////////////////////////////////////////////////////////// void CmdBomManager::initDemandStreamList (BomRoot& ioBomRoot) { - // Initialise the set of required airline features - DemandStreamListPtr_T lDemandStreamList_ptr = - boost::make_shared<DemandStreamList_T>(); - - // Set the AirlineFeatureSet for the BomRoot. - ioBomRoot.setDemandStreamList (lDemandStreamList_ptr); } // ////////////////////////////////////////////////////////////////////// This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-02-15 15:22:22
|
Revision: 139 http://stdair.svn.sourceforge.net/stdair/?rev=139&view=rev Author: denis_arnaud Date: 2010-02-15 15:22:16 +0000 (Mon, 15 Feb 2010) Log Message: ----------- [Dev] The passenger type has become the preferred cabin. Modified Paths: -------------- trunk/stdair/stdair/basic/DemandCharacteristics.cpp trunk/stdair/stdair/basic/DemandCharacteristics.hpp trunk/stdair/stdair/bom/BookingRequestStruct.cpp trunk/stdair/stdair/bom/BookingRequestStruct.hpp trunk/stdair/stdair/bom/DemandStream.cpp trunk/stdair/stdair/bom/DemandStream.hpp trunk/stdair/stdair/bom/DemandStreamKey.cpp trunk/stdair/stdair/bom/DemandStreamKey.hpp Modified: trunk/stdair/stdair/basic/DemandCharacteristics.cpp =================================================================== --- trunk/stdair/stdair/basic/DemandCharacteristics.cpp 2010-02-15 15:20:23 UTC (rev 138) +++ trunk/stdair/stdair/basic/DemandCharacteristics.cpp 2010-02-15 15:22:16 UTC (rev 139) @@ -18,7 +18,7 @@ // ///////////////////////////////////////////////////// DemandCharacteristics::DemandCharacteristics () - : _key (DemandStreamKey_T("", "", DEFAULT_DATE, PassengerType::LAST_VALUE)) { + : _key (DemandStreamKey_T ("", "", DEFAULT_DATE, "")) { } // ///////////////////////////////////////////////////// @@ -48,8 +48,8 @@ } // ///////////////////////////////////////////////////// - const PassengerType& DemandCharacteristics::getPaxType() const { - return _key.getPassengerType(); + const CabinCode_T& DemandCharacteristics::getPreferredCabin() const { + return _key.getPreferredCabin(); } // ///////////////////////////////////////////////////// @@ -65,7 +65,7 @@ << std::endl; oStr << "Preferred departure date ......... : " << _key.getPreferredDepartureDate() << std::endl; - oStr << "Passenger type ................... : " << _key.getPassengerType() + oStr << "Preferred cabin .................. : " << _key.getPreferredCabin() << std::endl; oStr << "Arrival pattern (days from departure, proportion): "; Modified: trunk/stdair/stdair/basic/DemandCharacteristics.hpp =================================================================== --- trunk/stdair/stdair/basic/DemandCharacteristics.hpp 2010-02-15 15:20:23 UTC (rev 138) +++ trunk/stdair/stdair/basic/DemandCharacteristics.hpp 2010-02-15 15:22:16 UTC (rev 139) @@ -32,8 +32,8 @@ /** Get the preferred departure date. */ const Date_T& getPreferredDepartureDate() const; - /** Get the passenger type. */ - const PassengerType& getPaxType() const; + /** Get the preferred cabin. */ + const CabinCode_T& getPreferredCabin() const; /** Get the arrival pattern. */ const ContinuousFloatDuration_T& getArrivalPattern() const { Modified: trunk/stdair/stdair/bom/BookingRequestStruct.cpp =================================================================== --- trunk/stdair/stdair/bom/BookingRequestStruct.cpp 2010-02-15 15:20:23 UTC (rev 138) +++ trunk/stdair/stdair/bom/BookingRequestStruct.cpp 2010-02-15 15:22:16 UTC (rev 139) @@ -16,12 +16,12 @@ const AirportCode_T& iDestination, const Date_T& iDepartureDate, const DateTime_T& iRequestDateTime, - const PassengerType& iPaxType, + const CabinCode_T& iPreferredCabin, const NbOfSeats_T& iPartySize) : _origin (iOrigin), _destination (iDestination), _preferredDepartureDate (iDepartureDate), _requestDateTime (iRequestDateTime), - _paxType (iPaxType), _partySize (iPartySize) { + _preferredCabin (iPreferredCabin), _partySize (iPartySize) { } // ////////////////////////////////////////////////////////////////////// @@ -41,7 +41,8 @@ const std::string BookingRequestStruct::describe() const { std::ostringstream oStr; oStr << _origin << " - " << _destination << " " << _preferredDepartureDate - << " " << _requestDateTime << " " << _paxType << " " << _partySize; + << " " << _requestDateTime << " " << _preferredCabin + << " " << _partySize; return oStr.str(); } Modified: trunk/stdair/stdair/bom/BookingRequestStruct.hpp =================================================================== --- trunk/stdair/stdair/bom/BookingRequestStruct.hpp 2010-02-15 15:20:23 UTC (rev 138) +++ trunk/stdair/stdair/bom/BookingRequestStruct.hpp 2010-02-15 15:22:16 UTC (rev 139) @@ -10,7 +10,6 @@ // StdAir #include <stdair/STDAIR_Types.hpp> #include <stdair/basic/StructAbstract.hpp> -#include <stdair/basic/PassengerType.hpp> namespace stdair { @@ -38,9 +37,9 @@ return _requestDateTime; } - /** Get the passenger type. */ - const PassengerType& getPaxType() const { - return _paxType; + /** Get the preferred cabin. */ + const CabinCode_T& getPreferredCabin() const { + return _preferredCabin; } /** Get the party size. */ @@ -70,9 +69,9 @@ _requestDateTime = iRequestDateTime; } - /** Set the passenger type. */ - void setPaxType (const PassengerType& iPaxType) { - _paxType = iPaxType; + /** Set the preferred cabin. */ + void setPreferredCabin (const CabinCode_T& iPreferredCabin) { + _preferredCabin = iPreferredCabin; } /** Set the party size. */ @@ -99,7 +98,7 @@ /** Constructor. */ BookingRequestStruct (const AirportCode_T&, const AirportCode_T&, const Date_T&, const DateTime_T&, - const PassengerType&, const NbOfSeats_T&); + const CabinCode_T&, const NbOfSeats_T&); public : /** Default constructor. */ BookingRequestStruct (); @@ -121,11 +120,11 @@ /** Departure date. */ Date_T _preferredDepartureDate; - /** Request datetime */ + /** Request date-time */ DateTime_T _requestDateTime; - /** Passenger type. */ - PassengerType _paxType; + /** Preferred cabin. */ + CabinCode_T _preferredCabin; /** Party size. */ NbOfSeats_T _partySize; Modified: trunk/stdair/stdair/bom/DemandStream.cpp =================================================================== --- trunk/stdair/stdair/bom/DemandStream.cpp 2010-02-15 15:20:23 UTC (rev 138) +++ trunk/stdair/stdair/bom/DemandStream.cpp 2010-02-15 15:22:16 UTC (rev 139) @@ -6,11 +6,10 @@ #include <iosfwd> #include <ostream> #include <sstream> +#include <cmath> // Boost #include <boost/math/distributions/normal.hpp> -// Math -#include <math.h> -// STDAIR +// StdAir #include <stdair/basic/BasConst_General.hpp> #include <stdair/basic/DemandCharacteristics.hpp> #include <stdair/basic/RandomGeneration.hpp> Modified: trunk/stdair/stdair/bom/DemandStream.hpp =================================================================== --- trunk/stdair/stdair/bom/DemandStream.hpp 2010-02-15 15:20:23 UTC (rev 138) +++ trunk/stdair/stdair/bom/DemandStream.hpp 2010-02-15 15:22:16 UTC (rev 139) @@ -53,9 +53,9 @@ return _demandCharacteristics.getPreferredDepartureDate(); } - /** Get the passenger type. */ - const PassengerType& getPaxType() const { - return _demandCharacteristics.getPaxType(); + /** Get the preferred cabin. */ + const CabinCode_T& getPreferredCabin() const { + return _demandCharacteristics.getPreferredCabin(); } /** Get the arrival pattern. */ Modified: trunk/stdair/stdair/bom/DemandStreamKey.cpp =================================================================== --- trunk/stdair/stdair/bom/DemandStreamKey.cpp 2010-02-15 15:20:23 UTC (rev 138) +++ trunk/stdair/stdair/bom/DemandStreamKey.cpp 2010-02-15 15:22:16 UTC (rev 139) @@ -7,24 +7,24 @@ namespace stdair { // //////////////////////////////////////////////////////////////////// - DemandStreamKey_T::DemandStreamKey_T () - : _paxType (PassengerType::LAST_VALUE) { + DemandStreamKey_T::DemandStreamKey_T () { } // //////////////////////////////////////////////////////////////////// DemandStreamKey_T::DemandStreamKey_T (const AirportCode_T& iOrigin, const AirportCode_T& iDestination, const Date_T& iPreferredDepartureDate, - const PassengerType& iPaxType) + const CabinCode_T& iPreferredCabin) : _origin (iOrigin), _destination (iDestination), - _preferredDepartureDate (iPreferredDepartureDate), _paxType (iPaxType) { + _preferredDepartureDate (iPreferredDepartureDate), + _preferredCabin (iPreferredCabin) { } // //////////////////////////////////////////////////////////////////// DemandStreamKey_T::DemandStreamKey_T (const DemandStreamKey_T& iKey) : _origin (iKey._origin), _destination (iKey._destination), _preferredDepartureDate (iKey._preferredDepartureDate), - _paxType (iKey._paxType) { + _preferredCabin (iKey._preferredCabin) { } // //////////////////////////////////////////////////////////////////// @@ -44,7 +44,7 @@ const std::string DemandStreamKey_T::toString() const { std::ostringstream oStr; oStr << _origin << "-" << _destination << " " << _preferredDepartureDate - << " " << _paxType; + << " " << _preferredCabin; return oStr.str(); } Modified: trunk/stdair/stdair/bom/DemandStreamKey.hpp =================================================================== --- trunk/stdair/stdair/bom/DemandStreamKey.hpp 2010-02-15 15:20:23 UTC (rev 138) +++ trunk/stdair/stdair/bom/DemandStreamKey.hpp 2010-02-15 15:22:16 UTC (rev 139) @@ -6,7 +6,6 @@ // ////////////////////////////////////////////////////////////////////// // StdAir #include <stdair/STDAIR_Types.hpp> -#include <stdair/basic/PassengerType.hpp> #include <stdair/bom/BomKey.hpp> #include <stdair/bom/BomRootKey.hpp> @@ -25,7 +24,7 @@ DemandStreamKey_T (const AirportCode_T& iOrigin, const AirportCode_T& iDestination, const Date_T& iPreferredDepartureDate, - const PassengerType& iPaxType); + const CabinCode_T& iPreferredCabin); DemandStreamKey_T (const DemandStreamKey_T&); /** Destructor. */ @@ -53,9 +52,9 @@ return _preferredDepartureDate; } - /** Get the passenger type. */ - const PassengerType& getPassengerType() const { - return _paxType; + /** Get the preferred cabin. */ + const CabinCode_T& getPreferredCabin() const { + return _preferredCabin; } @@ -89,8 +88,8 @@ /** Preferred departure date */ Date_T _preferredDepartureDate; - /** Passenger type. */ - PassengerType _paxType; + /** Preferred cabin. */ + CabinCode_T _preferredCabin; }; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qua...@us...> - 2010-02-15 15:48:17
|
Revision: 140 http://stdair.svn.sourceforge.net/stdair/?rev=140&view=rev Author: quannaus Date: 2010-02-15 15:48:08 +0000 (Mon, 15 Feb 2010) Log Message: ----------- [dev] Trasformed DemandStream into standart stdair BOM. Modified Paths: -------------- trunk/stdair/stdair/bom/AirlineFeature.hpp trunk/stdair/stdair/bom/AirlineFeatureContent.hpp trunk/stdair/stdair/bom/BomRoot.cpp trunk/stdair/stdair/bom/BomRoot.hpp trunk/stdair/stdair/bom/BomRootStructure.hpp trunk/stdair/stdair/bom/DemandStream.cpp trunk/stdair/stdair/bom/DemandStream.hpp trunk/stdair/stdair/bom/DemandStreamTypes.hpp trunk/stdair/stdair/bom/Inventory.cpp trunk/stdair/stdair/bom/sources.mk trunk/stdair/stdair/factory/FacBomContent.hpp trunk/stdair/stdair/factory/FacBomStructure.hpp Added Paths: ----------- trunk/stdair/stdair/bom/DemandStreamContent.cpp trunk/stdair/stdair/bom/DemandStreamContent.hpp trunk/stdair/stdair/bom/DemandStreamStructure.hpp Modified: trunk/stdair/stdair/bom/AirlineFeature.hpp =================================================================== --- trunk/stdair/stdair/bom/AirlineFeature.hpp 2010-02-15 15:22:16 UTC (rev 139) +++ trunk/stdair/stdair/bom/AirlineFeature.hpp 2010-02-15 15:48:08 UTC (rev 140) @@ -17,7 +17,6 @@ namespace stdair { // Forward declarations - class FacBomContent; struct AirlineFeatureKey_T; Modified: trunk/stdair/stdair/bom/AirlineFeatureContent.hpp =================================================================== --- trunk/stdair/stdair/bom/AirlineFeatureContent.hpp 2010-02-15 15:22:16 UTC (rev 139) +++ trunk/stdair/stdair/bom/AirlineFeatureContent.hpp 2010-02-15 15:48:08 UTC (rev 140) @@ -21,7 +21,7 @@ public: // /////////// Getters //////////// - /** Get the booking class key. */ + /** Get the airline feature key. */ const BomKey_T& getKey() const { return _key; } Modified: trunk/stdair/stdair/bom/BomRoot.cpp =================================================================== --- trunk/stdair/stdair/bom/BomRoot.cpp 2010-02-15 15:22:16 UTC (rev 139) +++ trunk/stdair/stdair/bom/BomRoot.cpp 2010-02-15 15:48:08 UTC (rev 140) @@ -43,7 +43,17 @@ NetworkMap_T BomRoot::getNetworkMap () const { return _bomRootStructure.getSecondChildrenHolder(); } + + // ////////////////////////////////////////////////////////////////////// + DemandStreamList_T BomRoot::getDemandStreamList () const { + return _bomRootStructure.getDemandStreamHolder(); + } + // ////////////////////////////////////////////////////////////////////// + DemandStreamMap_T BomRoot::getDemandStreamMap () const { + return _bomRootStructure.getDemandStreamHolder(); + } + // //////////////////////////////////////////////////////////////////// Inventory* BomRoot::getInventory (const AirlineCode_T& iAirlineCode) const { Inventory* oInventory_ptr = NULL; @@ -71,27 +81,25 @@ return oNetwork_ptr; } + + // //////////////////////////////////////////////////////////////////// + DemandStream& BomRoot:: + getDemandStream (const DemandStreamKeyStr_T& iKey) const { + DemandStreamMap_T lDemandStreamMap = getDemandStreamMap (); + + DemandStreamMap_T::iterator itDemandStream = lDemandStreamMap.find (iKey); + assert (itDemandStream != lDemandStreamMap.end()); + + DemandStream* oDemandStream_ptr = itDemandStream->second; + assert (oDemandStream_ptr != NULL); + + return *oDemandStream_ptr; + } // //////////////////////////////////////////////////////////////////// AirlineFeatureSet& BomRoot::getAirlineFeatureSet() const { assert (_airlineFeatureSet != NULL); return *_airlineFeatureSet; } - - // //////////////////////////////////////////////////////////////////// - void BomRoot::addDemandStream (const DemandStreamKeyStr_T& iKeyStr, - DemandStream& ioDemandStream) { - // Insert the reference on the given DemandStream object into the - // dedicated list - const bool hasInsertBeenSuccessfull = - _demandStreamList.insert (DemandStreamList_T:: - value_type (iKeyStr, &ioDemandStream)).second; - if (hasInsertBeenSuccessfull == false) { - STDAIR_LOG_ERROR ("The DemandStream object with key: " << iKeyStr - << " can not be inserted into the dedicated list"); - STDAIR_LOG_ERROR ("DemandStream object: " << ioDemandStream); - assert (false); - } - } } Modified: trunk/stdair/stdair/bom/BomRoot.hpp =================================================================== --- trunk/stdair/stdair/bom/BomRoot.hpp 2010-02-15 15:22:16 UTC (rev 139) +++ trunk/stdair/stdair/bom/BomRoot.hpp 2010-02-15 15:48:08 UTC (rev 140) @@ -18,6 +18,7 @@ // Forward declarations. class FacBomContent; class AirlineFeatureSet; + class DemandStream; struct BomRootKey_T; /** Class representing the actual functional/business content @@ -66,6 +67,9 @@ /** Definition allowing to retrieve the associated second BOM content child type. */ typedef Network SecondContentChild_T; + + /** Definition allowing to retrieve the specific DemandStream type. */ + typedef DemandStream DemandStreamContent_T; // ///////////////////////////////////////////////////////////////////////// @@ -117,15 +121,16 @@ /** Get a NetworkMap_T for iteration methods. */ NetworkMap_T getNetworkMap () const; + + /** Get a DemandStreamList_T for iteration methods. */ + DemandStreamList_T getDemandStreamList () const; + + /** Get a DemandStreamMap_T for iteration methods. */ + DemandStreamMap_T getDemandStreamMap () const; /** Get the reference of the AirlineFeatureSet object. */ AirlineFeatureSet& getAirlineFeatureSet() const; - /** Get the reference of the list of DemandStream objects. */ - DemandStreamList_T& getDemandStreamList() { - return _demandStreamList; - } - /** Retrieve, if existing, the Inventory corresponding to the given airline code (Inventory key). <br>If not existing, return the NULL pointer. */ @@ -136,6 +141,9 @@ <br>If not existing, return the NULL pointer. */ Network* getNetwork (const NetworkID_T&) const; + /** Retrieve the DemandStream which corresponds to the given key. */ + DemandStream& getDemandStream (const DemandStreamKeyStr_T&) const; + public: // //////////// Setters ////////////// @@ -174,8 +182,6 @@ /** Set of all AirlineFeatures. */ AirlineFeatureSet* _airlineFeatureSet; - /** Set of all DemandStream objects. */ - DemandStreamList_T _demandStreamList; }; } Modified: trunk/stdair/stdair/bom/BomRootStructure.hpp =================================================================== --- trunk/stdair/stdair/bom/BomRootStructure.hpp 2010-02-15 15:22:16 UTC (rev 139) +++ trunk/stdair/stdair/bom/BomRootStructure.hpp 2010-02-15 15:48:08 UTC (rev 140) @@ -54,7 +54,16 @@ /** Definition allowing to retrive the second children bom holder type. */ typedef BomChildrenHolderImp<SecondContentChild_T> SecondChildrenBomHolder_T; + /** Define the children demand stream type. */ + typedef typename BOM_CONTENT::DemandStreamContent_T DemandStream_T; + + /** Define the children demand stream holder type. */ + typedef BomChildrenHolderImp<DemandStream_T> DemandStreamHolder_T; + + /** Define the map of demand stream. */ + typedef BomMap_T<DemandStream_T> DemandStreamMap_T; + public: // /////////// Getters ///////////// /** Get the BomRootStructure key. */ @@ -85,6 +94,17 @@ ioChildrenHolder = _secondChildrenHolder; } + /** Get the holder of demand streams. */ + const DemandStreamHolder_T& getDemandStreamHolder() const { + assert (_demandStreamHolder); + return *_demandStreamHolder; + } + + /** Get the holder of demand streams. */ + void getDemandStreamHolder (DemandStreamHolder_T*& ioDemandStreamHolder) { + ioDemandStreamHolder = _demandStreamHolder; + } + private: /////////////// Setters //////////////// /** Default children holder setter. */ @@ -100,6 +120,11 @@ _secondChildrenHolder = &ioChildrenHolder; } + /** Set the demand stream holder. */ + void setDemandStreamHolder (DemandStreamHolder_T& ioDemandStreamHolder) { + _demandStreamHolder = &ioDemandStreamHolder; + } + public: // /////////// Display support methods ///////// /** Dump a Business Object into an output stream. @@ -128,7 +153,8 @@ layer. */ /** Default constructors. */ BomRootStructure () : _content (NULL), _childrenHolder (NULL), - _secondChildrenHolder (NULL) { }; + _secondChildrenHolder (NULL), + _demandStreamHolder (NULL) { }; BomRootStructure (const BomRootStructure&); /** Destructor. */ @@ -144,6 +170,9 @@ /** Holder of networks. */ SecondChildrenBomHolder_T* _secondChildrenHolder; + + /** Holder of demand streams. */ + DemandStreamHolder_T* _demandStreamHolder; }; } Modified: trunk/stdair/stdair/bom/DemandStream.cpp =================================================================== --- trunk/stdair/stdair/bom/DemandStream.cpp 2010-02-15 15:22:16 UTC (rev 139) +++ trunk/stdair/stdair/bom/DemandStream.cpp 2010-02-15 15:48:08 UTC (rev 140) @@ -28,41 +28,15 @@ const DemandDistribution& iDemandDistribution, const RandomSeed_T& iNumberOfRequestsSeed, const RandomSeed_T& iRequestDateTimeSeed, - const RandomSeed_T& iDemandCharacteristicsSeed) - : _key (iKey), - _demandCharacteristics (iDemandCharacteristics), - _demandDistribution (iDemandDistribution), - _totalNumberOfRequestsToBeGenerated (0), - _numberOfRequestsRandomGenerator (iNumberOfRequestsSeed), - _requestDateTimeRandomGenerator (iRequestDateTimeSeed), - _demandCharacteristicsRandomGenerator (iDemandCharacteristicsSeed) { - init(); + const RandomSeed_T& iDemandCharacteristicsSeed, + BomStructure_T& ioDemandStreamStructure) + : DemandStreamContent (iKey, iDemandCharacteristics, + iDemandDistribution, iNumberOfRequestsSeed, + iRequestDateTimeSeed, iDemandCharacteristicsSeed), + _demandStreamStructure (ioDemandStreamStructure) { } // ////////////////////////////////////////////////////////////////////// DemandStream::~DemandStream () { } - - // ////////////////////////////////////////////////////////////////////// - void DemandStream::init() { - // Generate the number of requests - const RealNumber_T lMu = _demandDistribution.getMeanNumberOfRequests (); - const RealNumber_T lSigma = - _demandDistribution.getStandardDeviationNumberOfRequests (); - - const RealNumber_T lRealNumberOfRequestsToBeGenerated = - _numberOfRequestsRandomGenerator.generateNormal (lMu, lSigma); - - NbOfRequests_T lIntegerNumberOfRequestsToBeGenerated = 0; - if (lRealNumberOfRequestsToBeGenerated < 0.5) { - lIntegerNumberOfRequestsToBeGenerated = 0; - - } else { - lIntegerNumberOfRequestsToBeGenerated = - static_cast<NbOfRequests_T> (lRealNumberOfRequestsToBeGenerated + 0.5); - } - - _totalNumberOfRequestsToBeGenerated = lIntegerNumberOfRequestsToBeGenerated; - } - } Modified: trunk/stdair/stdair/bom/DemandStream.hpp =================================================================== --- trunk/stdair/stdair/bom/DemandStream.hpp 2010-02-15 15:22:16 UTC (rev 139) +++ trunk/stdair/stdair/bom/DemandStream.hpp 2010-02-15 15:48:08 UTC (rev 140) @@ -10,110 +10,43 @@ #include <iosfwd> // STDAIR #include <stdair/STDAIR_Types.hpp> -#include <stdair/basic/DemandCharacteristics.hpp> -#include <stdair/basic/DemandDistribution.hpp> -#include <stdair/basic/RandomGeneration.hpp> -#include <stdair/basic/RandomGenerationContext.hpp> -#include <stdair/bom/BomContent.hpp> -#include <stdair/bom/BookingRequestTypes.hpp> -#include <stdair/bom/DemandStreamKey.hpp> +#include <stdair/bom/BomRoot.hpp> +#include <stdair/bom/DemandStreamStructure.hpp> +#include <stdair/bom/DemandStreamContent.hpp> +#include <stdair/bom/BomRootTypes.hpp> #include <stdair/bom/DemandStreamTypes.hpp> -#include <stdair/service/Logger.hpp> namespace stdair { + + // Forward declarations + struct DemandStreamKey_T; /** Class modeling a demand stream. */ - class DemandStream : public BomContent { + class DemandStream : public DemandStreamContent { friend class FacBomContent; public: - // ///////////// Getters /////////// - /** Get the key */ - const DemandStreamKey_T& getKey () const { - return _key; - } - - /** Get the total number of requests to be generated. */ - const NbOfRequests_T& getTotalNumberOfRequestsToBeGenerated() const { - return _totalNumberOfRequestsToBeGenerated; - } + // //////////// Type definitions ////////////// + /** Definition allowing to retrieve the associated parent + BOM content type. */ + typedef BomRoot Parent_T; - /** Get the origin. */ - const AirportCode_T& getOrigin() const { - return _demandCharacteristics.getOrigin(); - } - - /** Get the destination. */ - const AirportCode_T& getDestination() const { - return _demandCharacteristics.getDestination(); - } - - /** Get the preferred departure date. */ - const Date_T& getPreferredDepartureDate() const { - return _demandCharacteristics.getPreferredDepartureDate(); - } + /** Definition allowing to retrieve the associated BOM structure type. */ + typedef DemandStreamStructure_T BomStructure_T; - /** Get the preferred cabin. */ - const CabinCode_T& getPreferredCabin() const { - return _demandCharacteristics.getPreferredCabin(); - } - - /** Get the arrival pattern. */ - const ContinuousFloatDuration_T& getArrivalPattern() const { - return _demandCharacteristics.getArrivalPattern(); - } + /** Definition allowing to retrieve the associated BOM key type. */ + typedef DemandStreamKey_T BomKey_T; - /** Get the mean number of requests. */ - const NbOfRequests_T& getMeanNumberOfRequests() const { - return _demandDistribution.getMeanNumberOfRequests(); - } - - /** Get the standard deviation of number of requests. */ - const StandardDeviationValue_T& getStandardDeviationNumberOfRequests() const { - return _demandDistribution.getStandardDeviationNumberOfRequests(); - } - - /** Get the cumulative probability of arrival pattern for last - request generated so far. */ - const Probability_T& getCumulativeProbabilitySoFar () const { - return _randomGenerationContext.getCumulativeProbabilitySoFar(); - } - - /** Get the number of requests generated so far. */ - const Count_T getNumberOfRequestsGeneratedSoFar() const { - return _randomGenerationContext.getCumulativeProbabilitySoFar();; - } - - /** Get the seed of the random generator for the number of requests. */ - const RandomSeed_T& getNumberOfRequestsRandomGeneratorSeed () const { - return _numberOfRequestsRandomGenerator.getSeed(); - } + /** Definition allowing to retrieve the associated + BOM content child type. */ + typedef DemandStream ContentChild_T; - /** Get the seed of the random generator for the request datetime. */ - const RandomSeed_T& getRequestDateTimeRandomGeneratorSeed () const { - return _requestDateTimeRandomGenerator.getSeed(); + private: + /** Retrieve the BOM structure object. */ + BomStructure_T& getBomStructure () { + return _demandStreamStructure; } - - /** Get the seed of the random generator for the demand characteristics. */ - const RandomSeed_T& getDemandCharacteristicsRandomGeneratorSeed () const { - return _demandCharacteristicsRandomGenerator.getSeed(); - } - - public: - // //////////////// Setters ////////////////// - /** Set the cumulative probability of arrival pattern for last - request generated so far. */ - void setCumulativeProbabilitySoFar (const Probability_T& iCumulativeProbability) { - _randomGenerationContext. - setCumulativeProbabilitySoFar (iCumulativeProbability); - } - /** Set the number of requests generated so far. */ - void setNumberOfRequestsGeneratedSoFar (const Count_T& iNumberOfRequests) { - _randomGenerationContext. - setNumberOfRequestsGeneratedSoFar (iNumberOfRequests); - } - public: // /////////// Display support methods ///////// /** Dump a Business Object into an output stream. @@ -136,62 +69,15 @@ const std::string describeShortKey() const { return std::string (""); } - public: - // /////////////// Business Methods ////////// - /** Increment counter of requests generated so far */ - void incrementGeneratedRequestsCounter () { - _randomGenerationContext.incrementGeneratedRequestsCounter(); - } - - - /** Generate a randomized number following a uniform distribution - between 0 (included) and 1 (excluded). */ - RealNumber_T generateUniform01WithNumberOfRequestRandomGenerator () { - return _numberOfRequestsRandomGenerator.generateUniform01(); - } - RealNumber_T generateUniform01WithRequestDateTimeRandomGenerator() { - return _requestDateTimeRandomGenerator.generateUniform01(); - } - RealNumber_T generateUniform01WithDemandCharacteristicsRandomGenerator() { - return _demandCharacteristicsRandomGenerator.generateUniform01(); - } - - /** Generate a randomized number following a uniform distribution - between a minimum (included) and a maximum (excluded) - value. */ - RealNumber_T generateUniformWithNumberOfRequestRandomGenerator (const RealNumber_T& iMinValue, const RealNumber_T& iMaxValue) { - return _numberOfRequestsRandomGenerator.generateUniform (iMinValue, - iMaxValue); - } - RealNumber_T generateUniformWithRequestDateTimeRandomGenerator(const RealNumber_T& iMinValue, const RealNumber_T& iMaxValue) { - return _requestDateTimeRandomGenerator.generateUniform (iMinValue, - iMaxValue); - } - RealNumber_T generateUniformWithDemandCharacteristicsRandomGenerator(const RealNumber_T& iMinValue, const RealNumber_T& iMaxValue) { - return _demandCharacteristicsRandomGenerator.generateUniform (iMinValue, - iMaxValue); - } - - /** Generate a randomized number following a normal distribution - specified by a mean and a standard deviation. */ - RealNumber_T generateNormalWithNumberOfRequestRandomGenerator (const RealNumber_T& mu, const RealNumber_T& sigma) { - return _numberOfRequestsRandomGenerator.generateNormal (mu, sigma); - } - RealNumber_T generateNormalWithRequestDateTimeRandomGenerator(const RealNumber_T& mu, const RealNumber_T& sigma) { - return _requestDateTimeRandomGenerator.generateNormal (mu, sigma); - } - RealNumber_T generateNormalWithDemandCharacteristicsRandomGenerator(const RealNumber_T& mu, const RealNumber_T& sigma) { - return _demandCharacteristicsRandomGenerator.generateNormal (mu, sigma); - } - protected: // ////////// Constructors and destructors ///////// /** Constructor by default */ - DemandStream (const DemandStreamKey_T&, const DemandCharacteristics&, + DemandStream (const BomKey_T&, const DemandCharacteristics&, const DemandDistribution&, const RandomSeed_T& iNumberOfRequestsSeed, const RandomSeed_T& iRequestDateTimeSeed, - const RandomSeed_T& iDemandCharacteristicsSeed); + const RandomSeed_T& iDemandCharacteristicsSeed, + BomStructure_T&); /** Default constructors. */ DemandStream (); DemandStream (const DemandStream&); @@ -203,29 +89,8 @@ protected: // ////////// Attributes ////////// - /** Key */ - DemandStreamKey_T _key; - - /** Demand characteristics */ - DemandCharacteristics _demandCharacteristics; - - /** Demand distribution */ - DemandDistribution _demandDistribution; - - /** Total number of requests to be generated*/ - NbOfRequests_T _totalNumberOfRequestsToBeGenerated; - - /** Random generation context */ - RandomGenerationContext _randomGenerationContext; - - /** Random generator for number of requests */ - RandomGeneration _numberOfRequestsRandomGenerator; - - /** Random generator for request datetime */ - RandomGeneration _requestDateTimeRandomGenerator; - - /** Random generator for demand characteristics */ - RandomGeneration _demandCharacteristicsRandomGenerator; + /** Reference structure. */ + BomStructure_T& _demandStreamStructure; }; } Copied: trunk/stdair/stdair/bom/DemandStreamContent.cpp (from rev 136, trunk/stdair/stdair/bom/DemandStream.cpp) =================================================================== --- trunk/stdair/stdair/bom/DemandStreamContent.cpp (rev 0) +++ trunk/stdair/stdair/bom/DemandStreamContent.cpp 2010-02-15 15:48:08 UTC (rev 140) @@ -0,0 +1,65 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +#include <iosfwd> +#include <ostream> +#include <sstream> +// Boost +#include <boost/math/distributions/normal.hpp> +// Math +#include <math.h> +// STDAIR +#include <stdair/basic/BasConst_General.hpp> +#include <stdair/bom/DemandStreamContent.hpp> +#include <stdair/service/Logger.hpp> + + +namespace stdair { + + // ////////////////////////////////////////////////////////////////////// + DemandStreamContent:: + DemandStreamContent (const BomKey_T& iKey, + const DemandCharacteristics& iDemandCharacteristics, + const DemandDistribution& iDemandDistribution, + const RandomSeed_T& iNumberOfRequestsSeed, + const RandomSeed_T& iRequestDateTimeSeed, + const RandomSeed_T& iDemandCharacteristicsSeed) + : _key (iKey), + _demandCharacteristics (iDemandCharacteristics), + _demandDistribution (iDemandDistribution), + _totalNumberOfRequestsToBeGenerated (0), + _numberOfRequestsRandomGenerator (iNumberOfRequestsSeed), + _requestDateTimeRandomGenerator (iRequestDateTimeSeed), + _demandCharacteristicsRandomGenerator (iDemandCharacteristicsSeed) { + init(); + } + + // ////////////////////////////////////////////////////////////////////// + DemandStreamContent::~DemandStreamContent () { + } + + // ////////////////////////////////////////////////////////////////////// + void DemandStreamContent::init() { + // Generate the number of requests + const RealNumber_T lMu = _demandDistribution.getMeanNumberOfRequests (); + const RealNumber_T lSigma = + _demandDistribution.getStandardDeviationNumberOfRequests (); + + const RealNumber_T lRealNumberOfRequestsToBeGenerated = + _numberOfRequestsRandomGenerator.generateNormal (lMu, lSigma); + + NbOfRequests_T lIntegerNumberOfRequestsToBeGenerated = 0; + if (lRealNumberOfRequestsToBeGenerated < 0.5) { + lIntegerNumberOfRequestsToBeGenerated = 0; + + } else { + lIntegerNumberOfRequestsToBeGenerated = + static_cast<NbOfRequests_T> (lRealNumberOfRequestsToBeGenerated + 0.5); + } + + _totalNumberOfRequestsToBeGenerated = lIntegerNumberOfRequestsToBeGenerated; + } + +} Copied: trunk/stdair/stdair/bom/DemandStreamContent.hpp (from rev 136, trunk/stdair/stdair/bom/DemandStream.hpp) =================================================================== --- trunk/stdair/stdair/bom/DemandStreamContent.hpp (rev 0) +++ trunk/stdair/stdair/bom/DemandStreamContent.hpp 2010-02-15 15:48:08 UTC (rev 140) @@ -0,0 +1,232 @@ +#ifndef __STDAIR_BOM_DEMANDSTREAMCONTENT_HPP +#define __STDAIR_BOM_DEMANDSTREAMCONTENT_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// Boost +#include <boost/shared_ptr.hpp> +// STL +#include <iosfwd> +// STDAIR +#include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/DemandCharacteristics.hpp> +#include <stdair/basic/DemandDistribution.hpp> +#include <stdair/basic/RandomGeneration.hpp> +#include <stdair/basic/RandomGenerationContext.hpp> +#include <stdair/bom/BomContent.hpp> +#include <stdair/bom/DemandStreamKey.hpp> + +namespace stdair { + + /** Class modeling a demand stream. */ + class DemandStreamContent : public BomContent { + + public: + // Type definitions. + /** Definition allowing to retrieve the associated BOM key type. */ + typedef DemandStreamKey_T BomKey_T; + + public: + // ///////////// Getters /////////// + /** Get the key */ + const BomKey_T& getKey () const { + return _key; + } + + /** Get the total number of requests to be generated. */ + const NbOfRequests_T& getTotalNumberOfRequestsToBeGenerated() const { + return _totalNumberOfRequestsToBeGenerated; + } + + /** Get the origin. */ + const AirportCode_T& getOrigin() const { + return _demandCharacteristics.getOrigin(); + } + + /** Get the destination. */ + const AirportCode_T& getDestination() const { + return _demandCharacteristics.getDestination(); + } + + /** Get the preferred departure date. */ + const Date_T& getPreferredDepartureDate() const { + return _demandCharacteristics.getPreferredDepartureDate(); + } + + /** Get the preferred cabin. */ + const CabinCode_T& getPreferredCabin() const { + return _demandCharacteristics.getPreferredCabin(); + } + + /** Get the arrival pattern. */ + const ContinuousFloatDuration_T& getArrivalPattern() const { + return _demandCharacteristics.getArrivalPattern(); + } + + /** Get the mean number of requests. */ + const NbOfRequests_T& getMeanNumberOfRequests() const { + return _demandDistribution.getMeanNumberOfRequests(); + } + + /** Get the standard deviation of number of requests. */ + const StandardDeviationValue_T& getStandardDeviationNumberOfRequests() const { + return _demandDistribution.getStandardDeviationNumberOfRequests(); + } + + /** Get the cumulative probability of arrival pattern for last + request generated so far. */ + const Probability_T& getCumulativeProbabilitySoFar () const { + return _randomGenerationContext.getCumulativeProbabilitySoFar(); + } + + /** Get the number of requests generated so far. */ + const Count_T getNumberOfRequestsGeneratedSoFar() const { + return _randomGenerationContext.getCumulativeProbabilitySoFar();; + } + + /** Get the seed of the random generator for the number of requests. */ + const RandomSeed_T& getNumberOfRequestsRandomGeneratorSeed () const { + return _numberOfRequestsRandomGenerator.getSeed(); + } + + /** Get the seed of the random generator for the request datetime. */ + const RandomSeed_T& getRequestDateTimeRandomGeneratorSeed () const { + return _requestDateTimeRandomGenerator.getSeed(); + } + + /** Get the seed of the random generator for the demand characteristics. */ + const RandomSeed_T& getDemandCharacteristicsRandomGeneratorSeed () const { + return _demandCharacteristicsRandomGenerator.getSeed(); + } + + public: + // //////////////// Setters ////////////////// + /** Set the cumulative probability of arrival pattern for last + request generated so far. */ + void setCumulativeProbabilitySoFar (const Probability_T& iCumulativeProbability) { + _randomGenerationContext. + setCumulativeProbabilitySoFar (iCumulativeProbability); + } + + /** Set the number of requests generated so far. */ + void setNumberOfRequestsGeneratedSoFar (const Count_T& iNumberOfRequests) { + _randomGenerationContext. + setNumberOfRequestsGeneratedSoFar (iNumberOfRequests); + } + + public: + // /////////// Display support methods ///////// + /** Dump a Business Object into an output stream. + @param ostream& the output stream. */ + virtual void toStream (std::ostream& ioOut) const = 0; + + /** Read a Business Object from an input stream. + @param istream& the input stream. */ + virtual void fromStream (std::istream& ioIn) = 0; + + /** Get the serialised version of the Business Object. */ + virtual std::string toString() const = 0; + + /** Get a string describing the whole key (differentiating two objects + at any level). */ + virtual const std::string describeKey() const = 0; + + /** Get a string describing the short key (differentiating two objects + at the same level). */ + virtual const std::string describeShortKey() const = 0; + + public: + // /////////////// Business Methods ////////// + /** Increment counter of requests generated so far */ + void incrementGeneratedRequestsCounter () { + _randomGenerationContext.incrementGeneratedRequestsCounter(); + } + + + /** Generate a randomized number following a uniform distribution + between 0 (included) and 1 (excluded). */ + RealNumber_T generateUniform01WithNumberOfRequestRandomGenerator () { + return _numberOfRequestsRandomGenerator.generateUniform01(); + } + RealNumber_T generateUniform01WithRequestDateTimeRandomGenerator() { + return _requestDateTimeRandomGenerator.generateUniform01(); + } + RealNumber_T generateUniform01WithDemandCharacteristicsRandomGenerator() { + return _demandCharacteristicsRandomGenerator.generateUniform01(); + } + + /** Generate a randomized number following a uniform distribution + between a minimum (included) and a maximum (excluded) + value. */ + RealNumber_T generateUniformWithNumberOfRequestRandomGenerator (const RealNumber_T& iMinValue, const RealNumber_T& iMaxValue) { + return _numberOfRequestsRandomGenerator.generateUniform (iMinValue, + iMaxValue); + } + RealNumber_T generateUniformWithRequestDateTimeRandomGenerator(const RealNumber_T& iMinValue, const RealNumber_T& iMaxValue) { + return _requestDateTimeRandomGenerator.generateUniform (iMinValue, + iMaxValue); + } + RealNumber_T generateUniformWithDemandCharacteristicsRandomGenerator(const RealNumber_T& iMinValue, const RealNumber_T& iMaxValue) { + return _demandCharacteristicsRandomGenerator.generateUniform (iMinValue, + iMaxValue); + } + + /** Generate a randomized number following a normal distribution + specified by a mean and a standard deviation. */ + RealNumber_T generateNormalWithNumberOfRequestRandomGenerator (const RealNumber_T& mu, const RealNumber_T& sigma) { + return _numberOfRequestsRandomGenerator.generateNormal (mu, sigma); + } + RealNumber_T generateNormalWithRequestDateTimeRandomGenerator(const RealNumber_T& mu, const RealNumber_T& sigma) { + return _requestDateTimeRandomGenerator.generateNormal (mu, sigma); + } + RealNumber_T generateNormalWithDemandCharacteristicsRandomGenerator(const RealNumber_T& mu, const RealNumber_T& sigma) { + return _demandCharacteristicsRandomGenerator.generateNormal (mu, sigma); + } + + protected: + // ////////// Constructors and destructors ///////// + /** Constructor by default */ + DemandStreamContent (const BomKey_T&, const DemandCharacteristics&, + const DemandDistribution&, + const RandomSeed_T& iNumberOfRequestsSeed, + const RandomSeed_T& iRequestDateTimeSeed, + const RandomSeed_T& iDemandCharacteristicsSeed); + /** Default constructors. */ + DemandStreamContent (); + DemandStreamContent (const DemandStreamContent&); + /** Initialization. */ + void init(); + /** Destructor. */ + ~DemandStreamContent (); + + + protected: + // ////////// Attributes ////////// + /** Key */ + BomKey_T _key; + + /** Demand characteristics */ + DemandCharacteristics _demandCharacteristics; + + /** Demand distribution */ + DemandDistribution _demandDistribution; + + /** Total number of requests to be generated*/ + NbOfRequests_T _totalNumberOfRequestsToBeGenerated; + + /** Random generation context */ + RandomGenerationContext _randomGenerationContext; + + /** Random generator for number of requests */ + RandomGeneration _numberOfRequestsRandomGenerator; + + /** Random generator for request datetime */ + RandomGeneration _requestDateTimeRandomGenerator; + + /** Random generator for demand characteristics */ + RandomGeneration _demandCharacteristicsRandomGenerator; + }; + +} +#endif // __STDAIR_BOM_DEMANDSTREAMCONTENT_HPP Copied: trunk/stdair/stdair/bom/DemandStreamStructure.hpp (from rev 136, trunk/stdair/stdair/bom/AirlineFeatureStructure.hpp) =================================================================== --- trunk/stdair/stdair/bom/DemandStreamStructure.hpp (rev 0) +++ trunk/stdair/stdair/bom/DemandStreamStructure.hpp 2010-02-15 15:48:08 UTC (rev 140) @@ -0,0 +1,113 @@ +#ifndef __STDAIR_BOM_DEMANDSTREAMSTRUCTURE_HPP +#define __STDAIR_BOM_DEMANDSTREAMSTRUCTURE_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <iosfwd> +// MPL +#include <boost/mpl/vector.hpp> +// STDAIR +#include <stdair/bom/BomStopStructure.hpp> +#include <stdair/bom/BomStopContent.hpp> + +namespace stdair { + /** Wrapper class aimed at holding the actual content, modeled + by an external specific DemandStream class (for instance, + in the AIRSCHED library). */ + template <class BOM_CONTENT> + class DemandStreamStructure : public BomStructure { + friend class FacBomStructure; + friend class FacBomContent; + friend class BomStructure; + + public: + // Type definitions + /** Definition allowing to retrieve the associated BOM content type. */ + typedef BOM_CONTENT Content_T; + + /** Definition allowing to retrieve the associated BOM key type. */ + typedef typename BOM_CONTENT::BomKey_T BomKey_T; + + /** Definition allowing to retrieve the associated parent + BOM structure type. */ + typedef typename BOM_CONTENT::Parent_T::BomStructure_T ParentBomStructure_T; + + /** Definition allowing to retrieve the associated children type. */ + typedef boost::mpl::vector <BomStopStructure, + BomStopStructure> ChildrenBomTypeList_T; + + /** Definition allowing to retrieve the default children bom holder type. */ + typedef BomChildrenHolderImp<BomStopContent> DefaultChildrenBomHolder_T; + + public: + // /////////// Getters ///////////// + /** Get the (parent) BomRootStructure object. */ + ParentBomStructure_T* getBomRootStructurePtr() const { + return _parent; + } + + /** Get the (parent) BomRootStructure object. */ + ParentBomStructure_T& getBomRootStructure() const; + + /** Get the segment-cabin key. */ + const BomKey_T& getKey() const { + assert (_content != NULL); + return _content->getKey(); + } + + private: + // /////////// Setters ///////////// + /** Set the (parent) BomRootStructure object. */ + void setBomRootStructure (ParentBomStructure_T& ioBomRootStructure){ + _parent = &ioBomRootStructure; + } + + /** Default children holder setter. */ + void setChildrenHolder (DefaultChildrenBomHolder_T&) { } + + public: + // /////////// Display support methods ///////// + /** Dump a Business Object into an output stream. + @param ostream& the output stream. */ + void toStream (std::ostream& ioOut) const { + ioOut << toString() << std::endl; + } + + /** Read a Business Object from an input stream. + @param istream& the input stream. */ + void fromStream (std::istream& ioIn) { } + + /** Get the serialised version of the Business Object. */ + std::string toString() const { return describeKey(); } + + /** Get a string describing the whole key (differentiating two objects + at any level). */ + const std::string describeKey() const { return getKey().toString(); } + + /** Get a string describing the short key (differentiating two objects + at the same level). */ + const std::string describeShortKey() const { return getKey().toString(); } + + private: + /** Constructors are private so as to force the usage of the Factory + layer. */ + /** Default constructors. */ + DemandStreamStructure () : _parent (NULL), _content (NULL) { } + DemandStreamStructure (const DemandStreamStructure&); + + /** Destructor. */ + virtual ~DemandStreamStructure() { } + + private: + // Attributes + /** Parent segment-cabin. */ + ParentBomStructure_T* _parent; + + /** The actual functional (Business Object) content. */ + BOM_CONTENT* _content; + }; + +} +#endif // __STDAIR_BOM_DEMANDSTREAMSTRUCTURE_HPP Modified: trunk/stdair/stdair/bom/DemandStreamTypes.hpp =================================================================== --- trunk/stdair/stdair/bom/DemandStreamTypes.hpp 2010-02-15 15:22:16 UTC (rev 139) +++ trunk/stdair/stdair/bom/DemandStreamTypes.hpp 2010-02-15 15:48:08 UTC (rev 140) @@ -6,19 +6,30 @@ // ////////////////////////////////////////////////////////////////////// // STL #include <map> -// Boost -#include <boost/shared_ptr.hpp> -// STDAIR -#include <stdair/STDAIR_Types.hpp> +#include <vector> namespace stdair { - // Forward declaration + // Forward declarations. + template <typename BOM_CONTENT> class DemandStreamStructure; + template <typename BOM> struct BomList_T; + template <typename BOM> struct BomMap_T; class DemandStream; + + /** Define the airline feature structure. */ + typedef DemandStreamStructure<DemandStream> DemandStreamStructure_T; + + /** Define the airline feature structure list. */ + typedef std::vector<DemandStreamStructure_T*> DemandStreamStructureList_T; + /** Define the airline feature structure map. */ + typedef std::map<const std::string, DemandStreamStructure_T*> DemandStreamStructureMap_T; + + /** Define the airline feature list. */ + typedef BomList_T<DemandStream> DemandStreamList_T; + + /** Define the airline feature map. */ + typedef BomMap_T<DemandStream> DemandStreamMap_T; - /** Define a map of demand strams. */ - typedef std::map<const DemandStreamKeyStr_T, DemandStream*> DemandStreamList_T; - } #endif // __STDAIR_BOM_DEMANDSTREAMTYPES_HPP Modified: trunk/stdair/stdair/bom/Inventory.cpp =================================================================== --- trunk/stdair/stdair/bom/Inventory.cpp 2010-02-15 15:22:16 UTC (rev 139) +++ trunk/stdair/stdair/bom/Inventory.cpp 2010-02-15 15:48:08 UTC (rev 140) @@ -74,13 +74,5 @@ getFlightDate (const FlightDateKey_T& iKey) const { return _inventoryStructure.getContentChild (iKey); } - -// BookingClass* getBookingClass (const std::string&) const; - -// /** Clean the list of classes. */ -// void cleanClassList(); - -// FlightDate* -// getFlightDateInternal (const std::string& iFlightDateKey) const; } Modified: trunk/stdair/stdair/bom/sources.mk =================================================================== --- trunk/stdair/stdair/bom/sources.mk 2010-02-15 15:22:16 UTC (rev 139) +++ trunk/stdair/stdair/bom/sources.mk 2010-02-15 15:48:08 UTC (rev 140) @@ -86,6 +86,8 @@ $(top_srcdir)/stdair/bom/TravelSolutionTypes.hpp \ $(top_srcdir)/stdair/bom/BookingRequestStruct.hpp \ $(top_srcdir)/stdair/bom/AirlineStruct.hpp \ + $(top_srcdir)/stdair/bom/DemandStreamStructure.hpp \ + $(top_srcdir)/stdair/bom/DemandStreamContent.hpp \ $(top_srcdir)/stdair/bom/DemandStream.hpp \ $(top_srcdir)/stdair/bom/DemandStreamTypes.hpp \ $(top_srcdir)/stdair/bom/EventStruct.hpp \ @@ -141,6 +143,7 @@ $(top_srcdir)/stdair/bom/TravelSolutionStruct.cpp \ $(top_srcdir)/stdair/bom/BookingRequestStruct.cpp \ $(top_srcdir)/stdair/bom/AirlineStruct.cpp \ + $(top_srcdir)/stdair/bom/DemandStreamContent.cpp \ $(top_srcdir)/stdair/bom/DemandStream.cpp \ $(top_srcdir)/stdair/bom/EventStruct.cpp \ $(top_srcdir)/stdair/bom/EventQueue.cpp \ Modified: trunk/stdair/stdair/factory/FacBomContent.hpp =================================================================== --- trunk/stdair/stdair/factory/FacBomContent.hpp 2010-02-15 15:22:16 UTC (rev 139) +++ trunk/stdair/stdair/factory/FacBomContent.hpp 2010-02-15 15:48:08 UTC (rev 140) @@ -174,6 +174,29 @@ iReferenceOutboundPath._flightPathCode; } + /** Add a demand stream into the bom root. */ + template <typename DEMAND_STREAM> + static bool addDemandStream (typename DEMAND_STREAM::Parent_T& ioBomRoot, + DEMAND_STREAM& ioDemandStream) { + // Definition allowing to retrieve the corresponding BomRoot type. + typedef typename DEMAND_STREAM::Parent_T BOM_ROOT_T; + // Definition allowing to retrieve the corresponding BomRootStructure type. + typedef typename BOM_ROOT_T::BomStructure_T BOM_ROOT_STRUCTURE_T; + // Definition allowing to retrieve the corresponding + // DemandStreamStructure type. + typedef typename DEMAND_STREAM::BomStructure_T DEMAND_STREAM_STRUCTURE_T; + + // Retrieve the bom root structure and the demand stream structure. + BOM_ROOT_STRUCTURE_T& lBomRootStructure = ioBomRoot.getBomStructure(); + DEMAND_STREAM_STRUCTURE_T& lDemandStreamStructure = + ioDemandStream.getBomStructure(); + + // Forward the call to FacBomStructure. + return FacBomStructure:: + addDemandStream<DEMAND_STREAM_STRUCTURE_T> (lBomRootStructure, + lDemandStreamStructure); + } + // ////////////////////////////////////////////////////////////////// // /////////////////////// Dedicated factories ////////////////////// // ////////////////////////////////////////////////////////////////// @@ -184,14 +207,23 @@ const RandomSeed_T& iNumberOfRequestsSeed, const RandomSeed_T& iRequestDateTimeSeed, const RandomSeed_T& iDemandCharacteristicsSeed) { + // Create the structure/holder object + typedef typename DEMAND_STREAM::BomStructure_T DEMAND_STREAM_STRUCTURE_T; + DEMAND_STREAM_STRUCTURE_T& lBomStructure = + FacBomStructure::instance().create<DEMAND_STREAM_STRUCTURE_T> (); + DEMAND_STREAM* aDemandStream_ptr = new DEMAND_STREAM (iKey, iDemandCharacteristics, iDemandDistribution, iNumberOfRequestsSeed, iRequestDateTimeSeed, - iDemandCharacteristicsSeed); + iDemandCharacteristicsSeed, lBomStructure); assert (aDemandStream_ptr != NULL); // The new object is added to the pool of content objects _contentPool.push_back (aDemandStream_ptr); + + // Link the structure/holder object with its corresponding content object + setContent<DEMAND_STREAM_STRUCTURE_T, DEMAND_STREAM> (lBomStructure, + *aDemandStream_ptr); return *aDemandStream_ptr; } Modified: trunk/stdair/stdair/factory/FacBomStructure.hpp =================================================================== --- trunk/stdair/stdair/factory/FacBomStructure.hpp 2010-02-15 15:22:16 UTC (rev 139) +++ trunk/stdair/stdair/factory/FacBomStructure.hpp 2010-02-15 15:48:08 UTC (rev 140) @@ -603,6 +603,31 @@ } // ////////////////////////////////////////////////////////////////// + + // ////////////////////////////////////////////////////////////////// + /** Add a demand stream into the bom root. */ + template <typename DEMAND_STREAM_STRUCTURE> + static bool addDemandStream (typename DEMAND_STREAM_STRUCTURE::ParentBomStructure_T& ioBomRootStructure, DEMAND_STREAM_STRUCTURE& ioDemandStreamStructure) { + // Set the parent for the demand stream. + ioDemandStreamStructure._parent = &ioBomRootStructure; + + // Retrieve the DemandStream holder within the BomRoot, if this + // holder has not been created yet, then create it. + typedef typename DEMAND_STREAM_STRUCTURE::Content_T DEMAND_STREAM_T; + typedef BomChildrenHolderImp<DEMAND_STREAM_T> DEMAND_STREAM_HOLDER_T; + DEMAND_STREAM_HOLDER_T* lDemandStreamHolder = NULL; + ioBomRootStructure.getDemandStreamHolder (lDemandStreamHolder); + + if (lDemandStreamHolder == NULL) { + lDemandStreamHolder = + &FacBomStructure::instance().createBomHolder<DEMAND_STREAM_T> (); + ioBomRootStructure.setDemandStreamHolder (*lDemandStreamHolder); + } + + return addBomObjecdToBomHolder <DEMAND_STREAM_T> (*lDemandStreamHolder, + ioDemandStreamStructure); + } + 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. |
From: <qua...@us...> - 2010-02-16 16:49:16
|
Revision: 144 http://stdair.svn.sourceforge.net/stdair/?rev=144&view=rev Author: quannaus Date: 2010-02-16 16:49:09 +0000 (Tue, 16 Feb 2010) Log Message: ----------- [dev] Added some attributes into BookingRequest. Modified Paths: -------------- trunk/stdair/stdair/STDAIR_Types.hpp trunk/stdair/stdair/basic/BasConst.cpp trunk/stdair/stdair/basic/CategoricalAttribute.hpp trunk/stdair/stdair/basic/ContinuousAttribute.hpp trunk/stdair/stdair/basic/DemandCharacteristics.cpp trunk/stdair/stdair/basic/DemandCharacteristics.hpp trunk/stdair/stdair/basic/sources.mk trunk/stdair/stdair/bom/BookingRequestStruct.cpp trunk/stdair/stdair/bom/BookingRequestStruct.hpp trunk/stdair/stdair/bom/DemandStreamContent.hpp Added Paths: ----------- trunk/stdair/stdair/basic/BasConst_Request.hpp trunk/stdair/stdair/basic/DemandCharacteristicTypes.hpp Removed Paths: ------------- trunk/stdair/stdair/basic/ArrivalPattern.hpp Modified: trunk/stdair/stdair/STDAIR_Types.hpp =================================================================== --- trunk/stdair/stdair/STDAIR_Types.hpp 2010-02-15 19:48:39 UTC (rev 143) +++ trunk/stdair/stdair/STDAIR_Types.hpp 2010-02-16 16:49:09 UTC (rev 144) @@ -450,5 +450,16 @@ /** Type definition for the hashed key of the DemandStreamKey object. */ typedef std::string DemandStreamKeyStr_T; + + /** Type of booking channel (D=direct, I=indirect, N=oNline, F=oFfline). */ + typedef std::string ChannelLabel_T; + + /** Type of trip type (RO=outbound of round-trip, RI=inbound of round-trip, + OW=one way). */ + typedef std::string TripType_T; + + /** Type of frequent flyer (P=Platinum, G=Gold, S=Silver, M=Member, N=None). */ + typedef std::string FrequentFlyer_T; + } #endif // __STDAIR_STDAIR_TYPES_HPP Deleted: trunk/stdair/stdair/basic/ArrivalPattern.hpp =================================================================== --- trunk/stdair/stdair/basic/ArrivalPattern.hpp 2010-02-15 19:48:39 UTC (rev 143) +++ trunk/stdair/stdair/basic/ArrivalPattern.hpp 2010-02-16 16:49:09 UTC (rev 144) @@ -1,27 +0,0 @@ -#ifndef __STDAIR_BAS_ARRIVALPATTERN_HPP -#define __STDAIR_BAS_ARRIVALPATTERN_HPP - -// ////////////////////////////////////////////////////////////////////// -// Import section -// ////////////////////////////////////////////////////////////////////// -// StdAir -#include <stdair/STDAIR_Types.hpp> -#include <stdair/basic/ContinuousAttribute.hpp> - -namespace stdair { - - /** Type definition for the continuous distribition of the duration - (as a float number). */ - typedef ContinuousAttribute<FloatDuration_T> ContinuousFloatDuration_T; - - /** Type definition for the arrival pattern. */ - typedef ContinuousFloatDuration_T::ContinuousDistribution_T ArrivalPattern_T; - - /** Type definition for the arrival pattern cumulative distribution. */ - typedef std::multimap<FloatDuration_T, Probability_T> ArrivalPatternCumulativeDistribution_T; - - /** Type definition for the arrival pattern inverse cumulative distribution. */ - typedef std::multimap<Probability_T, FloatDuration_T> ArrivalPatternInverseCumulativeDistribution_T; - -} -#endif // __STDAIR_BAS_ARRIVALPATTERN_HPP Modified: trunk/stdair/stdair/basic/BasConst.cpp =================================================================== --- trunk/stdair/stdair/basic/BasConst.cpp 2010-02-15 19:48:39 UTC (rev 143) +++ trunk/stdair/stdair/basic/BasConst.cpp 2010-02-16 16:49:09 UTC (rev 144) @@ -6,6 +6,7 @@ // STDAIR #include <stdair/STDAIR_Types.hpp> #include <stdair/basic/BasConst_General.hpp> +#include <stdair/basic/BasConst_Request.hpp> #include <stdair/basic/BasConst_Inventory.hpp> #include <stdair/basic/BasConst_BookingClass.hpp> #include <stdair/basic/BasConst_Yield.hpp> @@ -24,92 +25,11 @@ /** Default number of generated flight dates . */ const NbOfFlightDates_T DEFAULT_NB_OF_FLIGHTDATES = 0.0; - - // // ///////// GSL ///////// - // /** Default (GSL) random generator type. */ - // const gsl_rng_type* DEFAULT_LATUS_RANDOM_GENERATOR_TYPE = gsl_rng_default; - - // /** Default seed value for Exponential distribution. */ - // const ExponentialSeed_T DEFAULT_EXPONENTIAL_SEED = 0; - - // /** Default seed value for Exponential distribution. */ - // const UniformSeed_T DEFAULT_UNIFORM_SEED = 0; - - // // ///////// Labels in General Configuration Files ///////// - // /** Default file path separator*/ - // const std::string DEFAULT_CONFIG_FILEPATH_SEPARATOR = "/"; - - // /** Default label for RDS. */ - // const std::string DEFAULT_CONFIG_RDS_LABEL = "rds"; - // /** Default label for RDS file path. */ - // const std::string DEFAULT_CONFIG_RDS_FILEPATH_LABEL = "rds_path"; - // /** Default label for RDS Id (= folder holding RDS). */ - // const std::string DEFAULT_CONFIG_RDS_ID_LABEL = "rds_id"; - // /** Default label for RDS manifest. */ - // const std::string DEFAULT_CONFIG_RDS_MANIFEST_LABEL = "rds_manifest"; - // /** Default label for RDS airline configuration file name. */ - // const std::string DEFAULT_CONFIG_RDS_AIRLINE_CONFIGURATION_LABEL = - // "airlineconfiguration"; - - // /** Default label for output files. */ - // const std::string DEFAULT_CONFIG_OUTPUT_FILE_LABEL = "output_files"; - // /** Default label for inventory output file name. */ - // const std::string DEFAULT_CONFIG_INVENTORY_OUTPUT_FILE_LABEL = - // "inventory_output"; - // /** Default label for simulation output file name. */ - // const std::string DEFAULT_CONFIG_SIMULATION_OUTPUT_FILE_LABEL = - // "simulation_output"; - - // // ///////// Lables in RDS XML file ///////// - // const std::string DEFAULT_CONFIG_RDS_DEMAND_ARRIVAL_FILENAME_LABEL = - // "demandpattern"; - // const std::string DEFAULT_CONFIG_RDS_CANCEL_FILENAME_LABEL = - // "cancelratecurve"; - // const std::string DEFAULT_CONFIG_RDS_CHARACTERISTIC_FILENAME_LABEL = - // "characteristics"; - // const std::string DEFAULT_CONFIG_RDS_DEMAND_FILENAME_LABEL = "demands"; - // const std::string DEFAULT_CONFIG_RDS_SCHEDULE_FILENAME_LABEL = "schedule"; - // const std::string DEFAULT_CONFIG_RDS_FARE_FILENAME_LABEL = "fares"; - // const std::string DEFAULT_CONFIG_RDS_YIELD_FILENAME_LABEL = "yields"; - // const std::string DEFAULT_CONFIG_RDS_AU_RULES_FILENAME_LABEL = "aurules"; - // const std::string DEFAULT_CONFIG_RDS_LFDTD_RULES_FILENAME_LABEL = "lfdtdrules"; - // const std::string DEFAULT_CONFIG_RDS_DCP_FILENAME_LABEL = - // "datacollectionpoints"; - - // // ///////// BOOST Date-Time ///////// - // // Time duration representing a full day - // // (i.e., 24h or 1,440 minutes or 86,400 seconds) - - // /** Time duration representing a full day (in boost::time_duration unit).*/ - // const Duration_T BOOST_TIME_DURATION_FOR_A_DAY = - // boost::posix_time::hours(24); - - // /** Time duration representing a full day (in seconds).*/ - // const int TIME_DURATION_FOR_A_DAY_IN_SECONDS = - // static_cast<const int> (BOOST_TIME_DURATION_FOR_A_DAY.total_seconds()); - - // /** Time duration representing a full hour (in seconds).*/ - // const int TIME_DURATION_FOR_AN_HOUR_IN_SECONDS = 3600; - - // /** Time duration representing a full minute (in seconds).*/ - // const int TIME_DURATION_FOR_A_MINUTE_IN_SECONDS = 60; - /** Null time duration (in boost::time_duration unit).*/ const Duration_T NULL_BOOST_TIME_DURATION = boost::posix_time::hours(0)+ boost::posix_time::minutes (0) + boost::posix_time::seconds (0); - // /** Date duration representing a full day (in boost::date_duration unit).*/ - // const DateOffSet_T BOOST_DATE_DURATION_FOR_A_DAY (1); - - // /** Date duration representing the window of time used for statistical - // analysis. */ - // const DateOffSet_T DEFAULT_ANALYSIS_TIME_WINDOW (180); - - // /** Date duration representing the period of reservation for a - // typical flight. */ - // const DateOffSet_T DEFAULT_RESERVATION_PERIOD_LENGTH (365); - // //////// (Flight-)Period-related BOM /////// /** Default number of duration days. */ @@ -144,6 +64,7 @@ /** Number of milliseconds in one second */ const Count_T MILLISECONDS_IN_ONE_SECOND = 1000; + // //////// Fare Rules /////// /** Default saturdayStay value (false). */ const SaturdayStay_T DEFAULT_SATURDAY_STAY = false; @@ -178,34 +99,7 @@ /** Default flightPathCode value (''). */ const FlightPathCode_T DEFAULT_FLIGHTPATH_CODE = ""; - // // //////// DemandFeatures /////// - // /** Default SaturdayStay average ratio of demand (value between [0, 100]). */ - // const SaturdayStayRatio_T DEFAULT_SATURDAY_STAY_RATIO = 50; - // /** Default Change fees average ratio (value between [0, 100]). */ - // const ChangeFeesRatio_T DEFAULT_CHANGE_FEES_RATIO = 50; - - // /** Default Non refundable average ratio (value between [0, 100]). */ - // const NonRefundableRatio_T DEFAULT_NON_REFUNDABLE_RATIO = 50; - - // /** Default passenger type (Leisure or Business). */ - // const PassengerType_T DEFAULT_PASSENGER_TYPE = "L"; - - // /** Default distribution pattern identifier. */ - // const DistributionPatternId_T DEFAULT_DISTRIBUTION_PATTERN_ID = ""; - - // /** Default cancellation rate curve identifier. */ - // const CancellationRateCurveId_T DEFAULT_CANCELLATION_RATE_CURVE_ID = ""; - - // /** Default airline preference identifier. */ - // const AirlinePreferenceId_T DEFAULT_AIRLINE_PREFERENCE_ID = ""; - - // /** Default percentage pair of cancellation and no-show. */ - // const CancellationNoShowRatePair_T DEFAULT_PERCENTAGE_PAIR (0.0, 0.0); - - // /** Default characteristics pattern identifier. */ - // const CharacteristicsPatternId_T DEFAULT_CHARACTERISTICS_PATTERN_ID = ""; - // //////// (Segment-)Class-related BOM /////// /** Default distance value (kilometers). */ const Distance_T DEFAULT_DISTANCE_VALUE = 0; @@ -286,6 +180,7 @@ /** Default load factor value (100%). */ const Percentage_T DEFAULT_LOAD_FACTOR_VALUE = 100.0; + // //////// (Leg-)YieldRange-related BOM /////// /** Default yield value. */ const Yield_T DEFAULT_YIELD_VALUE = 0.0; @@ -322,156 +217,25 @@ /** Default value of Fare. */ const Fare_T DEFAULT_OND_FARE_VALUE = 0.0; - // /** Default number of bookings. */ - // const NbOfBookings_T DEFAULT_OND_NB_OF_BOOKINGS = 0.0; + // //////// Booking Request ///////// + /** Default party size in a request. */ + const PartySize_T DEFAULT_PARTY_SIZE = 1; - // /** Default remaining future demand mean for OnD. */ - // const NbOfBookings_T DEFAULT_OND_REMAINING_DEMAND_MEAN = 0.0; - - // /** Default remaining futre demand standard deviation for OnD. */ - // const NbOfBookings_T DEFAULT_OND_REMAINING_DEMAND_STANDARD_DEVIATION = 0.0; - // //////// Travel Solutions /////// - /** Default Minimum connection time. */ - const Duration_T DEFAULT_MINIMUM_CONNECTION_TIME (0, 30, 0); + // //////// Travel Solutions /////// + /** Default Minimum connection time. */ + const Duration_T DEFAULT_MINIMUM_CONNECTION_TIME (0, 30, 0); - /** Default Matching Indicator value. */ - const MatchingIndicator_T DEFAULT_MATCHING_INDICATOR (0.0); + /** Default Matching Indicator value. */ + const MatchingIndicator_T DEFAULT_MATCHING_INDICATOR (0.0); - /** Default price value (0.0). */ - // const PriceValue_T DEFAULT_PRICE_VALUE (0.0); + /** Default currency (euro). */ + const PriceCurrency_T DEFAULT_CURRENCY ("EUR"); - /** Default currency (euro). */ - const PriceCurrency_T DEFAULT_CURRENCY ("EUR"); + /** Default availability status for a travel solution. */ + const AvailabilityStatus_T DEFAULT_AVAILABILITY_STATUS = false; - /** Default availability status for a travel solution. */ - const AvailabilityStatus_T DEFAULT_AVAILABILITY_STATUS = false; - // // //////// Cancellation /////// - // /** Default Fare value */ - // const Fare_T DEFAULT_FARE_VALUE = 0.0; - - // /** Default number of bookings. */ - // const NbOfBookings_T DEFAULT_NB_OF_BOOKINGS = 0; - - // /** Default date&time. */ - // const DateTime_T DEFAULT_CANCELLATION_DATETIME - // (DEFAULT_WORLD_SCHEDULE_UPDATE_DATE, - // NULL_BOOST_TIME_DURATION); - - // // //////// CityPair //////// - // /** Default booking date for BookingDay. */ - // const Date_T DEFAULT_BOOKING_DATE (2007, boost::gregorian::Jan, 1); - - // /** Default departure date for CityPairDate. */ - // const Date_T DEFAULT_DEPARTURE_DATE (2008, boost::gregorian::Jan, 1); - - // /** Date duration representing the time during which a flight-date is open - // to the reservation (in boost::date_duration unit).*/ - // const DateOffSet_T DEFAULT_FLIGHT_DATE_RESERVATION_DURATION (365); - - // /** Default number of seats required whenever a demand is processed into - // the simulator. */ - // const unsigned short DEFAULT_NUMBER_OF_REQUIRED_SEATS = 1; - - // // //////// Flight Period Actions //////// - // // //////// RMS mode /////// - // /** Default forecaster mode. */ - // const ForecasterMode_T DEFAULT_FORECAST_MODE = "NoForecast"; - - // /** First forecaster mode. */ - // const ForecasterMode_T FIRST_FORECAST_MODE = "Forecaster1"; - - // /** Basic forecaster mode. */ - // const ForecasterMode_T BASIC_FORECAST_MODE = "BasicForecaster"; - - // /** Neural forecaster mode. */ - // const ForecasterMode_T NEURAL_FORECAST_MODE = "NeuralForecaster"; - - // /** Q forecaster mode. */ - // const ForecasterMode_T Q_FORECAST_MODE = "QForecaster"; - - // /** Default optimizer mode. */ - // const OptimizerMode_T DEFAULT_OPTIMIZER_MODE = "FCFS"; - - // /** Optimizer mode for rules like LF & DTD threshold. */ - // const OptimizerMode_T LF_DTD_RULES_OPTIMIZER_MODE = "LFDTDRules"; - - // /** Optimizer mode for EMSR heuristic. */ - // const OptimizerMode_T EMSR_OPTIMIZER_MODE = "EMSR"; - - // /** Optimizer mode for EMSR-a heuristic. */ - // const OptimizerMode_T EMSRA_OPTIMIZER_MODE = "EMSRa"; - - // // /** Optimizer mode for EMSR-a with sell up probability. */ - // // const OptimizerMode_T EMSRA_SELLUP_OPTIMIZER_MODE = "EMSRaSellup"; - - // /** Optimizer mode for EMSR-b heuristic. */ - // const OptimizerMode_T EMSRB_OPTIMIZER_MODE = "EMSRb"; - - // /** Optimizer mode for Optimal Optimization by Monte-Carlo. */ - // const OptimizerMode_T MC_OPTIMIZER_MODE = "MC"; - - // /** Optimizer mode for Leg-Based Iterative DAVN Optimization with - // Monte-Carlo. */ - // const OptimizerMode_T LB_ITERATIVE_DAVN_OPTIMIZER_WITH_MC_MODE = "LB_DAVN_MC"; - - // /** Optimizer mode for Leg-Based Iterative DAVN Optimization with - // EMSR. */ - // const OptimizerMode_T LB_ITERATIVE_DAVN_OPTIMIZER_WITH_EMSR_MODE = "LB_DAVN_EMSR"; - - // // /** No sell-up for optimizer by default*/ - // // const SellupFlagForOptimizer_T DEFAULT_SELLUP_FLAG_FOR_OPTIMIZER = false; - - // /** Defaut control mode. */ - // const ControlMode_T DEFAULT_CONTROL_MODE = "STD"; - - // /** Theft control mode. */ - // const ControlMode_T THEFT_CONTROL_MODE = "THEFT"; - - // /** Default number of draws for Monte-Carlo Integration method. */ - // const int DEFAULT_NUMBER_OF_RANDOM_DRAWS = 1000; - - // /** Default epsilon for convergence test. */ - // const double DEFAULT_CONVERGENCE_EPSILON = 0.1; - - // /** Default max number of iterations for Iterative DAVN. */ - // const int DEFAULT_NB_OF_ITERATIONS_DAVN = 10; - - // // //////// Characteristics /////// - // /** Default k-factor (0.3).*/ - // const Multiplier_T DEFAULT_KFACTOR = 0.3; - - // /** Default basefare [used for computing WTP] (0).*/ - // const Fare_T DEFAULT_BASEFARE = 0; - - // /** Default elasticity multiplier [used for computing WTP] (1.5). */ - // const Multiplier_T DEFAULT_EMULTIPLIER = 1.5; - - // // //////// DICO mode /////// - // /** Default DICO studied airline. */ - // const AirlineCode_T DEFAULT_DICO_AIRLINE = "AD"; - // //const AirlineCode_T DEFAULT_DICO_STUDIED_AIRLINE = "AA"; - - // /** Default second studied airline for DICO. */ - // const AirlineCode_T DEFAULT_SECOND_DICO_AIRLINE = "AL"; - // //const AirlineCode_T DEFAULT_SECOND_DICO_STUDIED_AIRLINE = "BA"; - - // /** Default DICO studied date. */ - // const Date_T DEFAULT_DICO_STUDIED_DATE (2009, boost::gregorian::Jun, 29); - // //const Date_T DEFAULT_DICO_STUDIED_DATE (2009, boost::gregorian::Jun, 27); - - // /** Default DICO optimiser (dico mode). */ - // const DicoOptimizerMode_T DEFAULT_DICO_OPTIMIZER = "dico"; - - // /** Default DICO optimiser (robust dico mode). */ - // const DicoOptimizerMode_T DEFAULT_ROBUST_DICO_OPTIMIZER = - // "robustdico"; - - // /** Default DICO optimiser (fast robust dico mode). */ - // const DicoOptimizerMode_T DEFAULT_FAST_ROBUST_DICO_OPTIMIZER = - // "fastrobustdico"; - // //////// Inventory-related BOM /////// /** Default Bid-Price. */ const BidPrice_T DEFAULT_BID_PRICE = 0.0; Copied: trunk/stdair/stdair/basic/BasConst_Request.hpp (from rev 143, trunk/stdair/stdair/basic/BasConst_General.hpp) =================================================================== --- trunk/stdair/stdair/basic/BasConst_Request.hpp (rev 0) +++ trunk/stdair/stdair/basic/BasConst_Request.hpp 2010-02-16 16:49:09 UTC (rev 144) @@ -0,0 +1,16 @@ +#ifndef __STDAIR_BAS_BASCONST_REQUEST_HPP +#define __STDAIR_BAS_BASCONST_REQUEST_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// StdAir +#include <stdair/STDAIR_Types.hpp> + +namespace stdair { + + /** Default party size in a request. */ + extern const PartySize_T DEFAULT_PARTY_SIZE; + +} +#endif // __STDAIR_BAS_BASCONST_REQUEST_HPP Modified: trunk/stdair/stdair/basic/CategoricalAttribute.hpp =================================================================== --- trunk/stdair/stdair/basic/CategoricalAttribute.hpp 2010-02-15 19:48:39 UTC (rev 143) +++ trunk/stdair/stdair/basic/CategoricalAttribute.hpp 2010-02-16 16:49:09 UTC (rev 144) @@ -18,69 +18,101 @@ struct CategoricalAttribute { public: + /** Define the probability mass function type. */ + typedef std::map<T, Probability_T> ProbabilityMassFunction_T; + + /** Define the inverse cumulative distribution type. */ + typedef std::map<Probability_T, T> InverseCumulativeDistribution_T; + + public: // ///////////// Getters /////////// /** Get the probability mass function. */ const std::map<T,Probability_T>& getProbabilityMassFunction() const { - return _probability_mass_function; + return _probabilityMassFunction; } /** Get the inverse cumulative distribution. */ - const std::map<Probability_T, T>& getInverseCumulativeDistribution () const { - return _inverse_cumulative_distribution; + const InverseCumulativeDistribution_T& getInverseCumulativeDistribution () const { + return _inverseCumulativeDistribution; } // ///////////// Setters /////////// /** Set the probability mass function */ - void setProbabilityMassFunction (const std::map<T, Probability_T>& iProbabilityMassFunction) { - _probability_mass_function = iProbabilityMassFunction; + void setProbabilityMassFunction (const ProbabilityMassFunction_T& iProbabilityMassFunction) { + _probabilityMassFunction = iProbabilityMassFunction; determineInverseCumulativeDistributionFromProbabilityMassFunction(); } public: // /////////////// Business Methods ////////// /** Get value from inverse cumulative distribution. */ - T getValue(Probability_T iCumulativeProbability) { - return _inverse_cumulative_distribution.lower_bound(iCumulativeProbability)->second; + const T getValue (Probability_T iCumulativeProbability) const { + return _inverseCumulativeDistribution. + lower_bound (iCumulativeProbability)->second; } public: // ////////////// Display Support Methods ////////// - /** Display inverse cumulative distribution */ - void displayInverseCumulativeDistribution (std::ostream& ioStream) const { - for (typename std::map<Probability_T, T>::const_iterator it = _inverse_cumulative_distribution.begin(); - it != _inverse_cumulative_distribution.end(); ++it) { - ioStream << "cumulative prob: " << it->first + /** Display probability mass function. */ + const std::string displayProbabilityMassFunction () const { + std::ostringstream oStr; + unsigned int idx = 0; + + for (typename ProbabilityMassFunction_T::const_iterator it = + _probabilityMassFunction.begin(); + it != _probabilityMassFunction.end(); ++it, ++idx) { + if (idx != 0) { + oStr << ", "; + } + oStr << it->first << ":" << it->second; + } + + return oStr.str(); + } + + /** Display inverse cumulative distribution. */ + const std::string displayInverseCumulativeDistribution () const { + std::ostringstream oStr; + + for (typename InverseCumulativeDistribution_T::const_iterator it = + _inverseCumulativeDistribution.begin(); + it != _inverseCumulativeDistribution.end(); ++it) { + oStr << "cumulative prob: " << it->first << " value: " << it->second << std::endl; } + + return oStr.str(); } public: // ////////// Constructors and destructors ///////// /** Constructor by default */ - CategoricalAttribute (const std::map<T, Probability_T>& iProbabilityMassFunction) - : _probability_mass_function (iProbabilityMassFunction) { + CategoricalAttribute (const ProbabilityMassFunction_T& iProbabilityMassFunction) + : _probabilityMassFunction (iProbabilityMassFunction) { determineInverseCumulativeDistributionFromProbabilityMassFunction(); } + /** Default constructors. */ + CategoricalAttribute () { } + CategoricalAttribute (const CategoricalAttribute& iCategoricalAttribute) + : _probabilityMassFunction (iCategoricalAttribute._probabilityMassFunction) { + determineInverseCumulativeDistributionFromProbabilityMassFunction(); + } /** Destructor */ virtual ~CategoricalAttribute () { } - private: - /** Default constructors. */ - CategoricalAttribute (); - CategoricalAttribute (const CategoricalAttribute&); /** Determine inverse cumulative distribution from probability mass function (initialisation). */ void determineInverseCumulativeDistributionFromProbabilityMassFunction () { Probability_T cumulative_probability_so_far = 0.0; - for (typename std::map<T, Probability_T>::const_iterator itProbabilityMassFunction = _probability_mass_function.begin(); - itProbabilityMassFunction != _probability_mass_function.end(); + for (typename ProbabilityMassFunction_T::const_iterator itProbabilityMassFunction = _probabilityMassFunction.begin(); + itProbabilityMassFunction != _probabilityMassFunction.end(); ++itProbabilityMassFunction) { Probability_T attribute_probability_mass = itProbabilityMassFunction->second; if (attribute_probability_mass > 0) { T attribute_value = itProbabilityMassFunction->first; cumulative_probability_so_far += attribute_probability_mass; - _inverse_cumulative_distribution[cumulative_probability_so_far] = attribute_value; + _inverseCumulativeDistribution[cumulative_probability_so_far] = attribute_value; } } } @@ -88,10 +120,10 @@ private: // ////////// Attributes ////////// /** Probability mass function */ - std::map<T, Probability_T> _probability_mass_function; + ProbabilityMassFunction_T _probabilityMassFunction; /** Inverse cumulative distribution */ - std::map<Probability_T, T> _inverse_cumulative_distribution; + InverseCumulativeDistribution_T _inverseCumulativeDistribution; }; } Modified: trunk/stdair/stdair/basic/ContinuousAttribute.hpp =================================================================== --- trunk/stdair/stdair/basic/ContinuousAttribute.hpp 2010-02-15 19:48:39 UTC (rev 143) +++ trunk/stdair/stdair/basic/ContinuousAttribute.hpp 2010-02-16 16:49:09 UTC (rev 144) @@ -48,7 +48,7 @@ // /////////////// Business Methods ////////// /** Get value from inverse cumulative distribution. */ const T getValue (const Probability_T& iCumulativeProbability) const { - typename ContinuousDistribution_T::const_iterator it = + typename ContinuousInverseDistribution_T::const_iterator it = _inverseCumulativeDistribution.lower_bound (iCumulativeProbability); Probability_T cumulativeProbabilityNextPoint = it->first; @@ -63,15 +63,9 @@ Probability_T cumulativeProbabilityPreviousPoint = it->first; T valuePreviousPoint = it->second; if (cumulativeProbabilityNextPoint == cumulativeProbabilityPreviousPoint) { - //std::cout << "hlelo2" << std::endl; return valuePreviousPoint; } - //std::cout << "cumulativeProbabilityPreviousPoint: " << cumulativeProbabilityPreviousPoint << std::endl; - //std::cout << "cumulativeProbabilityNextPoint: " << cumulativeProbabilityNextPoint << std::endl; - //std::cout << "valuePreviousPoint: " << valuePreviousPoint << std::endl; - //std::cout << "valueNextPoint: " << valueNextPoint << std::endl; - return valuePreviousPoint + (valueNextPoint - valuePreviousPoint) * (iCumulativeProbability - cumulativeProbabilityPreviousPoint) / (cumulativeProbabilityNextPoint - cumulativeProbabilityPreviousPoint); @@ -80,7 +74,7 @@ public: // ////////////// Display Support Methods ////////// /** Display cumulative distribution */ - std::string displayCumulativeDistribution() const { + const std::string displayCumulativeDistribution() const { std::ostringstream oStr; unsigned int idx = 0; for (typename ContinuousDistribution_T::const_iterator it = @@ -95,7 +89,7 @@ } /** Display inverse cumulative distribution */ - std::string displayInverseCumulativeDistribution() const { + const std::string displayInverseCumulativeDistribution() const { std::ostringstream oStr; for (typename ContinuousInverseDistribution_T::const_iterator it = _inverseCumulativeDistribution.begin(); @@ -134,8 +128,9 @@ itCumulativeDistribution != _cumulativeDistribution.end(); ++itCumulativeDistribution) { _inverseCumulativeDistribution. - insert (std::pair<float, float> (itCumulativeDistribution->second, - itCumulativeDistribution->first)); + insert (typename ContinuousInverseDistribution_T:: + value_type (itCumulativeDistribution->second, + itCumulativeDistribution->first)); } } Copied: trunk/stdair/stdair/basic/DemandCharacteristicTypes.hpp (from rev 143, trunk/stdair/stdair/basic/ArrivalPattern.hpp) =================================================================== --- trunk/stdair/stdair/basic/DemandCharacteristicTypes.hpp (rev 0) +++ trunk/stdair/stdair/basic/DemandCharacteristicTypes.hpp 2010-02-16 16:49:09 UTC (rev 144) @@ -0,0 +1,82 @@ +#ifndef __STDAIR_BAS_DEMANDCHARACTERISTICTYPES_HPP +#define __STDAIR_BAS_DEMANDCHARACTERISTICTYPES_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// StdAir +#include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/ContinuousAttribute.hpp> +#include <stdair/basic/CategoricalAttribute.hpp> + +namespace stdair { + + /** Type definition for the continuous distribition of the duration + (as a float number). */ + typedef ContinuousAttribute<FloatDuration_T> ContinuousFloatDuration_T; + + /** Type definition for the arrival pattern. */ + typedef ContinuousFloatDuration_T::ContinuousDistribution_T ArrivalPattern_T; + + /** Type definition for the arrival pattern cumulative distribution. */ + typedef std::multimap<FloatDuration_T, Probability_T> ArrivalPatternCumulativeDistribution_T; + + /** Type definition for the arrival pattern inverse cumulative distribution. */ + typedef std::multimap<Probability_T, FloatDuration_T> ArrivalPatternInverseCumulativeDistribution_T; + + /** Define the booking channel probablity mass. */ + typedef CategoricalAttribute<ChannelLabel_T> ChannelProbabilityMass_T; + + /** Define the probability mass function type of booking channel. */ + typedef ChannelProbabilityMass_T::ProbabilityMassFunction_T ChannelProbabilityMassFunction_T; + + /** Define the inverse cumulative distribution of channel. */ + typedef ChannelProbabilityMass_T::InverseCumulativeDistribution_T ChannelInverserCumulativeDistribution_T; + + /** Define the trip type probablity mass. */ + typedef CategoricalAttribute<TripType_T> TripTypeProbabilityMass_T; + + /** Define the probability mass function type of trip type. */ + typedef TripTypeProbabilityMass_T::ProbabilityMassFunction_T TripTypeProbabilityMassFunction_T; + + /** Define the inverse cumulative distribution of trip type. */ + typedef TripTypeProbabilityMass_T::InverseCumulativeDistribution_T TripTypeInverserCumulativeDistribution_T; + + /** Define the stay duration probablity mass. */ + typedef CategoricalAttribute<DayDuration_T> StayDurationProbabilityMass_T; + + /** Define the probability mass function type of stay duration. */ + typedef StayDurationProbabilityMass_T::ProbabilityMassFunction_T StayDurationProbabilityMassFunction_T; + + /** Define the inverse cumulative distribution of stay duration. */ + typedef StayDurationProbabilityMass_T::InverseCumulativeDistribution_T StayDurationInverserCumulativeDistribution_T; + + /** Define the frequent flyer probablity mass. */ + typedef CategoricalAttribute<FrequentFlyer_T> FrequentFlyerProbabilityMass_T; + + /** Define the probability mass function type of frequent flyer. */ + typedef FrequentFlyerProbabilityMass_T::ProbabilityMassFunction_T FrequentFlyerProbabilityMassFunction_T; + + /** Define the inverse cumulative distribution of frequent flyer. */ + typedef FrequentFlyerProbabilityMass_T::InverseCumulativeDistribution_T FrequentFlyerInverserCumulativeDistribution_T; + + /** Define the preferred departure time cumulative distribution. */ + typedef ContinuousAttribute<IntDuration_T> PreferredDepartureTimeCumulativeDistribution_T; + + /** Define the preferred departure time continuous distribution. */ + typedef PreferredDepartureTimeCumulativeDistribution_T::ContinuousDistribution_T PreferredDepartureTimeContinuousDistribution_T; + + /** Define the preferred departure time continuous inverse distribution. */ + typedef PreferredDepartureTimeCumulativeDistribution_T::ContinuousInverseDistribution_T PreferredDepartureTimeContinuousInverseDistribution_T; + + /** Define the willingness-to-pay cumulative distribution. */ + typedef ContinuousAttribute<WTP_T> WTPCumulativeDistribution_T; + + /** Define the willingness-to-pay continuous distribution. */ + typedef WTPCumulativeDistribution_T::ContinuousDistribution_T WTPContinuousDistribution_T; + + /** Define the willingness-to-pay continuous inverse distribution. */ + typedef WTPCumulativeDistribution_T::ContinuousInverseDistribution_T WTPContinuousInverseDistribution_T; + +} +#endif // __STDAIR_BAS_DEMANDCHARACTERISTICTYPES_HPP Modified: trunk/stdair/stdair/basic/DemandCharacteristics.cpp =================================================================== --- trunk/stdair/stdair/basic/DemandCharacteristics.cpp 2010-02-15 19:48:39 UTC (rev 143) +++ trunk/stdair/stdair/basic/DemandCharacteristics.cpp 2010-02-16 16:49:09 UTC (rev 144) @@ -12,8 +12,22 @@ namespace stdair { // ///////////////////////////////////////////////////// - DemandCharacteristics::DemandCharacteristics (const DemandStreamKey_T& iKey) - : _key (iKey) { + DemandCharacteristics:: + DemandCharacteristics (const DemandStreamKey_T& iKey, + const ContinuousFloatDuration_T& iArrivalPattern, + const ChannelProbabilityMass_T& iChannelProbMass, + const TripTypeProbabilityMass_T& iTripTypeProbMass, + const StayDurationProbabilityMass_T& iStayDurationProbMass, + const FrequentFlyerProbabilityMass_T& iFrequentFlyerProbMass, + const PreferredDepartureTimeCumulativeDistribution_T& iPreferredDepartureTimeCumulativeDistribution, + const WTPCumulativeDistribution_T& iWTPCumulativeDistribution) + : _key (iKey), _arrivalPattern (iArrivalPattern), + _channelProbabilityMass (iChannelProbMass), + _tripTypeProbabilityMass (iTripTypeProbMass), + _stayDurationProbabilityMass (iStayDurationProbMass), + _frequentFlyerProbabilityMass (iFrequentFlyerProbMass), + _preferredDepartureTimeCumulativeDistribution (iPreferredDepartureTimeCumulativeDistribution), + _wtpCumulativeDistribution (iWTPCumulativeDistribution) { } // ///////////////////////////////////////////////////// @@ -29,7 +43,13 @@ DemandCharacteristics:: DemandCharacteristics (const DemandCharacteristics& iDemandCharacteristics) : _key (iDemandCharacteristics._key), - _arrivalPattern (iDemandCharacteristics._arrivalPattern) { + _arrivalPattern (iDemandCharacteristics._arrivalPattern), + _channelProbabilityMass (iDemandCharacteristics._channelProbabilityMass), + _tripTypeProbabilityMass (iDemandCharacteristics._tripTypeProbabilityMass), + _stayDurationProbabilityMass (iDemandCharacteristics._stayDurationProbabilityMass), + _frequentFlyerProbabilityMass (iDemandCharacteristics._frequentFlyerProbabilityMass), + _preferredDepartureTimeCumulativeDistribution (iDemandCharacteristics._preferredDepartureTimeCumulativeDistribution), + _wtpCumulativeDistribution (iDemandCharacteristics._wtpCumulativeDistribution) { } // ///////////////////////////////////////////////////// @@ -68,9 +88,25 @@ oStr << "Preferred cabin .................. : " << _key.getPreferredCabin() << std::endl; oStr << "Arrival pattern (days from departure, proportion): "; + oStr << _arrivalPattern.displayCumulativeDistribution() << std::endl; + oStr << "Channel probability mass (channel, propotion): "; + oStr << _channelProbabilityMass.displayProbabilityMassFunction() + << std::endl; + oStr << "Trip type probability mass (trip type, propotion): "; + oStr << _tripTypeProbabilityMass.displayProbabilityMassFunction() + << std::endl; + oStr << "Stay duration probability mass (number of days, propotion): "; + oStr << _stayDurationProbabilityMass.displayProbabilityMassFunction() + << std::endl; + oStr << "Frequent flyer probability mass (frequent flyer, propotion): "; + oStr << _frequentFlyerProbabilityMass.displayProbabilityMassFunction() + << std::endl; + oStr << "Preferred departure time cumulative distribution (time, proportion: "; + oStr << _preferredDepartureTimeCumulativeDistribution.displayCumulativeDistribution() << std::endl; + oStr << "WTP cumulative distribution (WTP, proportion: "; + oStr << _wtpCumulativeDistribution.displayCumulativeDistribution() + << std::endl; - // - oStr << _arrivalPattern.displayCumulativeDistribution() << std::endl; return oStr.str(); } Modified: trunk/stdair/stdair/basic/DemandCharacteristics.hpp =================================================================== --- trunk/stdair/stdair/basic/DemandCharacteristics.hpp 2010-02-15 19:48:39 UTC (rev 143) +++ trunk/stdair/stdair/basic/DemandCharacteristics.hpp 2010-02-16 16:49:09 UTC (rev 144) @@ -8,7 +8,7 @@ #include <string> // StdAir #include <stdair/STDAIR_Types.hpp> -#include <stdair/basic/ArrivalPattern.hpp> +#include <stdair/basic/DemandCharacteristicTypes.hpp> #include <stdair/bom/DemandStreamKey.hpp> namespace stdair { @@ -40,14 +40,35 @@ return _arrivalPattern; } + /** Get the channel probability mass. */ + const ChannelProbabilityMass_T& getChannelProbabilityMass() const { + return _channelProbabilityMass; + } + + /** Get the trip type probability mass. */ + const TripTypeProbabilityMass_T& getTripTypeProbabilityMass() const { + return _tripTypeProbabilityMass; + } - public: - // ///////////// Setters /////////// - /** Set the arrival pattern. */ - void setArrivalPattern (const ContinuousFloatDuration_T& iArrivalPattern) { - _arrivalPattern = iArrivalPattern; + /** Get the stay duration probability mass. */ + const StayDurationProbabilityMass_T& getStayDurationProbabilityMass() const { + return _stayDurationProbabilityMass; } + /** Get the frequent flyer probability mass. */ + const FrequentFlyerProbabilityMass_T& getFrequentFlyerProbabilityMass() const { + return _frequentFlyerProbabilityMass; + } + + /** Get the preferred departure time cumulative distribution. */ + const PreferredDepartureTimeCumulativeDistribution_T& getPreferredDepartureTimeCumulativeDistribution () const { + return _preferredDepartureTimeCumulativeDistribution; + } + + /** Get the WTP cumulative distribution. */ + const WTPCumulativeDistribution_T& getWTPCumulativeDistribution() const { + return _wtpCumulativeDistribution; + } public: // ////////////// Display Support Methods ////////// @@ -58,7 +79,14 @@ public: // ////////// Constructors and destructors ///////// /** Default constructor. */ - DemandCharacteristics (const DemandStreamKey_T& iKey); + DemandCharacteristics (const DemandStreamKey_T&, + const ContinuousFloatDuration_T&, + const ChannelProbabilityMass_T&, + const TripTypeProbabilityMass_T&, + const StayDurationProbabilityMass_T&, + const FrequentFlyerProbabilityMass_T&, + const PreferredDepartureTimeCumulativeDistribution_T&, + const WTPCumulativeDistribution_T&); /** Default constructor. */ // TODO: That copy constructor should be private @@ -80,13 +108,25 @@ /** Arrival pattern (cumulative distribution of timing of arrival of requests (negative number of days between departure date and request date). */ - ContinuousFloatDuration_T _arrivalPattern; + const ContinuousFloatDuration_T _arrivalPattern; + + /** Channel probability mass. */ + const ChannelProbabilityMass_T _channelProbabilityMass; /** Trip type probability mass */ - // CategoricalAttribute<TripType_T> _tripTypeProbabilityMass; + const TripTypeProbabilityMass_T _tripTypeProbabilityMass; + /** Stay duration probability mass */ + const StayDurationProbabilityMass_T _stayDurationProbabilityMass; + + /** Frequent flyer probability mass */ + const FrequentFlyerProbabilityMass_T _frequentFlyerProbabilityMass; + + /** Preferred departure time cumulative distribution. */ + const PreferredDepartureTimeCumulativeDistribution_T _preferredDepartureTimeCumulativeDistribution; + /** Willingness-to-pay cumulative distribution */ - // ContinuousAttribute<MonetaryValue_T> _willingnessToPayCumulativeDistribution; + const WTPCumulativeDistribution_T _wtpCumulativeDistribution; }; Modified: trunk/stdair/stdair/basic/sources.mk =================================================================== --- trunk/stdair/stdair/basic/sources.mk 2010-02-15 19:48:39 UTC (rev 143) +++ trunk/stdair/stdair/basic/sources.mk 2010-02-16 16:49:09 UTC (rev 144) @@ -1,6 +1,7 @@ bas_h_sources = \ $(top_srcdir)/stdair/basic/BasTypes.hpp \ $(top_srcdir)/stdair/basic/BasConst_General.hpp \ + $(top_srcdir)/stdair/basic/BasConst_Request.hpp \ $(top_srcdir)/stdair/basic/BasConst_Inventory.hpp \ $(top_srcdir)/stdair/basic/BasConst_BookingClass.hpp \ $(top_srcdir)/stdair/basic/BasConst_Yield.hpp \ @@ -14,8 +15,8 @@ $(top_srcdir)/stdair/basic/BasDBParams.hpp \ $(top_srcdir)/stdair/basic/PassengerType.hpp \ $(top_srcdir)/stdair/basic/ContinuousAttribute.hpp \ - $(top_srcdir)/stdair/basic/ArrivalPattern.hpp \ $(top_srcdir)/stdair/basic/CategoricalAttribute.hpp \ + $(top_srcdir)/stdair/basic/DemandCharacteristicTypes.hpp \ $(top_srcdir)/stdair/basic/DemandCharacteristics.hpp \ $(top_srcdir)/stdair/basic/DemandDistribution.hpp \ $(top_srcdir)/stdair/basic/RandomGeneration.hpp \ Modified: trunk/stdair/stdair/bom/BookingRequestStruct.cpp =================================================================== --- trunk/stdair/stdair/bom/BookingRequestStruct.cpp 2010-02-15 19:48:39 UTC (rev 143) +++ trunk/stdair/stdair/bom/BookingRequestStruct.cpp 2010-02-16 16:49:09 UTC (rev 144) @@ -12,16 +12,26 @@ namespace stdair { // ////////////////////////////////////////////////////////////////////// - BookingRequestStruct::BookingRequestStruct (const AirportCode_T& iOrigin, - const AirportCode_T& iDestination, - const Date_T& iDepartureDate, - const DateTime_T& iRequestDateTime, - const CabinCode_T& iPreferredCabin, - const NbOfSeats_T& iPartySize) + BookingRequestStruct:: + BookingRequestStruct (const AirportCode_T& iOrigin, + const AirportCode_T& iDestination, + const Date_T& iDepartureDate, + const DateTime_T& iRequestDateTime, + const CabinCode_T& iPreferredCabin, + const NbOfSeats_T& iPartySize, + const ChannelLabel_T& iChannel, + const TripType_T& iTripType, + const DayDuration_T& iStayDuration, + const FrequentFlyer_T& iFrequentFlyerType, + const Duration_T& iPreferredDepartureTime, + const WTP_T& iWTP) : _origin (iOrigin), _destination (iDestination), _preferredDepartureDate (iDepartureDate), _requestDateTime (iRequestDateTime), - _preferredCabin (iPreferredCabin), _partySize (iPartySize) { + _preferredCabin (iPreferredCabin), _partySize (iPartySize), + _channel (iChannel), _tripType (iTripType), + _stayDuration (iStayDuration), _frequentFlyerType (iFrequentFlyerType), + _preferredDepartureTime (iPreferredDepartureTime), _wtp (iWTP) { } // ////////////////////////////////////////////////////////////////////// @@ -42,7 +52,9 @@ std::ostringstream oStr; oStr << _origin << " - " << _destination << " " << _preferredDepartureDate << " " << _requestDateTime << " " << _preferredCabin - << " " << _partySize; + << " " << _partySize << " " << _channel << " " << _tripType + << " " << _stayDuration << " " << _frequentFlyerType + << " " << _preferredDepartureTime << " " << _wtp; return oStr.str(); } Modified: trunk/stdair/stdair/bom/BookingRequestStruct.hpp =================================================================== --- trunk/stdair/stdair/bom/BookingRequestStruct.hpp 2010-02-15 19:48:39 UTC (rev 143) +++ trunk/stdair/stdair/bom/BookingRequestStruct.hpp 2010-02-16 16:49:09 UTC (rev 144) @@ -46,40 +46,37 @@ const NbOfSeats_T& getPartySize() const { return _partySize; } - - // /////////////// Setters ///////////////// - /** Set the requested origin. */ - void setOrigin (const AirportCode_T& iOrigin) { - _origin = iOrigin; + /** Get the reservation channel. */ + const ChannelLabel_T& getBookingChannel() const { + return _channel; } - /** Set the requested destination. */ - void setDestination (const AirportCode_T& iDestination) { - _destination = iDestination; + /** Get the trip type. */ + const TripType_T& getTripType() const { + return _tripType; } - /** Set the requested departure date. */ - void setPreferredDepartureDate (const Date_T& iDepartureDate) { - _preferredDepartureDate = iDepartureDate; + /** Get the duration of stay. */ + const DayDuration_T& getStayDuration() const { + return _stayDuration; } - - /** Set the request datetime */ - void setRequestDateTime (const DateTime_T& iRequestDateTime) { - _requestDateTime = iRequestDateTime; + + /** Get the frequent flyer type. */ + const FrequentFlyer_T& getFrequentFlyerType() const { + return _frequentFlyerType; } - - /** Set the preferred cabin. */ - void setPreferredCabin (const CabinCode_T& iPreferredCabin) { - _preferredCabin = iPreferredCabin; + + /** Get the preferred departure time. */ + const Duration_T& getPreferredDepartureTime() const { + return _preferredDepartureTime; } - /** Set the party size. */ - void setPartySize (const NbOfSeats_T& iPartySize) { - _partySize = iPartySize; + /** Get the willingness-to-pay. */ + const WTP_T& getWTP() const { + return _wtp; } - - + // /////////// Display support method ///////////// /** Dump a Business Object into an output stream. @param ostream& the output stream. */ @@ -98,7 +95,10 @@ /** Constructor. */ BookingRequestStruct (const AirportCode_T&, const AirportCode_T&, const Date_T&, const DateTime_T&, - const CabinCode_T&, const NbOfSeats_T&); + const CabinCode_T&, const NbOfSeats_T&, + const ChannelLabel_T&, const TripType_T&, + const DayDuration_T&, const FrequentFlyer_T&, + const Duration_T&, const WTP_T&); public : /** Default constructor. */ BookingRequestStruct (); @@ -112,22 +112,41 @@ private: // /////////////// Attributes ///////////////// /** Origin. */ - AirportCode_T _origin; + const AirportCode_T _origin; /** Destination. */ - AirportCode_T _destination; + const AirportCode_T _destination; /** Departure date. */ - Date_T _preferredDepartureDate; + const Date_T _preferredDepartureDate; /** Request date-time */ - DateTime_T _requestDateTime; + const DateTime_T _requestDateTime; /** Preferred cabin. */ - CabinCode_T _preferredCabin; + const CabinCode_T _preferredCabin; /** Party size. */ - NbOfSeats_T _partySize; + const NbOfSeats_T _partySize; + + /** Booking channel (D=direct, I=indirect, N=oNline, F=oFfline). */ + const ChannelLabel_T _channel; + + /** Trip type (RO=outbound of round-trip, RI=inbound of round-trip, + OW=one way). */ + const TripType_T _tripType; + + /** Stay duration (number of days). */ + const DayDuration_T _stayDuration; + + /** Frequent flyer type (P=Platinum, G=Gold, S=Silver, M=Member, N=None). */ + const FrequentFlyer_T _frequentFlyerType; + + /** Preferred departure time. */ + const Duration_T _preferredDepartureTime; + + /** Willingness-To-Pay. */ + const WTP_T _wtp; }; } Modified: trunk/stdair/stdair/bom/DemandStreamContent.hpp =================================================================== --- trunk/stdair/stdair/bom/DemandStreamContent.hpp 2010-02-15 19:48:39 UTC (rev 143) +++ trunk/stdair/stdair/bom/DemandStreamContent.hpp 2010-02-16 16:49:09 UTC (rev 144) @@ -64,6 +64,36 @@ return _demandCharacteristics.getArrivalPattern(); } + /** Get the channel probability mass. */ + const ChannelProbabilityMass_T& getChannelProbabilityMass() const { + return _demandCharacteristics.getChannelProbabilityMass(); + } + + /** Get the trip type probability mass. */ + const TripTypeProbabilityMass_T& getTripTypeProbabilityMass() const { + return _demandCharacteristics.getTripTypeProbabilityMass(); + } + + /** Get the stay duration probability mass. */ + const StayDurationProbabilityMass_T& getStayDurationProbabilityMass() const { + return _demandCharacteristics.getStayDurationProbabilityMass(); + } + + /** Get the frequent flyer probability mass. */ + const FrequentFlyerProbabilityMass_T& getFrequentFlyerProbabilityMass() const { + return _demandCharacteristics.getFrequentFlyerProbabilityMass(); + } + + /** Get the preferred departure time cumulative distribution. */ + const PreferredDepartureTimeCumulativeDistribution_T& getPreferredDepartureTimeCumulativeDistribution () const { + return _demandCharacteristics.getPreferredDepartureTimeCumulativeDistribution(); + } + + /** Get the WTP cumulative distribution. */ + const WTPCumulativeDistribution_T& getWTPCumulativeDistribution() const { + return _demandCharacteristics.getWTPCumulativeDistribution(); + } + /** Get the mean number of requests. */ const NbOfRequests_T& getMeanNumberOfRequests() const { return _demandDistribution.getMeanNumberOfRequests(); @@ -100,6 +130,16 @@ return _demandCharacteristicsRandomGenerator.getSeed(); } + /** Get the demand characteristics. */ + const DemandCharacteristics& getDemandCharacteristics () const { + return _demandCharacteristics; + } + + /** Get the demand distribution. */ + const DemandDistribution& getDemandDistribution () const { + return _demandDistribution; + } + public: // //////////////// Setters ////////////////// /** Set the cumulative probability of arrival pattern for last This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qua...@us...> - 2010-02-17 09:21:36
|
Revision: 146 http://stdair.svn.sourceforge.net/stdair/?rev=146&view=rev Author: quannaus Date: 2010-02-17 09:21:30 +0000 (Wed, 17 Feb 2010) Log Message: ----------- [Dev] Fixed a bug Modified Paths: -------------- trunk/stdair/stdair/basic/RandomGenerationContext.cpp trunk/stdair/stdair/basic/RandomGenerationContext.hpp trunk/stdair/stdair/bom/DemandStreamContent.hpp Modified: trunk/stdair/stdair/basic/RandomGenerationContext.cpp =================================================================== --- trunk/stdair/stdair/basic/RandomGenerationContext.cpp 2010-02-16 16:50:19 UTC (rev 145) +++ trunk/stdair/stdair/basic/RandomGenerationContext.cpp 2010-02-17 09:21:30 UTC (rev 146) @@ -26,7 +26,7 @@ // ////////////////////////////////////////////////////////////////////// void RandomGenerationContext::incrementGeneratedRequestsCounter () { - _numberOfRequestsGeneratedSoFar++; + ++_numberOfRequestsGeneratedSoFar; } } Modified: trunk/stdair/stdair/basic/RandomGenerationContext.hpp =================================================================== --- trunk/stdair/stdair/basic/RandomGenerationContext.hpp 2010-02-16 16:50:19 UTC (rev 145) +++ trunk/stdair/stdair/basic/RandomGenerationContext.hpp 2010-02-17 09:21:30 UTC (rev 146) @@ -23,7 +23,7 @@ } /** Get the number of requests generated so far. */ - const Count_T& getNumberOfRequestsGeneratedSoFar() const { + const Count_T& getNumberOfRequestsGeneratedSoFar () const { return _numberOfRequestsGeneratedSoFar; } Modified: trunk/stdair/stdair/bom/DemandStreamContent.hpp =================================================================== --- trunk/stdair/stdair/bom/DemandStreamContent.hpp 2010-02-16 16:50:19 UTC (rev 145) +++ trunk/stdair/stdair/bom/DemandStreamContent.hpp 2010-02-17 09:21:30 UTC (rev 146) @@ -111,8 +111,8 @@ } /** Get the number of requests generated so far. */ - const Count_T getNumberOfRequestsGeneratedSoFar() const { - return _randomGenerationContext.getCumulativeProbabilitySoFar();; + const Count_T& getNumberOfRequestsGeneratedSoFar() const { + return _randomGenerationContext.getNumberOfRequestsGeneratedSoFar(); } /** Get the seed of the random generator for the number of requests. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qua...@us...> - 2010-02-17 13:02:02
|
Revision: 147 http://stdair.svn.sourceforge.net/stdair/?rev=147&view=rev Author: quannaus Date: 2010-02-17 13:01:56 +0000 (Wed, 17 Feb 2010) Log Message: ----------- [dev] Added POS and value of time into booking request. Modified Paths: -------------- trunk/stdair/stdair/basic/DemandCharacteristicTypes.hpp trunk/stdair/stdair/basic/DemandCharacteristics.cpp trunk/stdair/stdair/basic/DemandCharacteristics.hpp trunk/stdair/stdair/bom/BookingRequestStruct.cpp trunk/stdair/stdair/bom/BookingRequestStruct.hpp trunk/stdair/stdair/bom/DemandStreamContent.hpp Modified: trunk/stdair/stdair/basic/DemandCharacteristicTypes.hpp =================================================================== --- trunk/stdair/stdair/basic/DemandCharacteristicTypes.hpp 2010-02-17 09:21:30 UTC (rev 146) +++ trunk/stdair/stdair/basic/DemandCharacteristicTypes.hpp 2010-02-17 13:01:56 UTC (rev 147) @@ -24,6 +24,15 @@ /** Type definition for the arrival pattern inverse cumulative distribution. */ typedef std::multimap<Probability_T, FloatDuration_T> ArrivalPatternInverseCumulativeDistribution_T; + /** Define the point-of-sale probablity mass. */ + typedef CategoricalAttribute<AirportCode_T> POSProbabilityMass_T; + + /** Define the probability mass function type of point-of-sale. */ + typedef POSProbabilityMass_T::ProbabilityMassFunction_T POSProbabilityMassFunction_T; + + /** Define the inverse cumulative distribution of point-of-sale. */ + typedef POSProbabilityMass_T::InverseCumulativeDistribution_T POSInverserCumulativeDistribution_T; + /** Define the booking channel probablity mass. */ typedef CategoricalAttribute<ChannelLabel_T> ChannelProbabilityMass_T; @@ -77,6 +86,15 @@ /** Define the willingness-to-pay continuous inverse distribution. */ typedef WTPCumulativeDistribution_T::ContinuousInverseDistribution_T WTPContinuousInverseDistribution_T; + + /** Define the value of time cumulative distribution. */ + typedef ContinuousAttribute<PriceValue_T> ValueOfTimeCumulativeDistribution_T; + + /** Define the value of time continuous distribution. */ + typedef ValueOfTimeCumulativeDistribution_T::ContinuousDistribution_T ValueOfTimeContinuousDistribution_T; + + /** Define the value of time continuous inverse distribution. */ + typedef ValueOfTimeCumulativeDistribution_T::ContinuousInverseDistribution_T ValueOfTimeContinuousInverseDistribution_T; } #endif // __STDAIR_BAS_DEMANDCHARACTERISTICTYPES_HPP Modified: trunk/stdair/stdair/basic/DemandCharacteristics.cpp =================================================================== --- trunk/stdair/stdair/basic/DemandCharacteristics.cpp 2010-02-17 09:21:30 UTC (rev 146) +++ trunk/stdair/stdair/basic/DemandCharacteristics.cpp 2010-02-17 13:01:56 UTC (rev 147) @@ -15,19 +15,23 @@ DemandCharacteristics:: DemandCharacteristics (const DemandStreamKey_T& iKey, const ContinuousFloatDuration_T& iArrivalPattern, + const POSProbabilityMass_T& iPOSProbMass, const ChannelProbabilityMass_T& iChannelProbMass, const TripTypeProbabilityMass_T& iTripTypeProbMass, const StayDurationProbabilityMass_T& iStayDurationProbMass, const FrequentFlyerProbabilityMass_T& iFrequentFlyerProbMass, const PreferredDepartureTimeCumulativeDistribution_T& iPreferredDepartureTimeCumulativeDistribution, - const WTPCumulativeDistribution_T& iWTPCumulativeDistribution) + const WTPCumulativeDistribution_T& iWTPCumulativeDistribution, + const ValueOfTimeCumulativeDistribution_T& iValueOfTimeCumulativeDistribution) : _key (iKey), _arrivalPattern (iArrivalPattern), + _posProbabilityMass (iPOSProbMass), _channelProbabilityMass (iChannelProbMass), _tripTypeProbabilityMass (iTripTypeProbMass), _stayDurationProbabilityMass (iStayDurationProbMass), _frequentFlyerProbabilityMass (iFrequentFlyerProbMass), _preferredDepartureTimeCumulativeDistribution (iPreferredDepartureTimeCumulativeDistribution), - _wtpCumulativeDistribution (iWTPCumulativeDistribution) { + _wtpCumulativeDistribution (iWTPCumulativeDistribution), + _valueOfTimeCumulativeDistribution (iValueOfTimeCumulativeDistribution) { } // ///////////////////////////////////////////////////// @@ -44,12 +48,14 @@ DemandCharacteristics (const DemandCharacteristics& iDemandCharacteristics) : _key (iDemandCharacteristics._key), _arrivalPattern (iDemandCharacteristics._arrivalPattern), + _posProbabilityMass (iDemandCharacteristics._posProbabilityMass), _channelProbabilityMass (iDemandCharacteristics._channelProbabilityMass), _tripTypeProbabilityMass (iDemandCharacteristics._tripTypeProbabilityMass), _stayDurationProbabilityMass (iDemandCharacteristics._stayDurationProbabilityMass), _frequentFlyerProbabilityMass (iDemandCharacteristics._frequentFlyerProbabilityMass), _preferredDepartureTimeCumulativeDistribution (iDemandCharacteristics._preferredDepartureTimeCumulativeDistribution), - _wtpCumulativeDistribution (iDemandCharacteristics._wtpCumulativeDistribution) { + _wtpCumulativeDistribution (iDemandCharacteristics._wtpCumulativeDistribution), + _valueOfTimeCumulativeDistribution (iDemandCharacteristics._valueOfTimeCumulativeDistribution) { } // ///////////////////////////////////////////////////// @@ -89,6 +95,9 @@ << std::endl; oStr << "Arrival pattern (days from departure, proportion): "; oStr << _arrivalPattern.displayCumulativeDistribution() << std::endl; + oStr << "POS probability mass (POS, propotion): "; + oStr << _posProbabilityMass.displayProbabilityMassFunction() + << std::endl; oStr << "Channel probability mass (channel, propotion): "; oStr << _channelProbabilityMass.displayProbabilityMassFunction() << std::endl; @@ -106,6 +115,9 @@ oStr << "WTP cumulative distribution (WTP, proportion: "; oStr << _wtpCumulativeDistribution.displayCumulativeDistribution() << std::endl; + oStr << "Value of time cumulative distribution (value of time, proportion: "; + oStr << _valueOfTimeCumulativeDistribution.displayCumulativeDistribution() + << std::endl; return oStr.str(); Modified: trunk/stdair/stdair/basic/DemandCharacteristics.hpp =================================================================== --- trunk/stdair/stdair/basic/DemandCharacteristics.hpp 2010-02-17 09:21:30 UTC (rev 146) +++ trunk/stdair/stdair/basic/DemandCharacteristics.hpp 2010-02-17 13:01:56 UTC (rev 147) @@ -40,6 +40,11 @@ return _arrivalPattern; } + /** Get the point-of-sale probability mass. */ + const POSProbabilityMass_T& getPOSProbabilityMass() const { + return _posProbabilityMass; + } + /** Get the channel probability mass. */ const ChannelProbabilityMass_T& getChannelProbabilityMass() const { return _channelProbabilityMass; @@ -69,6 +74,11 @@ const WTPCumulativeDistribution_T& getWTPCumulativeDistribution() const { return _wtpCumulativeDistribution; } + + /** Get the value of time cumulative distribution. */ + const ValueOfTimeCumulativeDistribution_T& getValueOfTimeCumulativeDistribution () const { + return _valueOfTimeCumulativeDistribution; + } public: // ////////////// Display Support Methods ////////// @@ -81,12 +91,14 @@ /** Default constructor. */ DemandCharacteristics (const DemandStreamKey_T&, const ContinuousFloatDuration_T&, + const POSProbabilityMass_T&, const ChannelProbabilityMass_T&, const TripTypeProbabilityMass_T&, const StayDurationProbabilityMass_T&, const FrequentFlyerProbabilityMass_T&, const PreferredDepartureTimeCumulativeDistribution_T&, - const WTPCumulativeDistribution_T&); + const WTPCumulativeDistribution_T&, + const ValueOfTimeCumulativeDistribution_T&); /** Default constructor. */ // TODO: That copy constructor should be private @@ -110,6 +122,9 @@ and request date). */ const ContinuousFloatDuration_T _arrivalPattern; + /** POS probability mass. */ + const POSProbabilityMass_T _posProbabilityMass; + /** Channel probability mass. */ const ChannelProbabilityMass_T _channelProbabilityMass; @@ -127,7 +142,9 @@ /** Willingness-to-pay cumulative distribution */ const WTPCumulativeDistribution_T _wtpCumulativeDistribution; - + + /** Value of time cumulative distribution. */ + const ValueOfTimeCumulativeDistribution_T _valueOfTimeCumulativeDistribution; }; } Modified: trunk/stdair/stdair/bom/BookingRequestStruct.cpp =================================================================== --- trunk/stdair/stdair/bom/BookingRequestStruct.cpp 2010-02-17 09:21:30 UTC (rev 146) +++ trunk/stdair/stdair/bom/BookingRequestStruct.cpp 2010-02-17 13:01:56 UTC (rev 147) @@ -15,6 +15,7 @@ BookingRequestStruct:: BookingRequestStruct (const AirportCode_T& iOrigin, const AirportCode_T& iDestination, + const AirportCode_T& iPOS, const Date_T& iDepartureDate, const DateTime_T& iRequestDateTime, const CabinCode_T& iPreferredCabin, @@ -24,14 +25,16 @@ const DayDuration_T& iStayDuration, const FrequentFlyer_T& iFrequentFlyerType, const Duration_T& iPreferredDepartureTime, - const WTP_T& iWTP) + const WTP_T& iWTP, + const PriceValue_T& iValueOfTime) : _origin (iOrigin), _destination (iDestination), - _preferredDepartureDate (iDepartureDate), + _pos (iPOS), _preferredDepartureDate (iDepartureDate), _requestDateTime (iRequestDateTime), _preferredCabin (iPreferredCabin), _partySize (iPartySize), _channel (iChannel), _tripType (iTripType), _stayDuration (iStayDuration), _frequentFlyerType (iFrequentFlyerType), - _preferredDepartureTime (iPreferredDepartureTime), _wtp (iWTP) { + _preferredDepartureTime (iPreferredDepartureTime), _wtp (iWTP), + _valueOfTime (iValueOfTime) { } // ////////////////////////////////////////////////////////////////////// @@ -50,11 +53,13 @@ // ////////////////////////////////////////////////////////////////////// const std::string BookingRequestStruct::describe() const { std::ostringstream oStr; - oStr << _origin << " - " << _destination << " " << _preferredDepartureDate + oStr << _origin << " - " << _destination + << " " << _pos << " " << _preferredDepartureDate << " " << _requestDateTime << " " << _preferredCabin << " " << _partySize << " " << _channel << " " << _tripType << " " << _stayDuration << " " << _frequentFlyerType - << " " << _preferredDepartureTime << " " << _wtp; + << " " << _preferredDepartureTime << " " << _wtp + << " " << _valueOfTime; return oStr.str(); } Modified: trunk/stdair/stdair/bom/BookingRequestStruct.hpp =================================================================== --- trunk/stdair/stdair/bom/BookingRequestStruct.hpp 2010-02-17 09:21:30 UTC (rev 146) +++ trunk/stdair/stdair/bom/BookingRequestStruct.hpp 2010-02-17 13:01:56 UTC (rev 147) @@ -27,6 +27,11 @@ return _destination; } + /** Get the point-of-sale. */ + const AirportCode_T& getPOS() const { + return _pos; + } + /** Get the requested departure date. */ const Date_T& getPreferedDepartureDate() const { return _preferredDepartureDate; @@ -76,6 +81,11 @@ const WTP_T& getWTP() const { return _wtp; } + + /** Get the value of time. */ + const PriceValue_T& getValueOfTime () const { + return _valueOfTime; + } // /////////// Display support method ///////////// /** Dump a Business Object into an output stream. @@ -94,11 +104,11 @@ public : /** Constructor. */ BookingRequestStruct (const AirportCode_T&, const AirportCode_T&, - const Date_T&, const DateTime_T&, + const AirportCode_T&, const Date_T&, const DateTime_T&, const CabinCode_T&, const NbOfSeats_T&, const ChannelLabel_T&, const TripType_T&, const DayDuration_T&, const FrequentFlyer_T&, - const Duration_T&, const WTP_T&); + const Duration_T&, const WTP_T&, const PriceValue_T&); public : /** Default constructor. */ BookingRequestStruct (); @@ -116,6 +126,9 @@ /** Destination. */ const AirportCode_T _destination; + + /** Point-Of-Sale. */ + const AirportCode_T _pos; /** Departure date. */ const Date_T _preferredDepartureDate; @@ -147,6 +160,9 @@ /** Willingness-To-Pay. */ const WTP_T _wtp; + + /** Value of time. */ + const PriceValue_T _valueOfTime; }; } Modified: trunk/stdair/stdair/bom/DemandStreamContent.hpp =================================================================== --- trunk/stdair/stdair/bom/DemandStreamContent.hpp 2010-02-17 09:21:30 UTC (rev 146) +++ trunk/stdair/stdair/bom/DemandStreamContent.hpp 2010-02-17 13:01:56 UTC (rev 147) @@ -64,6 +64,11 @@ return _demandCharacteristics.getArrivalPattern(); } + /** Get the POS probability mass. */ + const POSProbabilityMass_T& getPOSProbabilityMass() const { + return _demandCharacteristics.getPOSProbabilityMass(); + } + /** Get the channel probability mass. */ const ChannelProbabilityMass_T& getChannelProbabilityMass() const { return _demandCharacteristics.getChannelProbabilityMass(); @@ -94,6 +99,11 @@ return _demandCharacteristics.getWTPCumulativeDistribution(); } + /** Get the value of time cumulative distribution. */ + const ValueOfTimeCumulativeDistribution_T& getValueOfTimeCumulativeDistribution() const { + return _demandCharacteristics.getValueOfTimeCumulativeDistribution(); + } + /** Get the mean number of requests. */ const NbOfRequests_T& getMeanNumberOfRequests() const { return _demandDistribution.getMeanNumberOfRequests(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qua...@us...> - 2010-02-17 14:57:12
|
Revision: 149 http://stdair.svn.sourceforge.net/stdair/?rev=149&view=rev Author: quannaus Date: 2010-02-17 14:57:06 +0000 (Wed, 17 Feb 2010) Log Message: ----------- [dev] Implemented the display for request. Modified Paths: -------------- trunk/stdair/stdair/STDAIR_Types.hpp trunk/stdair/stdair/bom/BomManager.cpp trunk/stdair/stdair/bom/BomManager.hpp Modified: trunk/stdair/stdair/STDAIR_Types.hpp =================================================================== --- trunk/stdair/stdair/STDAIR_Types.hpp 2010-02-17 14:48:47 UTC (rev 148) +++ trunk/stdair/stdair/STDAIR_Types.hpp 2010-02-17 14:57:06 UTC (rev 149) @@ -132,7 +132,7 @@ /** Time */ typedef boost::posix_time::time_duration Time_T; - /** Define an accurate time (date +time). */ + /** Define an accurate time (date+time). */ typedef boost::posix_time::ptime DateTime_T; /** Define a distance (kilometers). */ Modified: trunk/stdair/stdair/bom/BomManager.cpp =================================================================== --- trunk/stdair/stdair/bom/BomManager.cpp 2010-02-17 14:48:47 UTC (rev 148) +++ trunk/stdair/stdair/bom/BomManager.cpp 2010-02-17 14:57:06 UTC (rev 149) @@ -418,7 +418,7 @@ // Store current formatting flags of the given output stream std::ios::fmtflags oldFlags = oStream.flags(); - /* + /** #id, request_date (YYMMDD), request_time (HHMMSS), POS (three-letter code), origin (three-letter code), destination (three-letter code), preferred departure date (YYMMDD), preferred departure time (HHMM), @@ -434,9 +434,76 @@ #Duration of stay: irrelevant in case of one-way, but set to 0 #Frequent-flyer tier: G=Gold, S=Silver, K=Basic (Krisflyer), N=None */ + + // Request date&time + const DateTime_T& lRequestDateTime = iBookingRequest.getRequestDateTime(); + intDisplay (oStream, lRequestDateTime.date().year()); + intDisplay (oStream, lRequestDateTime.date().month()); + intDisplay (oStream, lRequestDateTime.date().day()); + oStream << ", "; + intDisplay (oStream, lRequestDateTime.time_of_day().hours()); + intDisplay (oStream, lRequestDateTime.time_of_day().minutes()); + intDisplay (oStream, lRequestDateTime.time_of_day().seconds()); + oStream << ", "; + // POS + oStream << iBookingRequest.getPOS() << ", "; + // Origin + oStream << iBookingRequest.getOrigin() << ", "; + // Destination + oStream << iBookingRequest.getDestination() << ", "; + // Preferred departure date + const Date_T& lPreferredDepartureDate = + iBookingRequest.getPreferedDepartureDate(); + intDisplay (oStream, lPreferredDepartureDate.year()); + intDisplay (oStream, lPreferredDepartureDate.month()); + intDisplay (oStream, lPreferredDepartureDate.day()); + oStream << ", "; + // Preferred departure time + const Duration_T& lPreferredDepartureTime = + iBookingRequest.getPreferredDepartureTime(); + intDisplay (oStream, lPreferredDepartureTime.hours()); + intDisplay (oStream, lPreferredDepartureTime.minutes()); + oStream << ", "; + // MIN & MAX preferred departure time (hardcode) + oStream << "0000, 2359, "; + // Preferred cabin + oStream << iBookingRequest.getPreferredCabin() << ", "; + // Trip type + oStream << iBookingRequest.getTripType() << ", "; + // Duration of stay + if (iBookingRequest.getTripType() == "OW") { + oStream << "0, "; + } else { + oStream << iBookingRequest.getStayDuration() << ", "; + } + // Frequent flyer tier + oStream << iBookingRequest.getFrequentFlyerType() << ", "; + // Willingness-to-pay + oStream << iBookingRequest.getWTP() << ", "; + // Disutility per stop (hardcode to 100) + oStream << "100, "; + // Preferred arrival date (hardcode to the preferred departure date) + intDisplay (oStream, lPreferredDepartureDate.year()); + intDisplay (oStream, lPreferredDepartureDate.month()); + intDisplay (oStream, lPreferredDepartureDate.day()); + oStream << ", "; + // Preferred arrival time (hardcode to 23:55 + oStream << "2355, "; + // Value of time + oStream <<iBookingRequest.getValueOfTime() << std::endl; // Reset formatting flags of the given output stream oStream.flags (oldFlags); } + + // //////////////////////////////////////////////////////////////////// + void BomManager::intDisplay (std::ostream& oStream, const int& iInt) { + const int dInt = iInt - static_cast<int>(iInt/100)*100; + if (dInt < 10) { + oStream << "0" << dInt; + } else { + oStream << dInt; + } + } } Modified: trunk/stdair/stdair/bom/BomManager.hpp =================================================================== --- trunk/stdair/stdair/bom/BomManager.hpp 2010-02-17 14:48:47 UTC (rev 148) +++ trunk/stdair/stdair/bom/BomManager.hpp 2010-02-17 14:57:06 UTC (rev 149) @@ -126,6 +126,8 @@ @param const LegCabin& Root of the BOM tree to be displayed. */ static void csvDisplay (std::ostream&, const BookingRequestStruct& iBookingRequest); + /** Helper fuction to display an interger. */ + static void intDisplay (std::ostream&, const int&); }; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qua...@us...> - 2010-02-18 15:42:41
|
Revision: 154 http://stdair.svn.sourceforge.net/stdair/?rev=154&view=rev Author: quannaus Date: 2010-02-18 15:42:34 +0000 (Thu, 18 Feb 2010) Log Message: ----------- [dev] Fix a bug in display. Modified Paths: -------------- trunk/stdair/stdair/STDAIR_Types.hpp trunk/stdair/stdair/bom/AirlineFeature.cpp trunk/stdair/stdair/bom/AirlineFeatureSet.cpp trunk/stdair/stdair/bom/AirlineFeatureSetStructure.hpp trunk/stdair/stdair/bom/AirlineFeatureStructure.hpp trunk/stdair/stdair/bom/AirportDate.cpp trunk/stdair/stdair/bom/AirportDateStructure.hpp trunk/stdair/stdair/bom/BomManager.cpp trunk/stdair/stdair/bom/BomManager.hpp trunk/stdair/stdair/bom/BomRoot.cpp trunk/stdair/stdair/bom/BomRootStructure.hpp trunk/stdair/stdair/bom/BookingClassStructure.hpp trunk/stdair/stdair/bom/DemandStreamStructure.hpp trunk/stdair/stdair/bom/FlightDate.cpp trunk/stdair/stdair/bom/FlightDateStructure.hpp trunk/stdair/stdair/bom/Inventory.cpp trunk/stdair/stdair/bom/InventoryStructure.hpp trunk/stdair/stdair/bom/LegCabin.cpp trunk/stdair/stdair/bom/LegCabinStructure.hpp trunk/stdair/stdair/bom/LegDate.cpp trunk/stdair/stdair/bom/LegDateStructure.hpp trunk/stdair/stdair/bom/Network.cpp trunk/stdair/stdair/bom/NetworkDate.cpp trunk/stdair/stdair/bom/NetworkDateStructure.hpp trunk/stdair/stdair/bom/NetworkStructure.hpp trunk/stdair/stdair/bom/OutboundPath.cpp trunk/stdair/stdair/bom/OutboundPathContent.hpp trunk/stdair/stdair/bom/OutboundPathKey.cpp trunk/stdair/stdair/bom/OutboundPathKey.hpp trunk/stdair/stdair/bom/OutboundPathStructure.hpp trunk/stdair/stdair/bom/SegmentCabin.cpp 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/command/CmdBomManager.cpp trunk/stdair/stdair/factory/FacBomContent.hpp trunk/stdair/stdair/factory/FacBomStructure.hpp Modified: trunk/stdair/stdair/STDAIR_Types.hpp =================================================================== --- trunk/stdair/stdair/STDAIR_Types.hpp 2010-02-18 10:19:27 UTC (rev 153) +++ trunk/stdair/stdair/STDAIR_Types.hpp 2010-02-18 15:42:34 UTC (rev 154) @@ -47,6 +47,9 @@ class MemoryAllocationException : public RootException { }; + class ObjectLinkingException : public RootException { + }; + class ParserException : public RootException { }; Modified: trunk/stdair/stdair/bom/AirlineFeature.cpp =================================================================== --- trunk/stdair/stdair/bom/AirlineFeature.cpp 2010-02-18 10:19:27 UTC (rev 153) +++ trunk/stdair/stdair/bom/AirlineFeature.cpp 2010-02-18 15:42:34 UTC (rev 154) @@ -63,7 +63,7 @@ // ////////////////////////////////////////////////////////////////////// const std::string AirlineFeature::describeKey() const { - return _key.toString(); + return _key.describe(); } // ////////////////////////////////////////////////////////////////////// Modified: trunk/stdair/stdair/bom/AirlineFeatureSet.cpp =================================================================== --- trunk/stdair/stdair/bom/AirlineFeatureSet.cpp 2010-02-18 10:19:27 UTC (rev 153) +++ trunk/stdair/stdair/bom/AirlineFeatureSet.cpp 2010-02-18 15:42:34 UTC (rev 154) @@ -38,7 +38,7 @@ // ////////////////////////////////////////////////////////////////////// std::string AirlineFeatureSet::toString() const { - return describeKey(); + return describeShortKey(); } // ////////////////////////////////////////////////////////////////////// @@ -48,7 +48,7 @@ // ////////////////////////////////////////////////////////////////////// const std::string AirlineFeatureSet::describeShortKey() const { - return std::string (""); + return _key.toString(); } // ////////////////////////////////////////////////////////////////////// Modified: trunk/stdair/stdair/bom/AirlineFeatureSetStructure.hpp =================================================================== --- trunk/stdair/stdair/bom/AirlineFeatureSetStructure.hpp 2010-02-18 10:19:27 UTC (rev 153) +++ trunk/stdair/stdair/bom/AirlineFeatureSetStructure.hpp 2010-02-18 15:42:34 UTC (rev 154) @@ -118,11 +118,11 @@ void fromStream (std::istream& ioIn) { } /** Get the serialised version of the Business Object. */ - std::string toString() const { return describeKey(); } + std::string toString() const { return describeShortKey(); } /** Get a string describing the whole key (differentiating two objects at any level). */ - const std::string describeKey() const { return getKey().toString(); } + const std::string describeKey() const { return getKey().describe(); } /** Get a string describing the short key (differentiating two objects at the same level). */ Modified: trunk/stdair/stdair/bom/AirlineFeatureStructure.hpp =================================================================== --- trunk/stdair/stdair/bom/AirlineFeatureStructure.hpp 2010-02-18 10:19:27 UTC (rev 153) +++ trunk/stdair/stdair/bom/AirlineFeatureStructure.hpp 2010-02-18 15:42:34 UTC (rev 154) @@ -80,11 +80,11 @@ void fromStream (std::istream& ioIn) { } /** Get the serialised version of the Business Object. */ - std::string toString() const { return describeKey(); } + std::string toString() const { return describeShortKey(); } /** Get a string describing the whole key (differentiating two objects at any level). */ - const std::string describeKey() const { return getKey().toString(); } + const std::string describeKey() const { return getKey().describe(); } /** Get a string describing the short key (differentiating two objects at the same level). */ Modified: trunk/stdair/stdair/bom/AirportDate.cpp =================================================================== --- trunk/stdair/stdair/bom/AirportDate.cpp 2010-02-18 10:19:27 UTC (rev 153) +++ trunk/stdair/stdair/bom/AirportDate.cpp 2010-02-18 15:42:34 UTC (rev 154) @@ -47,12 +47,12 @@ // //////////////////////////////////////////////////////////////////// const std::string AirportDate::describeKey() const { - return _airportDateStructure.describeKey(); + return _key.describe(); } // //////////////////////////////////////////////////////////////////// const std::string AirportDate::describeShortKey() const { - return _airportDateStructure.describeShortKey(); + return _key.toString(); } // //////////////////////////////////////////////////////////////////// Modified: trunk/stdair/stdair/bom/AirportDateStructure.hpp =================================================================== --- trunk/stdair/stdair/bom/AirportDateStructure.hpp 2010-02-18 10:19:27 UTC (rev 153) +++ trunk/stdair/stdair/bom/AirportDateStructure.hpp 2010-02-18 15:42:34 UTC (rev 154) @@ -142,11 +142,11 @@ void fromStream (std::istream& ioIn) { } /** Get the serialised version of the Business Object. */ - std::string toString() const { return describeKey(); } + std::string toString() const { return describeShortKey(); } /** Get a string describing the whole key (differentiating two objects at any level). */ - const std::string describeKey() const { return getKey().toString(); } + const std::string describeKey() const { return getKey().describe(); } /** Get a string describing the short key (differentiating two objects at the same level). */ Modified: trunk/stdair/stdair/bom/BomManager.cpp =================================================================== --- trunk/stdair/stdair/bom/BomManager.cpp 2010-02-18 10:19:27 UTC (rev 153) +++ trunk/stdair/stdair/bom/BomManager.cpp 2010-02-18 15:42:34 UTC (rev 154) @@ -413,6 +413,28 @@ } // ////////////////////////////////////////////////////////////////////// + void BomManager::display (std::ostream& oStream, + const AirlineFeatureSet& iAirlineFeatureSet) { + // Store current formatting flags of the given output stream + std::ios::fmtflags oldFlags = oStream.flags(); + + oStream << iAirlineFeatureSet.describeKey() << std::endl; + + const AirlineFeatureList_T& lAirlineFeatureList = + iAirlineFeatureSet.getAirlineFeatureList(); + for (AirlineFeatureList_T::iterator itAirlineFeature = + lAirlineFeatureList.begin(); + itAirlineFeature != lAirlineFeatureList.end(); ++itAirlineFeature) { + const AirlineFeature& lCurrentAirlineFeature = *itAirlineFeature; + + oStream << lCurrentAirlineFeature.describeKey() << std::endl; + } + + // Reset formatting flags of the given output stream + oStream.flags (oldFlags); + } + + // ////////////////////////////////////////////////////////////////////// void BomManager::csvDisplay (std::ostream& oStream, const BookingRequestStruct& iBookingRequest) { // Store current formatting flags of the given output stream Modified: trunk/stdair/stdair/bom/BomManager.hpp =================================================================== --- trunk/stdair/stdair/bom/BomManager.hpp 2010-02-18 10:19:27 UTC (rev 153) +++ trunk/stdair/stdair/bom/BomManager.hpp 2010-02-18 15:42:34 UTC (rev 154) @@ -22,6 +22,7 @@ class NetworkDate; class AirportDate; class OutboundPath; + class AirlineFeatureSet; struct BookingRequestStruct; /** Utility class for StdAir objects. */ @@ -123,6 +124,13 @@ the objects of the given BOM tree. @param std::ostream& Output stream in which the BOM tree should be logged/dumped. + @param const AirlineFeatureSet& Root of the BOM tree to be displayed. */ + static void display (std::ostream&, const AirlineFeatureSet&); + + /** Recursively display (dump in the underlying output log stream) + the objects of the given BOM tree. + @param std::ostream& Output stream in which the BOM tree should be + logged/dumped. @param const LegCabin& Root of the BOM tree to be displayed. */ static void csvDisplay (std::ostream&, const BookingRequestStruct& iBookingRequest); Modified: trunk/stdair/stdair/bom/BomRoot.cpp =================================================================== --- trunk/stdair/stdair/bom/BomRoot.cpp 2010-02-18 10:19:27 UTC (rev 153) +++ trunk/stdair/stdair/bom/BomRoot.cpp 2010-02-18 15:42:34 UTC (rev 154) @@ -17,7 +17,8 @@ // //////////////////////////////////////////////////////////////////// BomRoot::BomRoot (const BomKey_T& iKey, BomStructure_T& ioBomRootStructure) - : BomRootContent (iKey), _bomRootStructure (ioBomRootStructure) { + : BomRootContent (iKey), _bomRootStructure (ioBomRootStructure), + _airlineFeatureSet (NULL) { } // //////////////////////////////////////////////////////////////////// Modified: trunk/stdair/stdair/bom/BomRootStructure.hpp =================================================================== --- trunk/stdair/stdair/bom/BomRootStructure.hpp 2010-02-18 10:19:27 UTC (rev 153) +++ trunk/stdair/stdair/bom/BomRootStructure.hpp 2010-02-18 15:42:34 UTC (rev 154) @@ -138,11 +138,11 @@ void fromStream (std::istream& ioIn) { } /** Get the serialised version of the Business Object. */ - std::string toString() const { return describeKey(); } + std::string toString() const { return describeShortKey(); } /** Get a string describing the whole key (differentiating two objects at any level). */ - const std::string describeKey() const { return getKey().toString(); } + const std::string describeKey() const { return getKey().describe(); } /** Get a string describing the short key (differentiating two objects at the same level). */ Modified: trunk/stdair/stdair/bom/BookingClassStructure.hpp =================================================================== --- trunk/stdair/stdair/bom/BookingClassStructure.hpp 2010-02-18 10:19:27 UTC (rev 153) +++ trunk/stdair/stdair/bom/BookingClassStructure.hpp 2010-02-18 15:42:34 UTC (rev 154) @@ -78,11 +78,11 @@ void fromStream (std::istream& ioIn) { } /** Get the serialised version of the Business Object. */ - std::string toString() const { return describeKey(); } + std::string toString() const { return describeShortKey(); } /** Get a string describing the whole key (differentiating two objects at any level). */ - const std::string describeKey() const { return getKey().toString(); } + const std::string describeKey() const { return getKey().describe(); } /** Get a string describing the short key (differentiating two objects at the same level). */ Modified: trunk/stdair/stdair/bom/DemandStreamStructure.hpp =================================================================== --- trunk/stdair/stdair/bom/DemandStreamStructure.hpp 2010-02-18 10:19:27 UTC (rev 153) +++ trunk/stdair/stdair/bom/DemandStreamStructure.hpp 2010-02-18 15:42:34 UTC (rev 154) @@ -80,11 +80,11 @@ void fromStream (std::istream& ioIn) { } /** Get the serialised version of the Business Object. */ - std::string toString() const { return describeKey(); } + std::string toString() const { return describeShortKey(); } /** Get a string describing the whole key (differentiating two objects at any level). */ - const std::string describeKey() const { return getKey().toString(); } + const std::string describeKey() const { return getKey().describe(); } /** Get a string describing the short key (differentiating two objects at the same level). */ Modified: trunk/stdair/stdair/bom/FlightDate.cpp =================================================================== --- trunk/stdair/stdair/bom/FlightDate.cpp 2010-02-18 10:19:27 UTC (rev 153) +++ trunk/stdair/stdair/bom/FlightDate.cpp 2010-02-18 15:42:34 UTC (rev 154) @@ -48,12 +48,12 @@ // ////////////////////////////////////////////////////////////////////// const std::string FlightDate::describeKey() const { - return _flightDateStructure.describeKey(); + return _key.describe(); } // ////////////////////////////////////////////////////////////////////// const std::string FlightDate::describeShortKey() const { - return _flightDateStructure.describeShortKey(); + return _key.toString(); } // ////////////////////////////////////////////////////////////////////// Modified: trunk/stdair/stdair/bom/FlightDateStructure.hpp =================================================================== --- trunk/stdair/stdair/bom/FlightDateStructure.hpp 2010-02-18 10:19:27 UTC (rev 153) +++ trunk/stdair/stdair/bom/FlightDateStructure.hpp 2010-02-18 15:42:34 UTC (rev 154) @@ -229,11 +229,11 @@ void fromStream (std::istream& ioIn) { } /** Get the serialised version of the Business Object. */ - std::string toString() const { return describeKey(); } + std::string toString() const { return describeShortKey(); } /** Get a string describing the whole key (differentiating two objects at any level). */ - const std::string describeKey() const { return getKey().toString(); } + const std::string describeKey() const { return getKey().describe(); } /** Get a string describing the short key (differentiating two objects at the same level). */ Modified: trunk/stdair/stdair/bom/Inventory.cpp =================================================================== --- trunk/stdair/stdair/bom/Inventory.cpp 2010-02-18 10:19:27 UTC (rev 153) +++ trunk/stdair/stdair/bom/Inventory.cpp 2010-02-18 15:42:34 UTC (rev 154) @@ -41,12 +41,12 @@ // ////////////////////////////////////////////////////////////////////// const std::string Inventory::describeKey() const { - return _inventoryStructure.describeKey(); + return _key.describe(); } // ////////////////////////////////////////////////////////////////////// const std::string Inventory::describeShortKey() const { - return _inventoryStructure.describeShortKey(); + return _key.toString(); } // ////////////////////////////////////////////////////////////////////// Modified: trunk/stdair/stdair/bom/InventoryStructure.hpp =================================================================== --- trunk/stdair/stdair/bom/InventoryStructure.hpp 2010-02-18 10:19:27 UTC (rev 153) +++ trunk/stdair/stdair/bom/InventoryStructure.hpp 2010-02-18 15:42:34 UTC (rev 154) @@ -158,11 +158,11 @@ void fromStream (std::istream& ioIn) { } /** Get the serialised version of the Business Object. */ - std::string toString() const { return describeKey(); } + std::string toString() const { return describeShortKey(); } /** Get a string describing the whole key (differentiating two objects at any level). */ - const std::string describeKey() const { return getKey().toString(); } + const std::string describeKey() const { return getKey().describe(); } /** Get a string describing the short key (differentiating two objects at the same level). */ Modified: trunk/stdair/stdair/bom/LegCabin.cpp =================================================================== --- trunk/stdair/stdair/bom/LegCabin.cpp 2010-02-18 10:19:27 UTC (rev 153) +++ trunk/stdair/stdair/bom/LegCabin.cpp 2010-02-18 15:42:34 UTC (rev 154) @@ -42,12 +42,12 @@ // ////////////////////////////////////////////////////////////////////// const std::string LegCabin::describeKey() const { - return _legCabinStructure.describeKey(); + return _key.describe(); } // ////////////////////////////////////////////////////////////////////// const std::string LegCabin::describeShortKey() const { - return _legCabinStructure.describeShortKey(); + return _key.toString(); } // ////////////////////////////////////////////////////////////////////// Modified: trunk/stdair/stdair/bom/LegCabinStructure.hpp =================================================================== --- trunk/stdair/stdair/bom/LegCabinStructure.hpp 2010-02-18 10:19:27 UTC (rev 153) +++ trunk/stdair/stdair/bom/LegCabinStructure.hpp 2010-02-18 15:42:34 UTC (rev 154) @@ -96,11 +96,11 @@ void fromStream (std::istream& ioIn) { } /** Get the serialised version of the Business Object. */ - std::string toString() const { return describeKey(); } + std::string toString() const { return describeShortKey(); } /** Get a string describing the whole key (differentiating two objects at any level). */ - const std::string describeKey() const { return getKey().toString(); } + const std::string describeKey() const { return getKey().describe(); } /** Get a string describing the short key (differentiating two objects at the same level). */ Modified: trunk/stdair/stdair/bom/LegDate.cpp =================================================================== --- trunk/stdair/stdair/bom/LegDate.cpp 2010-02-18 10:19:27 UTC (rev 153) +++ trunk/stdair/stdair/bom/LegDate.cpp 2010-02-18 15:42:34 UTC (rev 154) @@ -45,12 +45,12 @@ // //////////////////////////////////////////////////////////////////// const std::string LegDate::describeKey() const { - return _legDateStructure.describeKey(); + return _key.describe(); } // //////////////////////////////////////////////////////////////////// const std::string LegDate::describeShortKey() const { - return _legDateStructure.describeShortKey(); + return _key.toString(); } // //////////////////////////////////////////////////////////////////// Modified: trunk/stdair/stdair/bom/LegDateStructure.hpp =================================================================== --- trunk/stdair/stdair/bom/LegDateStructure.hpp 2010-02-18 10:19:27 UTC (rev 153) +++ trunk/stdair/stdair/bom/LegDateStructure.hpp 2010-02-18 15:42:34 UTC (rev 154) @@ -145,11 +145,11 @@ void fromStream (std::istream& ioIn) { } /** Get the serialised version of the Business Object. */ - std::string toString() const { return describeKey(); } + std::string toString() const { return describeShortKey(); } /** Get a string describing the whole key (differentiating two objects at any level). */ - const std::string describeKey() const { return getKey().toString(); } + const std::string describeKey() const { return getKey().describe(); } /** Get a string describing the short key (differentiating two objects at the same level). */ Modified: trunk/stdair/stdair/bom/Network.cpp =================================================================== --- trunk/stdair/stdair/bom/Network.cpp 2010-02-18 10:19:27 UTC (rev 153) +++ trunk/stdair/stdair/bom/Network.cpp 2010-02-18 15:42:34 UTC (rev 154) @@ -40,12 +40,12 @@ // ////////////////////////////////////////////////////////////////////// const std::string Network::describeKey() const { - return _networkStructure.describeKey(); + return _key.describe(); } // ////////////////////////////////////////////////////////////////////// const std::string Network::describeShortKey() const { - return _networkStructure.describeShortKey(); + return _key.toString(); } // ////////////////////////////////////////////////////////////////////// Modified: trunk/stdair/stdair/bom/NetworkDate.cpp =================================================================== --- trunk/stdair/stdair/bom/NetworkDate.cpp 2010-02-18 10:19:27 UTC (rev 153) +++ trunk/stdair/stdair/bom/NetworkDate.cpp 2010-02-18 15:42:34 UTC (rev 154) @@ -40,12 +40,12 @@ // ////////////////////////////////////////////////////////////////////// const std::string NetworkDate::describeKey() const { - return _networkDateStructure.describeKey(); + return _key.describe(); } // ////////////////////////////////////////////////////////////////////// const std::string NetworkDate::describeShortKey() const { - return _networkDateStructure.describeShortKey(); + return _key.toString(); } // ////////////////////////////////////////////////////////////////////// Modified: trunk/stdair/stdair/bom/NetworkDateStructure.hpp =================================================================== --- trunk/stdair/stdair/bom/NetworkDateStructure.hpp 2010-02-18 10:19:27 UTC (rev 153) +++ trunk/stdair/stdair/bom/NetworkDateStructure.hpp 2010-02-18 15:42:34 UTC (rev 154) @@ -159,11 +159,11 @@ void fromStream (std::istream& ioIn) { } /** Get the serialised version of the Business Object. */ - std::string toString() const { return describeKey(); } + std::string toString() const { return describeShortKey(); } /** Get a string describing the whole key (differentiating two objects at any level). */ - const std::string describeKey() const { return getKey().toString(); } + const std::string describeKey() const { return getKey().describe(); } /** Get a string describing the short key (differentiating two objects at the same level). */ Modified: trunk/stdair/stdair/bom/NetworkStructure.hpp =================================================================== --- trunk/stdair/stdair/bom/NetworkStructure.hpp 2010-02-18 10:19:27 UTC (rev 153) +++ trunk/stdair/stdair/bom/NetworkStructure.hpp 2010-02-18 15:42:34 UTC (rev 154) @@ -143,11 +143,11 @@ void fromStream (std::istream& ioIn) { } /** Get the serialised version of the Business Object. */ - std::string toString() const { return describeKey(); } + std::string toString() const { return describeShortKey(); } /** Get a string describing the whole key (differentiating two objects at any level). */ - const std::string describeKey() const { return getKey().toString(); } + const std::string describeKey() const { return getKey().describe(); } /** Get a string describing the short key (differentiating two objects at the same level). */ Modified: trunk/stdair/stdair/bom/OutboundPath.cpp =================================================================== --- trunk/stdair/stdair/bom/OutboundPath.cpp 2010-02-18 10:19:27 UTC (rev 153) +++ trunk/stdair/stdair/bom/OutboundPath.cpp 2010-02-18 15:42:34 UTC (rev 154) @@ -47,12 +47,12 @@ // //////////////////////////////////////////////////////////////////// const std::string OutboundPath::describeKey() const { - return _outboundPathStructure.describeKey(); + return _key.describe(); } // //////////////////////////////////////////////////////////////////// const std::string OutboundPath::describeShortKey() const { - return _outboundPathStructure.describeShortKey(); + return _key.toString(); } // //////////////////////////////////////////////////////////////////// Modified: trunk/stdair/stdair/bom/OutboundPathContent.hpp =================================================================== --- trunk/stdair/stdair/bom/OutboundPathContent.hpp 2010-02-18 10:19:27 UTC (rev 153) +++ trunk/stdair/stdair/bom/OutboundPathContent.hpp 2010-02-18 15:42:34 UTC (rev 154) @@ -62,6 +62,11 @@ const NbOfAirlines_T& getNbOfAirlines() const { return _key.getNbOfAirlines(); } + + /** Get the boarding time. */ + const Duration_T& getBoardingTime() const { + return _key.getBoardingTime(); + } public: // /////////// Setters //////////// Modified: trunk/stdair/stdair/bom/OutboundPathKey.cpp =================================================================== --- trunk/stdair/stdair/bom/OutboundPathKey.cpp 2010-02-18 10:19:27 UTC (rev 153) +++ trunk/stdair/stdair/bom/OutboundPathKey.cpp 2010-02-18 15:42:34 UTC (rev 154) @@ -11,11 +11,13 @@ OutboundPathKey_T (const AirportCode_T& iDestination, const Duration_T& iElapsedTime, const NbOfSegments_T& iNbOfSegments, - const NbOfAirlines_T& iNbOfAirlines) + const NbOfAirlines_T& iNbOfAirlines, + const Duration_T& iBoardingTime) : _destination (iDestination), _elapsed (iElapsedTime), _nbOfSegments (iNbOfSegments), - _nbOfAirlines (iNbOfAirlines) { + _nbOfAirlines (iNbOfAirlines), + _boardingTime (iBoardingTime){ } // //////////////////////////////////////////////////////////////////// @@ -35,7 +37,7 @@ const std::string OutboundPathKey_T::toString() const { std::ostringstream oStr; oStr << _destination << ", " << _elapsed << ", " - << _nbOfSegments << ", " << _nbOfAirlines; + << _nbOfSegments << ", " << _nbOfAirlines << ", " << _boardingTime; return oStr.str(); } Modified: trunk/stdair/stdair/bom/OutboundPathKey.hpp =================================================================== --- trunk/stdair/stdair/bom/OutboundPathKey.hpp 2010-02-18 10:19:27 UTC (rev 153) +++ trunk/stdair/stdair/bom/OutboundPathKey.hpp 2010-02-18 15:42:34 UTC (rev 154) @@ -21,10 +21,9 @@ public: // /////////// Construction /////////// /** Constructor. */ - OutboundPathKey_T (const AirportCode_T&, - const Duration_T&, - const NbOfSegments_T&, - const NbOfAirlines_T&); + OutboundPathKey_T (const AirportCode_T&, const Duration_T&, + const NbOfSegments_T&, const NbOfAirlines_T&, + const Duration_T&); /** Destructor. */ ~OutboundPathKey_T (); @@ -49,6 +48,11 @@ const Duration_T& getElapsedTime() const { return _elapsed; } + + /** Get the boarding time. */ + const Duration_T& getBoardingTime () const { + return _boardingTime; + } /** Get boarding airport. */ const AirportCode_T& getBoardingPoint() const; @@ -96,6 +100,9 @@ /** Number of airlines included in the path. */ NbOfAirlines_T _nbOfAirlines; + + /** The boarding time. */ + Duration_T _boardingTime; }; } Modified: trunk/stdair/stdair/bom/OutboundPathStructure.hpp =================================================================== --- trunk/stdair/stdair/bom/OutboundPathStructure.hpp 2010-02-18 10:19:27 UTC (rev 153) +++ trunk/stdair/stdair/bom/OutboundPathStructure.hpp 2010-02-18 15:42:34 UTC (rev 154) @@ -117,11 +117,11 @@ void fromStream (std::istream& ioIn) { } /** Get the serialised version of the Business Object. */ - std::string toString() const { return describeKey(); } + std::string toString() const { return describeShortKey(); } /** Get a string describing the whole key (differentiating two objects at any level). */ - const std::string describeKey() const { return getKey().toString(); } + const std::string describeKey() const { return getKey().describe(); } /** Get a string describing the short key (differentiating two objects at the same level). */ Modified: trunk/stdair/stdair/bom/SegmentCabin.cpp =================================================================== --- trunk/stdair/stdair/bom/SegmentCabin.cpp 2010-02-18 10:19:27 UTC (rev 153) +++ trunk/stdair/stdair/bom/SegmentCabin.cpp 2010-02-18 15:42:34 UTC (rev 154) @@ -46,12 +46,12 @@ // ////////////////////////////////////////////////////////////////////// const std::string SegmentCabin::describeKey() const { - return _segmentCabinStructure.describeKey(); + return _key.describe(); } // ////////////////////////////////////////////////////////////////////// const std::string SegmentCabin::describeShortKey() const { - return _segmentCabinStructure.describeShortKey(); + return _key.toString(); } // ////////////////////////////////////////////////////////////////////// Modified: trunk/stdair/stdair/bom/SegmentCabinStructure.hpp =================================================================== --- trunk/stdair/stdair/bom/SegmentCabinStructure.hpp 2010-02-18 10:19:27 UTC (rev 153) +++ trunk/stdair/stdair/bom/SegmentCabinStructure.hpp 2010-02-18 15:42:34 UTC (rev 154) @@ -121,11 +121,11 @@ void fromStream (std::istream& ioIn) { } /** Get the serialised version of the Business Object. */ - std::string toString() const { return describeKey(); } + std::string toString() const { return describeShortKey(); } /** Get a string describing the whole key (differentiating two objects at any level). */ - const std::string describeKey() const { return getKey().toString(); } + const std::string describeKey() const { return getKey().describe(); } /** Get a string describing the short key (differentiating two objects at the same level). */ Modified: trunk/stdair/stdair/bom/SegmentDate.cpp =================================================================== --- trunk/stdair/stdair/bom/SegmentDate.cpp 2010-02-18 10:19:27 UTC (rev 153) +++ trunk/stdair/stdair/bom/SegmentDate.cpp 2010-02-18 15:42:34 UTC (rev 154) @@ -48,12 +48,12 @@ // ////////////////////////////////////////////////////////////////////// const std::string SegmentDate::describeKey() const { - return _segmentDateStructure.describeKey(); + return _key.describe(); } // ////////////////////////////////////////////////////////////////////// const std::string SegmentDate::describeShortKey() const { - return _segmentDateStructure.describeShortKey(); + return _key.toString(); } // ////////////////////////////////////////////////////////////////////// Modified: trunk/stdair/stdair/bom/SegmentDate.hpp =================================================================== --- trunk/stdair/stdair/bom/SegmentDate.hpp 2010-02-18 10:19:27 UTC (rev 153) +++ trunk/stdair/stdair/bom/SegmentDate.hpp 2010-02-18 15:42:34 UTC (rev 154) @@ -51,22 +51,7 @@ /** Get a LegDateList_T for iteration methods. */ LegDateList_T getLegDateList () const; - -// /** 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 the BookingClass corresponding to the given ClassCode. - <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 ClassCode_T&) const; - private: /** Retrieve the BOM structure object. */ BomStructure_T& getBomStructure () { @@ -126,15 +111,6 @@ /** Reference structure. */ BomStructure_T& _segmentDateStructure; -// /** Map between ClassCode and SegmentCabin pointer. */ -// ClassSegmentCabinList_T _classSegmentCabinList; - -// /** List of routing LegDate objects. */ -// LegDateOrderedList_T _legDateList; - - /** MultiMap linking MatchingIndicator values - and BookingClass. */ - // BookingClassIndicatorList_T _classIndicatorList; }; } Modified: trunk/stdair/stdair/bom/SegmentDateStructure.hpp =================================================================== --- trunk/stdair/stdair/bom/SegmentDateStructure.hpp 2010-02-18 10:19:27 UTC (rev 153) +++ trunk/stdair/stdair/bom/SegmentDateStructure.hpp 2010-02-18 15:42:34 UTC (rev 154) @@ -128,11 +128,11 @@ void fromStream (std::istream& ioIn) { } /** Get the serialised version of the Business Object. */ - std::string toString() const { return describeKey(); } + std::string toString() const { return describeShortKey(); } /** Get a string describing the whole key (differentiating two objects at any level). */ - const std::string describeKey() const { return getKey().toString(); } + const std::string describeKey() const { return getKey().describe(); } /** Get a string describing the short key (differentiating two objects at the same level). */ Modified: trunk/stdair/stdair/command/CmdBomManager.cpp =================================================================== --- trunk/stdair/stdair/command/CmdBomManager.cpp 2010-02-18 10:19:27 UTC (rev 153) +++ trunk/stdair/stdair/command/CmdBomManager.cpp 2010-02-18 15:42:34 UTC (rev 154) @@ -15,6 +15,7 @@ // Network: child of BomRoot, needed for creation of BomRoot #include <stdair/bom/Network.hpp> #include <stdair/bom/FlightDate.hpp> +#include <stdair/bom/BomManager.hpp> #include <stdair/factory/FacSupervisor.hpp> #include <stdair/factory/FacBomContent.hpp> #include <stdair/command/CmdBomManager.hpp> @@ -27,7 +28,6 @@ // Initialise the set of required airline features AirlineFeatureSet& lAirlineFeatureSet = FacBomContent::instance().create<AirlineFeatureSet>(); - // Set the AirlineFeatureSet for the BomRoot. ioBomRoot.setAirlineFeatureSet (&lAirlineFeatureSet); } @@ -40,10 +40,10 @@ AirlineFeatureKey_T lAirlineFeatureKey (iAirlineCode); AirlineFeature& lAirlineFeature = FacBomContent:: instance().create<AirlineFeature> (lAirlineFeatureKey); - + // Retrieve the AirlineFeatureSet object AirlineFeatureSet& lAirlineFeatureSet = ioBomRoot.getAirlineFeatureSet(); - + // Add the AirlineFeature object to its AirlineFeatureSet parent FacBomContent::linkWithParent<AirlineFeature> (lAirlineFeature, lAirlineFeatureSet); Modified: trunk/stdair/stdair/factory/FacBomContent.hpp =================================================================== --- trunk/stdair/stdair/factory/FacBomContent.hpp 2010-02-18 10:19:27 UTC (rev 153) +++ trunk/stdair/stdair/factory/FacBomContent.hpp 2010-02-18 15:42:34 UTC (rev 154) @@ -92,7 +92,7 @@ lBomStructureChild); if (hasLinkBeenSuccessful == false) { - throw new MemoryAllocationException(); + throw ObjectLinkingException(); } } Modified: trunk/stdair/stdair/factory/FacBomStructure.hpp =================================================================== --- trunk/stdair/stdair/factory/FacBomStructure.hpp 2010-02-18 10:19:27 UTC (rev 153) +++ trunk/stdair/stdair/factory/FacBomStructure.hpp 2010-02-18 15:42:34 UTC (rev 154) @@ -122,10 +122,12 @@ // Insert the structure object in the dedicated lists typedef typename BOM_HOLDER_T::BomChildrenMap_T BOM_MAP_T; + const bool hasInsertBeenSuccessful = ioBomHolder._bomChildrenMap. insert (typename BOM_MAP_T::value_type (lBomKeyStr, &ioBomStructure)).second; + if (hasInsertBeenSuccessful == false) { return hasInsertBeenSuccessful; } @@ -602,6 +604,10 @@ assert (ioOutboundPathStructure._segmentDateHolder != NULL); bool addingSucceeded = addFullBomObjectToBomHolder<SEGMENT_DATE_T> (*ioOutboundPathStructure._segmentDateHolder, ioSegmentDateStructure); + if (addingSucceeded == false) { + STDAIR_LOG_DEBUG ("Cannot add SegmentDate: " + << ioSegmentDateStructure._content->describeKey()); + } assert (addingSucceeded == true); } // ////////////////////////////////////////////////////////////////// This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qua...@us...> - 2010-03-10 16:30:35
|
Revision: 159 http://stdair.svn.sourceforge.net/stdair/?rev=159&view=rev Author: quannaus Date: 2010-03-10 16:30:22 +0000 (Wed, 10 Mar 2010) Log Message: ----------- [dev] Added the lite version of ContinuousAttribute and CategoricalAttribute. Modified Paths: -------------- trunk/stdair/stdair/STDAIR_Types.hpp trunk/stdair/stdair/basic/CategoricalAttribute.hpp trunk/stdair/stdair/basic/ContinuousAttribute.hpp trunk/stdair/stdair/basic/DemandCharacteristicTypes.hpp trunk/stdair/stdair/basic/DemandCharacteristics.cpp trunk/stdair/stdair/basic/DemandCharacteristics.hpp trunk/stdair/stdair/basic/sources.mk trunk/stdair/stdair/bom/BomChildrenHolderImp.hpp trunk/stdair/stdair/bom/DemandStream.cpp trunk/stdair/stdair/bom/DemandStream.hpp trunk/stdair/stdair/bom/DemandStreamContent.cpp trunk/stdair/stdair/bom/DemandStreamContent.hpp trunk/stdair/stdair/factory/FacBomContent.hpp Added Paths: ----------- trunk/stdair/stdair/basic/CategoricalAttributeLite.hpp trunk/stdair/stdair/basic/ContinuousAttributeLite.hpp trunk/stdair/stdair/basic/DictionaryManager.cpp trunk/stdair/stdair/basic/DictionaryManager.hpp Modified: trunk/stdair/stdair/STDAIR_Types.hpp =================================================================== --- trunk/stdair/stdair/STDAIR_Types.hpp 2010-02-18 19:57:17 UTC (rev 158) +++ trunk/stdair/stdair/STDAIR_Types.hpp 2010-03-10 16:30:22 UTC (rev 159) @@ -417,6 +417,9 @@ /** Probability */ typedef float Probability_T; + /** Dictionary key. */ + typedef unsigned char DictionaryKey_T; + // ////////////////////////////////////////////////////////////////////// // Date / Time /** Time duration in (integer) number of seconds */ Modified: trunk/stdair/stdair/basic/CategoricalAttribute.hpp =================================================================== --- trunk/stdair/stdair/basic/CategoricalAttribute.hpp 2010-02-18 19:57:17 UTC (rev 158) +++ trunk/stdair/stdair/basic/CategoricalAttribute.hpp 2010-03-10 16:30:22 UTC (rev 159) @@ -9,6 +9,7 @@ #include <iosfwd> // STDAIR #include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/DictionaryManager.hpp> namespace stdair { @@ -19,15 +20,15 @@ public: /** Define the probability mass function type. */ - typedef std::map<T, Probability_T> ProbabilityMassFunction_T; + typedef std::map<T, DictionaryKey_T> ProbabilityMassFunction_T; /** Define the inverse cumulative distribution type. */ - typedef std::map<Probability_T, T> InverseCumulativeDistribution_T; + typedef std::map<DictionaryKey_T, T> InverseCumulativeDistribution_T; - public: + private: // ///////////// Getters /////////// /** Get the probability mass function. */ - const std::map<T,Probability_T>& getProbabilityMassFunction() const { + const ProbabilityMassFunction_T& getProbabilityMassFunction() const { return _probabilityMassFunction; } @@ -47,8 +48,10 @@ // /////////////// Business Methods ////////// /** Get value from inverse cumulative distribution. */ const T getValue (Probability_T iCumulativeProbability) const { + const DictionaryKey_T lKey = + DictionaryManager::valueToKey (iCumulativeProbability); return _inverseCumulativeDistribution. - lower_bound (iCumulativeProbability)->second; + lower_bound (lKey)->second; } public: @@ -64,7 +67,8 @@ if (idx != 0) { oStr << ", "; } - oStr << it->first << ":" << it->second; + oStr << it->first << ":" + << DictionaryManager::keyToValue (it->second); } return oStr.str(); @@ -77,7 +81,7 @@ for (typename InverseCumulativeDistribution_T::const_iterator it = _inverseCumulativeDistribution.begin(); it != _inverseCumulativeDistribution.end(); ++it) { - oStr << "cumulative prob: " << it->first + oStr << "cumulative prob: " << DictionaryManager::keyToValue (it->first) << " value: " << it->second << std::endl; } @@ -108,11 +112,15 @@ for (typename ProbabilityMassFunction_T::const_iterator itProbabilityMassFunction = _probabilityMassFunction.begin(); itProbabilityMassFunction != _probabilityMassFunction.end(); ++itProbabilityMassFunction) { - Probability_T attribute_probability_mass = itProbabilityMassFunction->second; + Probability_T attribute_probability_mass = + DictionaryManager::keyToValue (itProbabilityMassFunction->second); if (attribute_probability_mass > 0) { T attribute_value = itProbabilityMassFunction->first; cumulative_probability_so_far += attribute_probability_mass; - _inverseCumulativeDistribution[cumulative_probability_so_far] = attribute_value; + DictionaryKey_T lKey = + DictionaryManager::valueToKey (cumulative_probability_so_far); + //_inverseCumulativeDistribution[lKey] = attribute_value; + _inverseCumulativeDistribution.insert (typename InverseCumulativeDistribution_T::value_type (lKey, attribute_value)); } } } Copied: trunk/stdair/stdair/basic/CategoricalAttributeLite.hpp (from rev 158, trunk/stdair/stdair/basic/CategoricalAttribute.hpp) =================================================================== --- trunk/stdair/stdair/basic/CategoricalAttributeLite.hpp (rev 0) +++ trunk/stdair/stdair/basic/CategoricalAttributeLite.hpp 2010-03-10 16:30:22 UTC (rev 159) @@ -0,0 +1,122 @@ +#ifndef __STDAIR_BAS_CATEGORICALATTRIBUTELITE_HPP +#define __STDAIR_BAS_CATEGORICALATTRIBUTELITE_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <map> +#include <iosfwd> +// STDAIR +#include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/DictionaryManager.hpp> +#include <stdair/service/Logger.hpp> + +namespace stdair { + + /** Class modeling the distribution of values that can be taken by a + categorical attribute. */ + template <class T> + struct CategoricalAttributeLite { + public: + /** Define the probability mass function type. */ + typedef std::map<T, Probability_T> ProbabilityMassFunction_T; + + public: + // /////////////// Business Methods ////////// + /** Get value from inverse cumulative distribution. */ + const T getValue (Probability_T iCumulativeProbability) const { + const DictionaryKey_T lKey = + DictionaryManager::valueToKey (iCumulativeProbability); + + for (unsigned int idx = 0; idx < _size; ++idx) { + if (_cumulativeDistribution[idx] >= lKey) { + return _valueArray[idx]; + } + } + + STDAIR_LOG_ERROR ("The following cumulative probability " + << "is out of range: " << iCumulativeProbability); + assert (false); + T t; + return t; + } + + public: + // ////////////// Display Support Methods ////////// + /** Display probability mass function. */ + const std::string displayProbabilityMass () const { + std::ostringstream oStr; + + for (unsigned int idx = 0; idx < _size; ++idx) { + if (idx != 0) { + oStr << ", "; + } + oStr << _valueArray [idx] << ":" + << DictionaryManager::keyToValue (_cumulativeDistribution[idx]); + } + return oStr.str(); + } + + public: + // ////////// Constructors and destructors ///////// + /** Constructor by default */ + CategoricalAttributeLite (const ProbabilityMassFunction_T& iValueMap) + : _size (iValueMap.size()) { + _cumulativeDistribution = new DictionaryKey_T[_size]; + _valueArray = new T[_size]; + init (iValueMap); + } + /** Destructor */ + virtual ~CategoricalAttributeLite () { + // TODO: Verify that the arrays are correctly cleaned. + delete _cumulativeDistribution; _cumulativeDistribution = NULL; + delete _valueArray; _valueArray = NULL; + } + + private: + /** Default constructors. */ + CategoricalAttributeLite (); + CategoricalAttributeLite (const CategoricalAttributeLite&); + + + /** Initialise the two arrays from the given map. */ + void init (const ProbabilityMassFunction_T& iValueMap) { + + Probability_T cumulative_probability_so_far = 0.0; + unsigned int idx = 0; + + // Browse the map to retrieve the values and to build the + // cumulative probabilities. + for (typename ProbabilityMassFunction_T::const_iterator itProbabilityMassFunction = iValueMap.begin(); + itProbabilityMassFunction != iValueMap.end(); + ++itProbabilityMassFunction, ++idx) { + + Probability_T attribute_probability_mass = + itProbabilityMassFunction->second; + if (attribute_probability_mass > 0) { + T attribute_value = itProbabilityMassFunction->first; + cumulative_probability_so_far += attribute_probability_mass; + DictionaryKey_T lKey = + DictionaryManager::valueToKey (cumulative_probability_so_far); + + // Build the two arrays. + _cumulativeDistribution[idx] = lKey; + _valueArray[idx] = attribute_value; + } + } + } + + private: + // ////////// Attributes ////////// + /** Size of the two arrays. */ + const unsigned int _size; + + /** Cumulative dictionary-coded distribution. */ + DictionaryKey_T* _cumulativeDistribution; + + /** The corresponding values. */ + T* _valueArray; + }; +} +#endif // __STDAIR_BAS_CATEGORICALATTRIBUTELITE_HPP Modified: trunk/stdair/stdair/basic/ContinuousAttribute.hpp =================================================================== --- trunk/stdair/stdair/basic/ContinuousAttribute.hpp 2010-02-18 19:57:17 UTC (rev 158) +++ trunk/stdair/stdair/basic/ContinuousAttribute.hpp 2010-03-10 16:30:22 UTC (rev 159) @@ -9,6 +9,7 @@ #include <map> // STDAIR #include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/DictionaryManager.hpp> #include <stdair/service/Logger.hpp> namespace stdair { @@ -21,10 +22,10 @@ // ///////////// Type definitions ////////////// /** */ - typedef std::multimap<T, Probability_T> ContinuousDistribution_T; - typedef std::multimap<Probability_T, T> ContinuousInverseDistribution_T; - - + typedef std::multimap<T, DictionaryKey_T> ContinuousDistribution_T; + typedef std::multimap<DictionaryKey_T, T> ContinuousInverseDistribution_T; + + private: // ///////////// Getters /////////// /** Get the cumulative distribution. */ const ContinuousDistribution_T& getCumulativeDistribution() const { @@ -36,7 +37,7 @@ return _inverseCumulativeDistribution; } - public: + private: // ///////////// Setters /////////// /** Set the cumulative distribution */ void setCumulativeDistribution (const ContinuousDistribution_T& iCumulativeDistribution) { @@ -48,10 +49,13 @@ // /////////////// Business Methods ////////// /** Get value from inverse cumulative distribution. */ const T getValue (const Probability_T& iCumulativeProbability) const { + const DictionaryKey_T lKey = + DictionaryManager::valueToKey (iCumulativeProbability); typename ContinuousInverseDistribution_T::const_iterator it = - _inverseCumulativeDistribution.lower_bound (iCumulativeProbability); + _inverseCumulativeDistribution.lower_bound (lKey); - Probability_T cumulativeProbabilityNextPoint = it->first; + Probability_T cumulativeProbabilityNextPoint = + DictionaryManager::keyToValue (it->first); T valueNextPoint = it->second; if (it == _inverseCumulativeDistribution.begin()) { @@ -60,7 +64,8 @@ } --it; - Probability_T cumulativeProbabilityPreviousPoint = it->first; + Probability_T cumulativeProbabilityPreviousPoint = + DictionaryManager::keyToValue (it->first); T valuePreviousPoint = it->second; if (cumulativeProbabilityNextPoint == cumulativeProbabilityPreviousPoint) { return valuePreviousPoint; @@ -83,7 +88,8 @@ if (idx != 0) { oStr << ", "; } - oStr << it->first << ":" << it->second; + oStr << it->first << ":" + << DictionaryManager::keyToValue (it->second); } return oStr.str(); } @@ -94,7 +100,7 @@ for (typename ContinuousInverseDistribution_T::const_iterator it = _inverseCumulativeDistribution.begin(); it != _inverseCumulativeDistribution.end(); ++it) { - oStr << "cumulative prob: " << it->first + oStr << "cumulative prob: " << DictionaryManager::keyToValue (it->first) << " value: " << it->second << std::endl; } return oStr.str(); Copied: trunk/stdair/stdair/basic/ContinuousAttributeLite.hpp (from rev 158, trunk/stdair/stdair/basic/ContinuousAttribute.hpp) =================================================================== --- trunk/stdair/stdair/basic/ContinuousAttributeLite.hpp (rev 0) +++ trunk/stdair/stdair/basic/ContinuousAttributeLite.hpp 2010-03-10 16:30:22 UTC (rev 159) @@ -0,0 +1,129 @@ +#ifndef __STDAIR_BAS_CONTINUOUSATTRIBUTELITE_HPP +#define __STDAIR_BAS_CONTINUOUSATTRIBUTELITE_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <string> +#include <map> +// STDAIR +#include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/DictionaryManager.hpp> +#include <stdair/service/Logger.hpp> + +namespace stdair { + + /** Class modeling the distribution of values that can be taken by a + continuous attribute. */ + template <class T> + struct ContinuousAttributeLite { + public: + // ///////////// Type definitions ////////////// + typedef std::multimap<T, Probability_T> ContinuousDistribution_T; + + public: + // /////////////// Business Methods ////////// + /** Get value from inverse cumulative distribution. */ + const T getValue (const Probability_T& iCumulativeProbability) const { + const DictionaryKey_T lKey = + DictionaryManager::valueToKey (iCumulativeProbability); + unsigned int idx = 0; + + // Find the first cumulative probablity value greater or equal to lKey. + for (; idx < _size; ++idx) { + if (_cumulativeDistribution[idx] >= lKey) { + break; + } + } + + if (idx == 0) { + return _valueArray[idx]; + } + + Probability_T lCumulativeCurrentPoint = + DictionaryManager::keyToValue (_cumulativeDistribution[idx]); + Probability_T lCumulativePreviousPoint = + DictionaryManager::keyToValue (_cumulativeDistribution[idx-1]); + T lValueCurrentPoint = _valueArray[idx]; + T lValuePreviousPoint = _valueArray[idx-1]; + + if (lCumulativePreviousPoint == lCumulativeCurrentPoint) { + return lValuePreviousPoint; + } + + return lValuePreviousPoint + (lValueCurrentPoint - lValuePreviousPoint) + * (iCumulativeProbability - lCumulativePreviousPoint) + / (lCumulativeCurrentPoint - lCumulativePreviousPoint); + } + + public: + // ////////////// Display Support Methods ////////// + /** Display cumulative distribution */ + const std::string displayCumulativeDistribution() const { + std::ostringstream oStr; + + for (unsigned int idx = 0; idx < _size; ++idx) { + if (idx != 0) { + oStr << ", "; + } + oStr << _valueArray[idx] << ":" + << DictionaryManager::keyToValue (_cumulativeDistribution[idx]); + } + return oStr.str(); + } + + public: + // ////////// Constructors and destructors ///////// + /** Constructor */ + ContinuousAttributeLite (const ContinuousDistribution_T& iValueMap) + : _size (iValueMap.size()) { + _cumulativeDistribution = new DictionaryKey_T[_size]; + _valueArray = new T[_size]; + init (iValueMap); + } + + /** Destructor */ + virtual ~ContinuousAttributeLite () { + // TODO: Verify that the arrays are correctly cleaned. + delete _cumulativeDistribution; _cumulativeDistribution = NULL; + delete _valueArray; _valueArray = NULL; + } + + private: + /** Constructors by default */ + ContinuousAttributeLite (); + ContinuousAttributeLite (const ContinuousAttributeLite&); + + /** Determine inverse cumulative distribution from cumulative + distribution (initialisation). */ + void init (const ContinuousDistribution_T& iValueMap) { + unsigned int idx = 0; + + // Browse the map to retrieve the values and cumulative probabilities. + for (typename ContinuousDistribution_T::const_iterator it = + iValueMap.begin(); it != iValueMap.end(); ++it, ++idx) { + + T attributeValue = it->first; + DictionaryKey_T lKey = DictionaryManager::valueToKey (it->second); + + // Build the two arrays. + _cumulativeDistribution[idx] = lKey; + _valueArray[idx] = attributeValue; + } + } + + private: + // ////////// Attributes ////////// + /** Size of the two arrays. */ + const unsigned int _size; + + /** Cumulative dictionary-coded distribution. */ + DictionaryKey_T* _cumulativeDistribution; + + /** The corresponding values. */ + T* _valueArray; + }; + +} +#endif // __STDAIR_BAS_CONTINUOUSATTRIBUTELITE_HPP Modified: trunk/stdair/stdair/basic/DemandCharacteristicTypes.hpp =================================================================== --- trunk/stdair/stdair/basic/DemandCharacteristicTypes.hpp 2010-02-18 19:57:17 UTC (rev 158) +++ trunk/stdair/stdair/basic/DemandCharacteristicTypes.hpp 2010-03-10 16:30:22 UTC (rev 159) @@ -6,95 +6,64 @@ // ////////////////////////////////////////////////////////////////////// // StdAir #include <stdair/STDAIR_Types.hpp> -#include <stdair/basic/ContinuousAttribute.hpp> -#include <stdair/basic/CategoricalAttribute.hpp> +#include <stdair/basic/ContinuousAttributeLite.hpp> +#include <stdair/basic/CategoricalAttributeLite.hpp> namespace stdair { /** Type definition for the continuous distribition of the duration (as a float number). */ - typedef ContinuousAttribute<FloatDuration_T> ContinuousFloatDuration_T; + typedef ContinuousAttributeLite<FloatDuration_T> ContinuousFloatDuration_T; - /** Type definition for the arrival pattern. */ - typedef ContinuousFloatDuration_T::ContinuousDistribution_T ArrivalPattern_T; - /** Type definition for the arrival pattern cumulative distribution. */ - typedef std::multimap<FloatDuration_T, Probability_T> ArrivalPatternCumulativeDistribution_T; + typedef ContinuousFloatDuration_T::ContinuousDistribution_T ArrivalPatternCumulativeDistribution_T; - /** Type definition for the arrival pattern inverse cumulative distribution. */ - typedef std::multimap<Probability_T, FloatDuration_T> ArrivalPatternInverseCumulativeDistribution_T; - /** Define the point-of-sale probablity mass. */ - typedef CategoricalAttribute<AirportCode_T> POSProbabilityMass_T; + typedef CategoricalAttributeLite<AirportCode_T> POSProbabilityMass_T; /** Define the probability mass function type of point-of-sale. */ typedef POSProbabilityMass_T::ProbabilityMassFunction_T POSProbabilityMassFunction_T; - - /** Define the inverse cumulative distribution of point-of-sale. */ - typedef POSProbabilityMass_T::InverseCumulativeDistribution_T POSInverserCumulativeDistribution_T; /** Define the booking channel probablity mass. */ - typedef CategoricalAttribute<ChannelLabel_T> ChannelProbabilityMass_T; + typedef CategoricalAttributeLite<ChannelLabel_T> ChannelProbabilityMass_T; /** Define the probability mass function type of booking channel. */ typedef ChannelProbabilityMass_T::ProbabilityMassFunction_T ChannelProbabilityMassFunction_T; - /** Define the inverse cumulative distribution of channel. */ - typedef ChannelProbabilityMass_T::InverseCumulativeDistribution_T ChannelInverserCumulativeDistribution_T; - /** Define the trip type probablity mass. */ - typedef CategoricalAttribute<TripType_T> TripTypeProbabilityMass_T; + typedef CategoricalAttributeLite<TripType_T> TripTypeProbabilityMass_T; /** Define the probability mass function type of trip type. */ typedef TripTypeProbabilityMass_T::ProbabilityMassFunction_T TripTypeProbabilityMassFunction_T; - - /** Define the inverse cumulative distribution of trip type. */ - typedef TripTypeProbabilityMass_T::InverseCumulativeDistribution_T TripTypeInverserCumulativeDistribution_T; /** Define the stay duration probablity mass. */ - typedef CategoricalAttribute<DayDuration_T> StayDurationProbabilityMass_T; + typedef CategoricalAttributeLite<DayDuration_T> StayDurationProbabilityMass_T; /** Define the probability mass function type of stay duration. */ typedef StayDurationProbabilityMass_T::ProbabilityMassFunction_T StayDurationProbabilityMassFunction_T; - /** Define the inverse cumulative distribution of stay duration. */ - typedef StayDurationProbabilityMass_T::InverseCumulativeDistribution_T StayDurationInverserCumulativeDistribution_T; - /** Define the frequent flyer probablity mass. */ - typedef CategoricalAttribute<FrequentFlyer_T> FrequentFlyerProbabilityMass_T; + typedef CategoricalAttributeLite<FrequentFlyer_T> FrequentFlyerProbabilityMass_T; /** Define the probability mass function type of frequent flyer. */ typedef FrequentFlyerProbabilityMass_T::ProbabilityMassFunction_T FrequentFlyerProbabilityMassFunction_T; - /** Define the inverse cumulative distribution of frequent flyer. */ - typedef FrequentFlyerProbabilityMass_T::InverseCumulativeDistribution_T FrequentFlyerInverserCumulativeDistribution_T; - /** Define the preferred departure time cumulative distribution. */ - typedef ContinuousAttribute<IntDuration_T> PreferredDepartureTimeCumulativeDistribution_T; + typedef ContinuousAttributeLite<IntDuration_T> PreferredDepartureTimeCumulativeDistribution_T; /** Define the preferred departure time continuous distribution. */ typedef PreferredDepartureTimeCumulativeDistribution_T::ContinuousDistribution_T PreferredDepartureTimeContinuousDistribution_T; - /** Define the preferred departure time continuous inverse distribution. */ - typedef PreferredDepartureTimeCumulativeDistribution_T::ContinuousInverseDistribution_T PreferredDepartureTimeContinuousInverseDistribution_T; - /** Define the willingness-to-pay cumulative distribution. */ - typedef ContinuousAttribute<WTP_T> WTPCumulativeDistribution_T; + typedef ContinuousAttributeLite<WTP_T> WTPCumulativeDistribution_T; /** Define the willingness-to-pay continuous distribution. */ typedef WTPCumulativeDistribution_T::ContinuousDistribution_T WTPContinuousDistribution_T; - /** Define the willingness-to-pay continuous inverse distribution. */ - typedef WTPCumulativeDistribution_T::ContinuousInverseDistribution_T WTPContinuousInverseDistribution_T; - /** Define the value of time cumulative distribution. */ - typedef ContinuousAttribute<PriceValue_T> ValueOfTimeCumulativeDistribution_T; + typedef ContinuousAttributeLite<PriceValue_T> ValueOfTimeCumulativeDistribution_T; /** Define the value of time continuous distribution. */ typedef ValueOfTimeCumulativeDistribution_T::ContinuousDistribution_T ValueOfTimeContinuousDistribution_T; - - /** Define the value of time continuous inverse distribution. */ - typedef ValueOfTimeCumulativeDistribution_T::ContinuousInverseDistribution_T ValueOfTimeContinuousInverseDistribution_T; - } #endif // __STDAIR_BAS_DEMANDCHARACTERISTICTYPES_HPP Modified: trunk/stdair/stdair/basic/DemandCharacteristics.cpp =================================================================== --- trunk/stdair/stdair/basic/DemandCharacteristics.cpp 2010-02-18 19:57:17 UTC (rev 158) +++ trunk/stdair/stdair/basic/DemandCharacteristics.cpp 2010-03-10 16:30:22 UTC (rev 159) @@ -14,51 +14,31 @@ // ///////////////////////////////////////////////////// DemandCharacteristics:: DemandCharacteristics (const DemandStreamKey_T& iKey, - const ContinuousFloatDuration_T& iArrivalPattern, - const POSProbabilityMass_T& iPOSProbMass, - const ChannelProbabilityMass_T& iChannelProbMass, - const TripTypeProbabilityMass_T& iTripTypeProbMass, - const StayDurationProbabilityMass_T& iStayDurationProbMass, - const FrequentFlyerProbabilityMass_T& iFrequentFlyerProbMass, - const PreferredDepartureTimeCumulativeDistribution_T& iPreferredDepartureTimeCumulativeDistribution, - const WTPCumulativeDistribution_T& iWTPCumulativeDistribution, - const ValueOfTimeCumulativeDistribution_T& iValueOfTimeCumulativeDistribution) + const ArrivalPatternCumulativeDistribution_T& iArrivalPattern, + const POSProbabilityMassFunction_T& iPOSProbMass, + const ChannelProbabilityMassFunction_T& iChannelProbMass, + const TripTypeProbabilityMassFunction_T& iTripTypeProbMass, + const StayDurationProbabilityMassFunction_T& iStayDurationProbMass, + const FrequentFlyerProbabilityMassFunction_T& iFrequentFlyerProbMass, + const PreferredDepartureTimeContinuousDistribution_T& iPreferredDepartureTimeContinuousDistribution, + const WTPContinuousDistribution_T& iWTPContinuousDistribution, + const ValueOfTimeContinuousDistribution_T& iValueOfTimeContinuousDistribution) : _key (iKey), _arrivalPattern (iArrivalPattern), _posProbabilityMass (iPOSProbMass), _channelProbabilityMass (iChannelProbMass), _tripTypeProbabilityMass (iTripTypeProbMass), _stayDurationProbabilityMass (iStayDurationProbMass), _frequentFlyerProbabilityMass (iFrequentFlyerProbMass), - _preferredDepartureTimeCumulativeDistribution (iPreferredDepartureTimeCumulativeDistribution), - _wtpCumulativeDistribution (iWTPCumulativeDistribution), - _valueOfTimeCumulativeDistribution (iValueOfTimeCumulativeDistribution) { + _preferredDepartureTimeCumulativeDistribution (iPreferredDepartureTimeContinuousDistribution), + _wtpCumulativeDistribution (iWTPContinuousDistribution), + _valueOfTimeCumulativeDistribution (iValueOfTimeContinuousDistribution) { } - + // ///////////////////////////////////////////////////// - DemandCharacteristics::DemandCharacteristics () - : _key (DemandStreamKey_T ("", "", DEFAULT_DATE, "")) { - } - - // ///////////////////////////////////////////////////// DemandCharacteristics::~DemandCharacteristics () { } // ///////////////////////////////////////////////////// - DemandCharacteristics:: - DemandCharacteristics (const DemandCharacteristics& iDemandCharacteristics) - : _key (iDemandCharacteristics._key), - _arrivalPattern (iDemandCharacteristics._arrivalPattern), - _posProbabilityMass (iDemandCharacteristics._posProbabilityMass), - _channelProbabilityMass (iDemandCharacteristics._channelProbabilityMass), - _tripTypeProbabilityMass (iDemandCharacteristics._tripTypeProbabilityMass), - _stayDurationProbabilityMass (iDemandCharacteristics._stayDurationProbabilityMass), - _frequentFlyerProbabilityMass (iDemandCharacteristics._frequentFlyerProbabilityMass), - _preferredDepartureTimeCumulativeDistribution (iDemandCharacteristics._preferredDepartureTimeCumulativeDistribution), - _wtpCumulativeDistribution (iDemandCharacteristics._wtpCumulativeDistribution), - _valueOfTimeCumulativeDistribution (iDemandCharacteristics._valueOfTimeCumulativeDistribution) { - } - - // ///////////////////////////////////////////////////// const AirportCode_T& DemandCharacteristics::getOrigin() const { return _key.getOrigin(); } @@ -96,19 +76,19 @@ oStr << "Arrival pattern (days from departure, proportion): "; oStr << _arrivalPattern.displayCumulativeDistribution() << std::endl; oStr << "POS probability mass (POS, propotion): "; - oStr << _posProbabilityMass.displayProbabilityMassFunction() + oStr << _posProbabilityMass.displayProbabilityMass() << std::endl; oStr << "Channel probability mass (channel, propotion): "; - oStr << _channelProbabilityMass.displayProbabilityMassFunction() + oStr << _channelProbabilityMass.displayProbabilityMass() << std::endl; oStr << "Trip type probability mass (trip type, propotion): "; - oStr << _tripTypeProbabilityMass.displayProbabilityMassFunction() + oStr << _tripTypeProbabilityMass.displayProbabilityMass() << std::endl; oStr << "Stay duration probability mass (number of days, propotion): "; - oStr << _stayDurationProbabilityMass.displayProbabilityMassFunction() + oStr << _stayDurationProbabilityMass.displayProbabilityMass() << std::endl; oStr << "Frequent flyer probability mass (frequent flyer, propotion): "; - oStr << _frequentFlyerProbabilityMass.displayProbabilityMassFunction() + oStr << _frequentFlyerProbabilityMass.displayProbabilityMass() << std::endl; oStr << "Preferred departure time cumulative distribution (time, proportion: "; oStr << _preferredDepartureTimeCumulativeDistribution.displayCumulativeDistribution() << std::endl; Modified: trunk/stdair/stdair/basic/DemandCharacteristics.hpp =================================================================== --- trunk/stdair/stdair/basic/DemandCharacteristics.hpp 2010-02-18 19:57:17 UTC (rev 158) +++ trunk/stdair/stdair/basic/DemandCharacteristics.hpp 2010-03-10 16:30:22 UTC (rev 159) @@ -90,28 +90,25 @@ // ////////// Constructors and destructors ///////// /** Default constructor. */ DemandCharacteristics (const DemandStreamKey_T&, - const ContinuousFloatDuration_T&, - const POSProbabilityMass_T&, - const ChannelProbabilityMass_T&, - const TripTypeProbabilityMass_T&, - const StayDurationProbabilityMass_T&, - const FrequentFlyerProbabilityMass_T&, - const PreferredDepartureTimeCumulativeDistribution_T&, - const WTPCumulativeDistribution_T&, - const ValueOfTimeCumulativeDistribution_T&); + const ArrivalPatternCumulativeDistribution_T&, + const POSProbabilityMassFunction_T&, + const ChannelProbabilityMassFunction_T&, + const TripTypeProbabilityMassFunction_T&, + const StayDurationProbabilityMassFunction_T&, + const FrequentFlyerProbabilityMassFunction_T&, + const PreferredDepartureTimeContinuousDistribution_T&, + const WTPContinuousDistribution_T&, + const ValueOfTimeContinuousDistribution_T&); + /** Destructor */ + virtual ~DemandCharacteristics (); + + private: /** Default constructor. */ - // TODO: That copy constructor should be private DemandCharacteristics (); - /** Copy constructor. */ - // TODO: That copy constructor should be private DemandCharacteristics (const DemandCharacteristics&); - /** Destructor */ - virtual ~DemandCharacteristics (); - - private: // //////////////////// Attributes ///////////////////// /** DemandStream Key */ Added: trunk/stdair/stdair/basic/DictionaryManager.cpp =================================================================== --- trunk/stdair/stdair/basic/DictionaryManager.cpp (rev 0) +++ trunk/stdair/stdair/basic/DictionaryManager.cpp 2010-03-10 16:30:22 UTC (rev 159) @@ -0,0 +1,21 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STDAIR +#include <stdair/basic/DictionaryManager.hpp> + +namespace stdair { + // //////////////////////////////////////////////////////////////////// + const Probability_T DictionaryManager::keyToValue(const DictionaryKey_T iKey) { + return static_cast<Probability_T>(iKey) / 200; + } + + // //////////////////////////////////////////////////////////////////// + const DictionaryKey_T DictionaryManager:: + valueToKey (const Probability_T iValue) { + return iValue * 200; + } + + // DEBUG + unsigned int COUNT = 0; +} Added: trunk/stdair/stdair/basic/DictionaryManager.hpp =================================================================== --- trunk/stdair/stdair/basic/DictionaryManager.hpp (rev 0) +++ trunk/stdair/stdair/basic/DictionaryManager.hpp 2010-03-10 16:30:22 UTC (rev 159) @@ -0,0 +1,25 @@ +// ////////////////////////////////////////////////////////////////////// +#ifndef __STDAIR_BOM_DICTIONARYMANAGER_HPP +#define __STDAIR_BOM_DICTIONARYMANAGER_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STDAIR +#include <stdair/STDAIR_Types.hpp> + +namespace stdair { + + /** Class wrapper of dictionary business methods. */ + class DictionaryManager { + public: + // //////////// Business methods ///////////////// + /** Convert from key to value. */ + static const Probability_T keyToValue (const DictionaryKey_T); + + /** Convert from value to key. */ + static const DictionaryKey_T valueToKey (const Probability_T); + + }; +} +#endif // __STDAIR_BOM_DICTIONARYMANAGER_HPP Modified: trunk/stdair/stdair/basic/sources.mk =================================================================== --- trunk/stdair/stdair/basic/sources.mk 2010-02-18 19:57:17 UTC (rev 158) +++ trunk/stdair/stdair/basic/sources.mk 2010-03-10 16:30:22 UTC (rev 159) @@ -16,11 +16,14 @@ $(top_srcdir)/stdair/basic/PassengerType.hpp \ $(top_srcdir)/stdair/basic/ContinuousAttribute.hpp \ $(top_srcdir)/stdair/basic/CategoricalAttribute.hpp \ + $(top_srcdir)/stdair/basic/ContinuousAttributeLite.hpp \ + $(top_srcdir)/stdair/basic/CategoricalAttributeLite.hpp \ $(top_srcdir)/stdair/basic/DemandCharacteristicTypes.hpp \ $(top_srcdir)/stdair/basic/DemandCharacteristics.hpp \ $(top_srcdir)/stdair/basic/DemandDistribution.hpp \ $(top_srcdir)/stdair/basic/RandomGeneration.hpp \ - $(top_srcdir)/stdair/basic/RandomGenerationContext.hpp + $(top_srcdir)/stdair/basic/RandomGenerationContext.hpp \ + $(top_srcdir)/stdair/basic/DictionaryManager.hpp bas_cc_sources = \ $(top_srcdir)/stdair/basic/BasConst.cpp \ $(top_srcdir)/stdair/basic/BasChronometer.cpp \ @@ -31,4 +34,5 @@ $(top_srcdir)/stdair/basic/DemandCharacteristics.cpp \ $(top_srcdir)/stdair/basic/DemandDistribution.cpp \ $(top_srcdir)/stdair/basic/RandomGeneration.cpp \ - $(top_srcdir)/stdair/basic/RandomGenerationContext.cpp + $(top_srcdir)/stdair/basic/RandomGenerationContext.cpp \ + $(top_srcdir)/stdair/basic/DictionaryManager.cpp Modified: trunk/stdair/stdair/bom/BomChildrenHolderImp.hpp =================================================================== --- trunk/stdair/stdair/bom/BomChildrenHolderImp.hpp 2010-02-18 19:57:17 UTC (rev 158) +++ trunk/stdair/stdair/bom/BomChildrenHolderImp.hpp 2010-03-10 16:30:22 UTC (rev 159) @@ -114,7 +114,7 @@ // /////////// Other operators ///////////// /** Get the size of the list. */ const unsigned int size () const { - return _bomChildrenList.size(); + return _bomChildrenMap.size(); } /** Retrieve, if existing, the bom corresponding to the given key. */ Modified: trunk/stdair/stdair/bom/DemandStream.cpp =================================================================== --- trunk/stdair/stdair/bom/DemandStream.cpp 2010-02-18 19:57:17 UTC (rev 158) +++ trunk/stdair/stdair/bom/DemandStream.cpp 2010-03-10 16:30:22 UTC (rev 159) @@ -24,13 +24,26 @@ // ////////////////////////////////////////////////////////////////////// DemandStream:: DemandStream (const DemandStreamKey_T& iKey, - const DemandCharacteristics& iDemandCharacteristics, + const ArrivalPatternCumulativeDistribution_T& iArrivalPattern, + const POSProbabilityMassFunction_T& iPOSProbMass, + const ChannelProbabilityMassFunction_T& iChannelProbMass, + const TripTypeProbabilityMassFunction_T& iTripTypeProbMass, + const StayDurationProbabilityMassFunction_T& iStayDurationProbMass, + const FrequentFlyerProbabilityMassFunction_T& iFrequentFlyerProbMass, + const PreferredDepartureTimeContinuousDistribution_T& iPreferredDepartureTimeContinuousDistribution, + const WTPContinuousDistribution_T& iWTPContinuousDistribution, + const ValueOfTimeContinuousDistribution_T& iValueOfTimeContinuousDistribution, const DemandDistribution& iDemandDistribution, const RandomSeed_T& iNumberOfRequestsSeed, const RandomSeed_T& iRequestDateTimeSeed, const RandomSeed_T& iDemandCharacteristicsSeed, BomStructure_T& ioDemandStreamStructure) - : DemandStreamContent (iKey, iDemandCharacteristics, + : DemandStreamContent (iKey, iArrivalPattern, iPOSProbMass, + iChannelProbMass, iTripTypeProbMass, + iStayDurationProbMass, iFrequentFlyerProbMass, + iPreferredDepartureTimeContinuousDistribution, + iWTPContinuousDistribution, + iValueOfTimeContinuousDistribution, iDemandDistribution, iNumberOfRequestsSeed, iRequestDateTimeSeed, iDemandCharacteristicsSeed), _demandStreamStructure (ioDemandStreamStructure) { Modified: trunk/stdair/stdair/bom/DemandStream.hpp =================================================================== --- trunk/stdair/stdair/bom/DemandStream.hpp 2010-02-18 19:57:17 UTC (rev 158) +++ trunk/stdair/stdair/bom/DemandStream.hpp 2010-03-10 16:30:22 UTC (rev 159) @@ -72,7 +72,16 @@ protected: // ////////// Constructors and destructors ///////// /** Constructor by default */ - DemandStream (const BomKey_T&, const DemandCharacteristics&, + DemandStream (const BomKey_T&, + const ArrivalPatternCumulativeDistribution_T&, + const POSProbabilityMassFunction_T&, + const ChannelProbabilityMassFunction_T&, + const TripTypeProbabilityMassFunction_T&, + const StayDurationProbabilityMassFunction_T&, + const FrequentFlyerProbabilityMassFunction_T&, + const PreferredDepartureTimeContinuousDistribution_T&, + const WTPContinuousDistribution_T&, + const ValueOfTimeContinuousDistribution_T&, const DemandDistribution&, const RandomSeed_T& iNumberOfRequestsSeed, const RandomSeed_T& iRequestDateTimeSeed, Modified: trunk/stdair/stdair/bom/DemandStreamContent.cpp =================================================================== --- trunk/stdair/stdair/bom/DemandStreamContent.cpp 2010-02-18 19:57:17 UTC (rev 158) +++ trunk/stdair/stdair/bom/DemandStreamContent.cpp 2010-03-10 16:30:22 UTC (rev 159) @@ -21,13 +21,26 @@ // ////////////////////////////////////////////////////////////////////// DemandStreamContent:: DemandStreamContent (const BomKey_T& iKey, - const DemandCharacteristics& iDemandCharacteristics, + const ArrivalPatternCumulativeDistribution_T& iArrivalPattern, + const POSProbabilityMassFunction_T& iPOSProbMass, + const ChannelProbabilityMassFunction_T& iChannelProbMass, + const TripTypeProbabilityMassFunction_T& iTripTypeProbMass, + const StayDurationProbabilityMassFunction_T& iStayDurationProbMass, + const FrequentFlyerProbabilityMassFunction_T& iFrequentFlyerProbMass, + const PreferredDepartureTimeContinuousDistribution_T& iPreferredDepartureTimeContinuousDistribution, + const WTPContinuousDistribution_T& iWTPContinuousDistribution, + const ValueOfTimeContinuousDistribution_T& iValueOfTimeContinuousDistribution, const DemandDistribution& iDemandDistribution, const RandomSeed_T& iNumberOfRequestsSeed, const RandomSeed_T& iRequestDateTimeSeed, const RandomSeed_T& iDemandCharacteristicsSeed) : _key (iKey), - _demandCharacteristics (iDemandCharacteristics), + _demandCharacteristics (iKey, iArrivalPattern, iPOSProbMass, + iChannelProbMass, iTripTypeProbMass, + iStayDurationProbMass, iFrequentFlyerProbMass, + iPreferredDepartureTimeContinuousDistribution, + iWTPContinuousDistribution, + iValueOfTimeContinuousDistribution), _demandDistribution (iDemandDistribution), _totalNumberOfRequestsToBeGenerated (0), _numberOfRequestsRandomGenerator (iNumberOfRequestsSeed), Modified: trunk/stdair/stdair/bom/DemandStreamContent.hpp =================================================================== --- trunk/stdair/stdair/bom/DemandStreamContent.hpp 2010-02-18 19:57:17 UTC (rev 158) +++ trunk/stdair/stdair/bom/DemandStreamContent.hpp 2010-03-10 16:30:22 UTC (rev 159) @@ -237,11 +237,20 @@ protected: // ////////// Constructors and destructors ///////// /** Constructor by default */ - DemandStreamContent (const BomKey_T&, const DemandCharacteristics&, - const DemandDistribution&, - const RandomSeed_T& iNumberOfRequestsSeed, - const RandomSeed_T& iRequestDateTimeSeed, - const RandomSeed_T& iDemandCharacteristicsSeed); + DemandStreamContent (const BomKey_T&, + const ArrivalPatternCumulativeDistribution_T&, + const POSProbabilityMassFunction_T&, + const ChannelProbabilityMassFunction_T&, + const TripTypeProbabilityMassFunction_T&, + const StayDurationProbabilityMassFunction_T&, + const FrequentFlyerProbabilityMassFunction_T&, + const PreferredDepartureTimeContinuousDistribution_T&, + const WTPContinuousDistribution_T&, + const ValueOfTimeContinuousDistribution_T&, + const DemandDistribution&, + const RandomSeed_T& iNumberOfRequestsSeed, + const RandomSeed_T& iRequestDateTimeSeed, + const RandomSeed_T& iDemandCharacteristicsSeed); /** Default constructors. */ DemandStreamContent (); DemandStreamContent (const DemandStreamContent&); Modified: trunk/stdair/stdair/factory/FacBomContent.hpp =================================================================== --- trunk/stdair/stdair/factory/FacBomContent.hpp 2010-02-18 19:57:17 UTC (rev 158) +++ trunk/stdair/stdair/factory/FacBomContent.hpp 2010-03-10 16:30:22 UTC (rev 159) @@ -11,6 +11,7 @@ // STDAIR #include <stdair/STDAIR_Types.hpp> #include <stdair/basic/BasConst_Inventory.hpp> +#include <stdair/basic/DemandCharacteristicTypes.hpp> #include <stdair/bom/BomStructure.hpp> #include <stdair/factory/FacBomStructure.hpp> @@ -202,7 +203,15 @@ // ////////////////////////////////////////////////////////////////// template <typename DEMAND_STREAM> DEMAND_STREAM& create (const DemandStreamKey_T& iKey, - const DemandCharacteristics& iDemandCharacteristics, + const ArrivalPatternCumulativeDistribution_T& iArrivalPattern, + const POSProbabilityMassFunction_T& iPOSProbMass, + const ChannelProbabilityMassFunction_T& iChannelProbMass, + const TripTypeProbabilityMassFunction_T& iTripTypeProbMass, + const StayDurationProbabilityMassFunction_T& iStayDurationProbMass, + const FrequentFlyerProbabilityMassFunction_T& iFrequentFlyerProbMass, + const PreferredDepartureTimeContinuousDistribution_T& iPreferredDepartureTimeContinuousDistribution, + const WTPContinuousDistribution_T& iWTPContinuousDistribution, + const ValueOfTimeContinuousDistribution_T& iValueOfTimeContinuousDistribution, const DemandDistribution& iDemandDistribution, const RandomSeed_T& iNumberOfRequestsSeed, const RandomSeed_T& iRequestDateTimeSeed, @@ -213,7 +222,13 @@ FacBomStructure::instance().create<DEMAND_STREAM_STRUCTURE_T> (); DEMAND_STREAM* aDemandStream_ptr = - new DEMAND_STREAM (iKey, iDemandCharacteristics, iDemandDistribution, + new DEMAND_STREAM (iKey, iArrivalPattern, iPOSProbMass, + iChannelProbMass, iTripTypeProbMass, + iStayDurationProbMass, iFrequentFlyerProbMass, + iPreferredDepartureTimeContinuousDistribution, + iWTPContinuousDistribution, + iValueOfTimeContinuousDistribution, + iDemandDistribution, iNumberOfRequestsSeed, iRequestDateTimeSeed, iDemandCharacteristicsSeed, lBomStructure); assert (aDemandStream_ptr != NULL); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qua...@us...> - 2010-03-11 09:07:39
|
Revision: 160 http://stdair.svn.sourceforge.net/stdair/?rev=160&view=rev Author: quannaus Date: 2010-03-11 09:07:32 +0000 (Thu, 11 Mar 2010) Log Message: ----------- [dev] Removed the key from DemandCharacteristics. Modified Paths: -------------- trunk/stdair/stdair/basic/DemandCharacteristics.cpp trunk/stdair/stdair/basic/DemandCharacteristics.hpp trunk/stdair/stdair/bom/DemandStreamContent.cpp trunk/stdair/stdair/bom/DemandStreamContent.hpp Modified: trunk/stdair/stdair/basic/DemandCharacteristics.cpp =================================================================== --- trunk/stdair/stdair/basic/DemandCharacteristics.cpp 2010-03-10 16:30:22 UTC (rev 159) +++ trunk/stdair/stdair/basic/DemandCharacteristics.cpp 2010-03-11 09:07:32 UTC (rev 160) @@ -13,8 +13,7 @@ // ///////////////////////////////////////////////////// DemandCharacteristics:: - DemandCharacteristics (const DemandStreamKey_T& iKey, - const ArrivalPatternCumulativeDistribution_T& iArrivalPattern, + DemandCharacteristics (const ArrivalPatternCumulativeDistribution_T& iArrivalPattern, const POSProbabilityMassFunction_T& iPOSProbMass, const ChannelProbabilityMassFunction_T& iChannelProbMass, const TripTypeProbabilityMassFunction_T& iTripTypeProbMass, @@ -23,7 +22,7 @@ const PreferredDepartureTimeContinuousDistribution_T& iPreferredDepartureTimeContinuousDistribution, const WTPContinuousDistribution_T& iWTPContinuousDistribution, const ValueOfTimeContinuousDistribution_T& iValueOfTimeContinuousDistribution) - : _key (iKey), _arrivalPattern (iArrivalPattern), + : _arrivalPattern (iArrivalPattern), _posProbabilityMass (iPOSProbMass), _channelProbabilityMass (iChannelProbMass), _tripTypeProbabilityMass (iTripTypeProbMass), @@ -39,40 +38,12 @@ } // ///////////////////////////////////////////////////// - const AirportCode_T& DemandCharacteristics::getOrigin() const { - return _key.getOrigin(); - } - - // ///////////////////////////////////////////////////// - const AirportCode_T& DemandCharacteristics::getDestination() const { - return _key.getDestination(); - } - - // ///////////////////////////////////////////////////// - const Date_T& DemandCharacteristics::getPreferredDepartureDate() const { - return _key.getPreferredDepartureDate(); - } - - // ///////////////////////////////////////////////////// - const CabinCode_T& DemandCharacteristics::getPreferredCabin() const { - return _key.getPreferredCabin(); - } - - // ///////////////////////////////////////////////////// std::string DemandCharacteristics::display() const { std::ostringstream oStr; // oStr << "****************** Demand characteristics ******************" << std::endl; - oStr << "Origin ........................... : " << _key.getOrigin() - << std::endl; - oStr << "Destination ...................... : " << _key.getDestination() - << std::endl; - oStr << "Preferred departure date ......... : " - << _key.getPreferredDepartureDate() << std::endl; - oStr << "Preferred cabin .................. : " << _key.getPreferredCabin() - << std::endl; oStr << "Arrival pattern (days from departure, proportion): "; oStr << _arrivalPattern.displayCumulativeDistribution() << std::endl; oStr << "POS probability mass (POS, propotion): "; Modified: trunk/stdair/stdair/basic/DemandCharacteristics.hpp =================================================================== --- trunk/stdair/stdair/basic/DemandCharacteristics.hpp 2010-03-10 16:30:22 UTC (rev 159) +++ trunk/stdair/stdair/basic/DemandCharacteristics.hpp 2010-03-11 09:07:32 UTC (rev 160) @@ -17,24 +17,7 @@ struct DemandCharacteristics { public: - // ///////////// Getters /////////// - /** Get the key. */ - const DemandStreamKey_T& getKey() const { - return _key; - } - - /** Get the origin. */ - const AirportCode_T& getOrigin() const; - - /** Get the destination. */ - const AirportCode_T& getDestination() const; - - /** Get the preferred departure date. */ - const Date_T& getPreferredDepartureDate() const; - - /** Get the preferred cabin. */ - const CabinCode_T& getPreferredCabin() const; - + // ///////////// Getters /////////// /** Get the arrival pattern. */ const ContinuousFloatDuration_T& getArrivalPattern() const { return _arrivalPattern; @@ -89,8 +72,7 @@ public: // ////////// Constructors and destructors ///////// /** Default constructor. */ - DemandCharacteristics (const DemandStreamKey_T&, - const ArrivalPatternCumulativeDistribution_T&, + DemandCharacteristics (const ArrivalPatternCumulativeDistribution_T&, const POSProbabilityMassFunction_T&, const ChannelProbabilityMassFunction_T&, const TripTypeProbabilityMassFunction_T&, @@ -111,9 +93,6 @@ private: // //////////////////// Attributes ///////////////////// - /** DemandStream Key */ - const DemandStreamKey_T _key; - /** Arrival pattern (cumulative distribution of timing of arrival of requests (negative number of days between departure date and request date). */ Modified: trunk/stdair/stdair/bom/DemandStreamContent.cpp =================================================================== --- trunk/stdair/stdair/bom/DemandStreamContent.cpp 2010-03-10 16:30:22 UTC (rev 159) +++ trunk/stdair/stdair/bom/DemandStreamContent.cpp 2010-03-11 09:07:32 UTC (rev 160) @@ -35,7 +35,7 @@ const RandomSeed_T& iRequestDateTimeSeed, const RandomSeed_T& iDemandCharacteristicsSeed) : _key (iKey), - _demandCharacteristics (iKey, iArrivalPattern, iPOSProbMass, + _demandCharacteristics (iArrivalPattern, iPOSProbMass, iChannelProbMass, iTripTypeProbMass, iStayDurationProbMass, iFrequentFlyerProbMass, iPreferredDepartureTimeContinuousDistribution, Modified: trunk/stdair/stdair/bom/DemandStreamContent.hpp =================================================================== --- trunk/stdair/stdair/bom/DemandStreamContent.hpp 2010-03-10 16:30:22 UTC (rev 159) +++ trunk/stdair/stdair/bom/DemandStreamContent.hpp 2010-03-11 09:07:32 UTC (rev 160) @@ -41,22 +41,22 @@ /** Get the origin. */ const AirportCode_T& getOrigin() const { - return _demandCharacteristics.getOrigin(); + return _key.getOrigin(); } /** Get the destination. */ const AirportCode_T& getDestination() const { - return _demandCharacteristics.getDestination(); + return _key.getDestination(); } /** Get the preferred departure date. */ const Date_T& getPreferredDepartureDate() const { - return _demandCharacteristics.getPreferredDepartureDate(); + return _key.getPreferredDepartureDate(); } /** Get the preferred cabin. */ const CabinCode_T& getPreferredCabin() const { - return _demandCharacteristics.getPreferredCabin(); + return _key.getPreferredCabin(); } /** Get the arrival pattern. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |