From: <qua...@us...> - 2010-07-07 14:07:49
|
Revision: 210 http://stdair.svn.sourceforge.net/stdair/?rev=210&view=rev Author: quannaus Date: 2010-07-07 14:07:43 +0000 (Wed, 07 Jul 2010) Log Message: ----------- [dev] Added functions for getting travel solution list. Modified Paths: -------------- trunk/stdair/stdair/STDAIR_Types.hpp trunk/stdair/stdair/bom/BomManager.cpp trunk/stdair/stdair/bom/BomManager.hpp trunk/stdair/stdair/bom/BookingClassTypes.hpp trunk/stdair/stdair/bom/SegmentPathPeriod.cpp trunk/stdair/stdair/bom/SegmentPathPeriod.hpp trunk/stdair/stdair/bom/SegmentPeriodContent.cpp trunk/stdair/stdair/bom/SegmentPeriodContent.hpp trunk/stdair/stdair/bom/TravelSolutionStruct.cpp trunk/stdair/stdair/bom/TravelSolutionStruct.hpp Modified: trunk/stdair/stdair/STDAIR_Types.hpp =================================================================== --- trunk/stdair/stdair/STDAIR_Types.hpp 2010-06-30 15:59:19 UTC (rev 209) +++ trunk/stdair/stdair/STDAIR_Types.hpp 2010-07-07 14:07:43 UTC (rev 210) @@ -467,6 +467,13 @@ /** Key of a STL map. */ typedef std::string MapKey_T; + + /** List of keys. */ + typedef std::vector<std::string> KeyList_T; + + /** Map between the cabin codes and the booking class codes within + each cabin. */ + typedef std::map<CabinCode_T, ClassList_String_T> CabinBookingClassMap_T; } #endif // __STDAIR_STDAIR_TYPES_HPP Modified: trunk/stdair/stdair/bom/BomManager.cpp =================================================================== --- trunk/stdair/stdair/bom/BomManager.cpp 2010-06-30 15:59:19 UTC (rev 209) +++ trunk/stdair/stdair/bom/BomManager.cpp 2010-07-07 14:07:43 UTC (rev 210) @@ -492,5 +492,97 @@ oStream << dInt; } } + + // //////////////////////////////////////////////////////////////////// + void BomManager::displaySegmentPathNetwork (std::ostream& oStream, + const BomRoot& iBomRoot) { + // Store current formatting flags of the given output stream + std::ios::fmtflags oldFlags = oStream.flags(); + + oStream << std::endl; + + // Browse the reachable universe objects. + const ReachableUniverseList_T& lRUList = iBomRoot.getReachableUniverseList(); + for (ReachableUniverseList_T::iterator itRU = lRUList.begin(); + itRU != lRUList.end(); ++itRU) { + const ReachableUniverse& lCurrentRU = *itRU; + + display (oStream, lCurrentRU); + } + + // Reset formatting flags of the given output stream + oStream.flags (oldFlags); + } + + // //////////////////////////////////////////////////////////////////// + void BomManager::display (std::ostream& oStream, + const ReachableUniverse& iReachableUniverse) { + // Store current formatting flags of the given output stream + std::ios::fmtflags oldFlags = oStream.flags(); + + oStream << std::endl << "Reachable Universe level: " + << iReachableUniverse.describeShortKey() << std::endl; + + // Browse the origin-destination set objects. + const OriginDestinationSetList_T& lODSetList = + iReachableUniverse.getOriginDestinationSetList (); + for (OriginDestinationSetList_T::iterator itODS = lODSetList.begin(); + itODS != lODSetList.end(); ++itODS) { + const OriginDestinationSet& lCurrentODS = *itODS; + + display (oStream, lCurrentODS); + } + + // Reset formatting flags of the given output stream + oStream.flags (oldFlags); + } + + // //////////////////////////////////////////////////////////////////// + void BomManager::display (std::ostream& oStream, + const OriginDestinationSet& iOriginDestinationSet) { + // Store current formatting flags of the given output stream + std::ios::fmtflags oldFlags = oStream.flags(); + + oStream << "Origine-Destination Set level: " + << iOriginDestinationSet.describeShortKey () << std::endl; + + // Browse the segment path period objects. + const SegmentPathPeriodList_T& lSegmentPathPeriodList = + iOriginDestinationSet.getSegmentPathPeriodList (); + for (SegmentPathPeriodList_T::iterator itSegmentPath = + lSegmentPathPeriodList.begin(); + itSegmentPath != lSegmentPathPeriodList.end(); ++itSegmentPath) { + const SegmentPathPeriod& lCurrentSegmentPath = *itSegmentPath; + + display (oStream, lCurrentSegmentPath); + } + + // Reset formatting flags of the given output stream + oStream.flags (oldFlags); + } + + // //////////////////////////////////////////////////////////////////// + void BomManager::display (std::ostream& oStream, + const SegmentPathPeriod& iSegmentPathPeriod) { + // Store current formatting flags of the given output stream + std::ios::fmtflags oldFlags = oStream.flags(); + + oStream << "Segment Path Period level: " + << iSegmentPathPeriod.describeShortKey () << std::endl; + + // Browse the segment period objects. + const SegmentPeriodList_T& lSegmentPeriodList = + iSegmentPathPeriod.getSegmentPeriodList(); + for (SegmentPeriodList_T::iterator itSegmentPeriod = + lSegmentPeriodList.begin(); + itSegmentPeriod != lSegmentPeriodList.end(); ++itSegmentPeriod) { + const SegmentPeriod& lCurrentSegmentPeriod = *itSegmentPeriod; + oStream << "Segment Period details: " + << lCurrentSegmentPeriod.describeKey() << std::endl; + } + + // Reset formatting flags of the given output stream + oStream.flags (oldFlags); + } } Modified: trunk/stdair/stdair/bom/BomManager.hpp =================================================================== --- trunk/stdair/stdair/bom/BomManager.hpp 2010-06-30 15:59:19 UTC (rev 209) +++ trunk/stdair/stdair/bom/BomManager.hpp 2010-07-07 14:07:43 UTC (rev 210) @@ -18,6 +18,11 @@ class SegmentDate; class SegmentCabin; class BookingClass; + class ReachableUniverse; + class OriginDestinationSet; + class SegmentPathPeriod; + class FlightPeriod; + class SegmentPeriod; class Network; class NetworkDate; class AirportDate; @@ -128,6 +133,25 @@ const BookingRequestStruct& iBookingRequest); /** Helper fuction to display an interger. */ static void intDisplay (std::ostream&, const int&); + + /** 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 BomRoot& Root of the BOM tree to be displayed. */ + static void displaySegmentPathNetwork (std::ostream&, const BomRoot&); + + /** Recursively display (dump in the underlying output log stream) + the objects of the given BOM tree. */ + static void display (std::ostream&, const ReachableUniverse&); + + /** Recursively display (dump in the underlying output log stream) + the objects of the given BOM tree. */ + static void display (std::ostream&, const OriginDestinationSet&); + + /** Recursively display (dump in the underlying output log stream) + the objects of the given BOM tree. */ + static void display (std::ostream&, const SegmentPathPeriod&); }; } Modified: trunk/stdair/stdair/bom/BookingClassTypes.hpp =================================================================== --- trunk/stdair/stdair/bom/BookingClassTypes.hpp 2010-06-30 15:59:19 UTC (rev 209) +++ trunk/stdair/stdair/bom/BookingClassTypes.hpp 2010-07-07 14:07:43 UTC (rev 210) @@ -28,11 +28,7 @@ typedef BomList_T<BookingClass> BookingClassList_T; /** Define the booking class map. */ - typedef BomMap_T<BookingClass> BookingClassMap_T; - - /** Define the STL list of booking classes. */ - typedef std::vector<BookingClass*> BookingClassSTLList_T; - + typedef BomMap_T<BookingClass> BookingClassMap_T; } #endif // __STDAIR_BOM_BOOKINGCLASSTYPES_HPP Modified: trunk/stdair/stdair/bom/SegmentPathPeriod.cpp =================================================================== --- trunk/stdair/stdair/bom/SegmentPathPeriod.cpp 2010-06-30 15:59:19 UTC (rev 209) +++ trunk/stdair/stdair/bom/SegmentPathPeriod.cpp 2010-07-07 14:07:43 UTC (rev 210) @@ -194,8 +194,8 @@ const DateOffset_T& lLastBoardingDateOffset = lBoardingDateOffsetList.at (getNbOfSegments() - 1); const DateOffset_T lNextBoardingDateOffset = - lLastBoardingDateOffset + lNextSegmentPeriod_ptr->getOffDateOffset() - - lNextSegmentPeriod_ptr->getBoardingDateOffset(); + lLastBoardingDateOffset + lLastSegmentPeriod_ptr->getOffDateOffset() + - lLastSegmentPeriod_ptr->getBoardingDateOffset(); const DateOffset_T lNegativeNextBoardingDateOffset = DateOffset_T (0) - lNextBoardingDateOffset; @@ -224,8 +224,8 @@ const DateOffset_T& lLastBoardingDateOffset = lBoardingDateOffsetList.at (getNbOfSegments() - 1); const DateOffset_T lNextBoardingDateOffset = - lLastBoardingDateOffset + lNextSegmentPeriod_ptr->getOffDateOffset() - - lNextSegmentPeriod_ptr->getBoardingDateOffset() + DateOffset_T (1); + lLastBoardingDateOffset + lLastSegmentPeriod_ptr->getOffDateOffset() + - lLastSegmentPeriod_ptr->getBoardingDateOffset() + DateOffset_T (1); const DateOffset_T lNegativeNextBoardingDateOffset = DateOffset_T (0) - lNextBoardingDateOffset; @@ -267,6 +267,28 @@ } return false; } + + // //////////////////////////////////////////////////////////////////// + bool SegmentPathPeriod:: + isDepartureDateValid (const Date_T& iDepartureDate) const { + const PeriodStruct_T& lPeriod = getDeparturePeriod (); + + // Check if the departure date is within the date range. + const DatePeriod_T& lDeparturePeriod = lPeriod.getDateRange (); + if (lDeparturePeriod.contains (iDepartureDate) == false) { + return false; + } + + // Check if the departure date is valid within the DOW. + // 0 = Sunday, 1 = Monday, etc. + const short lDay = iDepartureDate.day_of_week (); + const DoWStruct_T& lDoW = lPeriod.getDoW (); + if (lDoW.getStandardDayOfWeek (lDay) == false) { + return false; + } + + return true; + } } Modified: trunk/stdair/stdair/bom/SegmentPathPeriod.hpp =================================================================== --- trunk/stdair/stdair/bom/SegmentPathPeriod.hpp 2010-06-30 15:59:19 UTC (rev 209) +++ trunk/stdair/stdair/bom/SegmentPathPeriod.hpp 2010-07-07 14:07:43 UTC (rev 210) @@ -73,7 +73,25 @@ of the last segment. */ const AirportCode_T& getDestination () const; + public: + // /////////// Display support methods ///////// + /** 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); + + /** Get the serialised version of the Business Object. */ + std::string toString() const; + + /** Get a string describing the whole key (differentiating two objects + at any level). */ + const std::string describeKey() const; + public: + // ////////////// Busniess methods //////////////// /** Check if the (i-1)-length segment path period can be fused with the single segment segment path period in order to create an i-length segment path period. The function will return a valid or non-valid @@ -96,23 +114,11 @@ the segments of the internal list. */ bool isAirlineFlown (const AirlineCode_T&) const; - public: - // /////////// Display support methods ///////// - /** Dump a Business Object into an output stream. - @param ostream& the output stream. */ - void toStream (std::ostream& ioOut) const; + /** Check if the given departure date is included in the departure period + of the segment path. */ + bool isDepartureDateValid (const Date_T&) const; - /** 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; - - /** Get a string describing the whole key (differentiating two objects - at any level). */ - const std::string describeKey() const; - protected: /** Constructors are private so as to force the usage of the Factory layer. */ Modified: trunk/stdair/stdair/bom/SegmentPeriodContent.cpp =================================================================== --- trunk/stdair/stdair/bom/SegmentPeriodContent.cpp 2010-06-30 15:59:19 UTC (rev 209) +++ trunk/stdair/stdair/bom/SegmentPeriodContent.cpp 2010-07-07 14:07:43 UTC (rev 210) @@ -18,5 +18,14 @@ SegmentPeriodContent::~SegmentPeriodContent () { } + // //////////////////////////////////////////////////////////////////// + void SegmentPeriodContent:: + addCabinBookingClassList (const CabinCode_T& iCabinCode, + const ClassList_String_T& iClassCodeList) { + const bool insert = _cabinBookingClassMap. + insert (CabinBookingClassMap_T::value_type (iCabinCode, iClassCodeList)).second; + assert (insert == true); + } + } Modified: trunk/stdair/stdair/bom/SegmentPeriodContent.hpp =================================================================== --- trunk/stdair/stdair/bom/SegmentPeriodContent.hpp 2010-06-30 15:59:19 UTC (rev 209) +++ trunk/stdair/stdair/bom/SegmentPeriodContent.hpp 2010-07-07 14:07:43 UTC (rev 210) @@ -59,6 +59,11 @@ return _elapsedTime; } + /** Get the cabin booking class map. */ + const CabinBookingClassMap_T& getCabinBookingClassMap () const { + return _cabinBookingClassMap; + } + public: // ///////// Setters ////////// /** Set the boarding time. */ @@ -86,6 +91,11 @@ _elapsedTime = iElapsedTime; } + /** Add a pair cabin code and list of class codes within the cabin to the + cabin booking class map. */ + void addCabinBookingClassList (const CabinCode_T&, + const ClassList_String_T&); + public: // /////////// Display support methods ///////// @@ -120,6 +130,7 @@ DateOffset_T _boardingDateOffset; DateOffset_T _offDateOffset; Duration_T _elapsedTime; + CabinBookingClassMap_T _cabinBookingClassMap; }; } Modified: trunk/stdair/stdair/bom/TravelSolutionStruct.cpp =================================================================== --- trunk/stdair/stdair/bom/TravelSolutionStruct.cpp 2010-06-30 15:59:19 UTC (rev 209) +++ trunk/stdair/stdair/bom/TravelSolutionStruct.cpp 2010-07-07 14:07:43 UTC (rev 210) @@ -8,33 +8,22 @@ #include <sstream> // StdAir #include <stdair/basic/BasConst_BookingClass.hpp> -#include <stdair/bom/OutboundPath.hpp> #include <stdair/bom/TravelSolutionStruct.hpp> namespace stdair { - // //////////////////////////////////////////////////////////////////// - TravelSolutionStruct::TravelSolutionStruct () - : _outboundPath_ptr (NULL) { - assert (false); + TravelSolutionStruct::TravelSolutionStruct () + : _fare (DEFAULT_FARE_VALUE), _availability (DEFAULT_AVAILABILITY) { } // //////////////////////////////////////////////////////////////////// TravelSolutionStruct:: TravelSolutionStruct (const TravelSolutionStruct& iTravelSolutionStruct) - : _outboundPath_ptr (iTravelSolutionStruct._outboundPath_ptr), - _bookingClassList (iTravelSolutionStruct._bookingClassList), + : _segmentDateKeyList (iTravelSolutionStruct._segmentDateKeyList), + _bookingClassKeyList (iTravelSolutionStruct._bookingClassKeyList), _fare (iTravelSolutionStruct._fare), _availability (iTravelSolutionStruct._availability) { } - - // //////////////////////////////////////////////////////////////////// - TravelSolutionStruct:: - TravelSolutionStruct (OutboundPath& ioOutboundPath, - const BookingClassSTLList_T& iBookingClassList) - : _outboundPath_ptr (&ioOutboundPath), _bookingClassList (iBookingClassList), - _fare (DEFAULT_FARE_VALUE), _availability (DEFAULT_AVAILABILITY) { - } // //////////////////////////////////////////////////////////////////// TravelSolutionStruct::~TravelSolutionStruct () { @@ -52,29 +41,21 @@ // ////////////////////////////////////////////////////////////////////// const std::string TravelSolutionStruct::describe() const { std::ostringstream oStr; - if (_outboundPath_ptr != NULL) { - oStr << *_outboundPath_ptr; + + ClassList_String_T::const_iterator itClass = _bookingClassKeyList.begin(); + + for (KeyList_T::const_iterator itSegmentKey = _segmentDateKeyList.begin (); + itSegmentKey != _segmentDateKeyList.end(); ++itSegmentKey) { + oStr << *itSegmentKey << ", "; + if (itClass != _bookingClassKeyList.end()) { + oStr << *itClass << ", "; + ++itClass; + } } + + oStr << _fare << ", " << _availability; return oStr.str(); } - - // ////////////////////////////////////////////////////////////////////// - const std::string TravelSolutionStruct::describeKey() const { - std::string oString; - if (_outboundPath_ptr != NULL) { - oString = _outboundPath_ptr->describeKey(); - } - return oString; - } - - // ////////////////////////////////////////////////////////////////////// - const std::string TravelSolutionStruct::describeShortKey() const { - std::string oString; - if (_outboundPath_ptr != NULL) { - oString = _outboundPath_ptr->describeShortKey(); - } - return oString; - } } Modified: trunk/stdair/stdair/bom/TravelSolutionStruct.hpp =================================================================== --- trunk/stdair/stdair/bom/TravelSolutionStruct.hpp 2010-06-30 15:59:19 UTC (rev 209) +++ trunk/stdair/stdair/bom/TravelSolutionStruct.hpp 2010-07-07 14:07:43 UTC (rev 210) @@ -14,21 +14,15 @@ #include <stdair/bom/BookingClassTypes.hpp> namespace stdair { - - // Forward declarations - class OutboundPath; - /** Structure holding the elements of a travel solution. */ struct TravelSolutionStruct : public StructAbstract { public: // /////////// Getters /////////////// - /** Retrieve the attributes of the object. */ - OutboundPath& getOutboundPath() const { - assert (_outboundPath_ptr != NULL); - return *_outboundPath_ptr; + const KeyList_T& getSegmentDateKeyList () { + return _segmentDateKeyList; } - const BookingClassSTLList_T& getBookingClassList () const { - return _bookingClassList; + const ClassList_String_T& getBookingClassKeyList () const { + return _bookingClassKeyList; } const Fare_T getFare() const { return _fare; } const Availability_T getAvailability() const { return _availability; } @@ -38,6 +32,12 @@ /** Setter for some attributes. */ void setFare (const Fare_T& iFare) { _fare = iFare; } void setAvailability (const Availability_T& iAvail) { _availability=iAvail; } + void addSegmentDateKey (const std::string& iKey) { + _segmentDateKeyList.push_back (iKey); + } + void addBookingClassKey (const char iKey) { + _bookingClassKeyList.push_back (iKey); + } public: // /////////// Display support method ///////////// @@ -51,35 +51,24 @@ /** Display of the structure. */ const std::string describe() const; - - /** Get a string describing the whole key (differentiating two objects - at any level). */ - const std::string describeKey() const; - - /** Get a string describing the short key (differentiating two objects - at the same level). */ - const std::string describeShortKey() const; - public: // //////////// Constructors & Destructor /////////////// /** Main constructor. */ - TravelSolutionStruct (OutboundPath&, const BookingClassSTLList_T&); + TravelSolutionStruct (); /** Destructor. */ ~TravelSolutionStruct (); /** Default copy constructor. */ TravelSolutionStruct (const TravelSolutionStruct&); - /** Default constructor, not to be used. */ - TravelSolutionStruct (); private: // ///////////////////// Attributes ////////////////////// - /** The outbound path associated to this solution.*/ - OutboundPath* _outboundPath_ptr; - - /** The list of booking classes which make the travel solution. */ - BookingClassSTLList_T _bookingClassList; - + /** The list of segment-date whole keys which make the travel solution. */ + KeyList_T _segmentDateKeyList; + + /** The list of booking class keys which make the travel solution. */ + ClassList_String_T _bookingClassKeyList; + /** The fare of the travel solution. */ Fare_T _fare; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |