From: <qua...@us...> - 2010-04-23 08:53:40
|
Revision: 183 http://stdair.svn.sourceforge.net/stdair/?rev=183&view=rev Author: quannaus Date: 2010-04-23 08:53:34 +0000 (Fri, 23 Apr 2010) Log Message: ----------- [dev] Implemented some functions within CmdBomManager. Modified Paths: -------------- trunk/stdair/stdair/STDAIR_Service.hpp trunk/stdair/stdair/command/CmdBomManager.cpp trunk/stdair/stdair/command/CmdBomManager.hpp trunk/stdair/stdair/service/STDAIR_Service.cpp Modified: trunk/stdair/stdair/STDAIR_Service.hpp =================================================================== --- trunk/stdair/stdair/STDAIR_Service.hpp 2010-04-22 14:41:11 UTC (rev 182) +++ trunk/stdair/stdair/STDAIR_Service.hpp 2010-04-23 08:53:34 UTC (rev 183) @@ -14,8 +14,6 @@ // Forward declarations class BomRoot; - class YieldStore; - class Inventory; /** Interface for the STDAIR Services. */ class STDAIR_Service { @@ -42,19 +40,7 @@ /** Destructor. */ ~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; - - /** Retrieve the Yield Store corresponding to the given airline code - (YieldStore key). - <br>If not existing, a ObjectNotFoundException exception is thrown. */ - YieldStore& getYieldStore (const AirlineCode_T& iAirlineCode) const; - - // ///////////////// Getters /////////////////// /** Get a reference on the BomRoot object. <br>If the service context has not been initialised, that @@ -62,23 +48,6 @@ BomRoot& getBomRoot () const { 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; - - /** Retrieve the YieldStore corresponding to the given airline code - (YieldStore key). - <br>If not existing, a ObjectNotFoundException exception is thrown. */ - YieldStore& createYieldStore (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 /////// @@ -86,13 +55,10 @@ STDAIR_Service (); /** Default copy constructor. */ STDAIR_Service (const STDAIR_Service&); - /** 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 @@ -103,10 +69,8 @@ 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 (); - private: // /////////////// Attributes /////////////// Modified: trunk/stdair/stdair/command/CmdBomManager.cpp =================================================================== --- trunk/stdair/stdair/command/CmdBomManager.cpp 2010-04-22 14:41:11 UTC (rev 182) +++ trunk/stdair/stdair/command/CmdBomManager.cpp 2010-04-23 08:53:34 UTC (rev 183) @@ -3,13 +3,7 @@ // ////////////////////////////////////////////////////////////////////// // STL #include <cassert> -// Boost -#include <boost/make_shared.hpp> // StdAir -#include <stdair/bom/BomRoot.hpp> -#include <stdair/bom/Inventory.hpp> -#include <stdair/bom/YieldStore.hpp> -#include <stdair/bom/AirlineFeature.hpp> #include <stdair/bom/BomSource.hpp> #include <stdair/factory/FacBomContent.hpp> #include <stdair/command/CmdBomManager.hpp> @@ -18,8 +12,8 @@ namespace stdair { // ////////////////////////////////////////////////////////////////////// - void CmdBomManager::addAirlineFeature (BomRoot& ioBomRoot, - const AirlineCode_T& iAirlineCode) { + void CmdBomManager::createAirlineFeature (const BomRoot& iBomRoot, + const AirlineCode_T& iAirlineCode) { // Initialise an AirlineFeature object AirlineFeatureKey_T lAirlineFeatureKey (iAirlineCode); @@ -27,84 +21,175 @@ instance().create<AirlineFeature> (lAirlineFeatureKey); // Add the AirlineFeature object to its AirlineFeatureSet parent - FacBomContent::linkWithParent (lAirlineFeature, ioBomRoot); + FacBomContent::linkWithParent (lAirlineFeature, iBomRoot); // Link the AirlineFeature with its corresponding inventory (if exist) - Inventory* lInventory_ptr = ioBomRoot.getInventory (iAirlineCode); + Inventory* lInventory_ptr = iBomRoot.getInventory (iAirlineCode); if (lInventory_ptr != NULL) { lInventory_ptr->setAirlineFeature (&lAirlineFeature); } } - + // ////////////////////////////////////////////////////////////////////// + YieldStore& CmdBomManager:: + createYieldStore (const BomRoot& iBomRoot, + const AirlineCode_T& iAirlineCode) { + // Instantiate an YieldStore object with the given airline code + YieldStoreKey_T lYieldStoreKey (iAirlineCode); + YieldStore& oYieldStore = + stdair::FacBomContent::instance().create<YieldStore> (lYieldStoreKey); + // Link the created YieldStore with the bom root. + FacBomContent::linkWithParent (oYieldStore, iBomRoot); + + return oYieldStore; + } + + // ////////////////////////////////////////////////////////////////////// Inventory& CmdBomManager:: - createInventoryInternal (BomRoot& ioBomRoot, - const AirlineCode_T& iAirlineCode) { + createInventory (const BomRoot& iBomRoot, + const AirlineCode_T& iAirlineCode) { + // Instantiate an inventory object with the given airline code InventoryKey_T lInventoryKey (iAirlineCode); - - // Instantiate an Inventory object with the given airline code - Inventory& lInventory = + Inventory& oInventory = FacBomContent::instance().create<Inventory> (lInventoryKey); + // Link the created inventory with the bom root. + FacBomContent::linkWithParent (oInventory, iBomRoot); - // Link the created inventory with the bom root. - FacBomContent::linkWithParent (lInventory, ioBomRoot); + // Create the AirlineFeature for the inventory. + createAirlineFeature (iBomRoot, iAirlineCode); - return lInventory; + return oInventory; } + + // ////////////////////////////////////////////////////////////////////// + FlightDate& CmdBomManager:: + createFlightDate (const Inventory& iInventory, + const FlightDateKey_T& iFlightDateKey) { + // Instantiate a flight-date object with the given key. + FlightDate& oFlightDate = + FacBomContent::instance().create<FlightDate> (iFlightDateKey); + // Link the created inventory with the inventory. + FacBomContent::linkWithParent (oFlightDate, iInventory); + + return oFlightDate; + } // ////////////////////////////////////////////////////////////////////// - Inventory& CmdBomManager:: - getOrCreateInventory (BomRoot& ioBomRoot, - const AirlineCode_T& iAirlineCode) { - Inventory* lInventory_ptr = ioBomRoot.getInventory (iAirlineCode); + LegDate& CmdBomManager:: + createLegDate (const FlightDate& iFlightDate, + const AirportCode_T& iBoardingPoint) { + // Instantiate a leg-date object with the given boarding point + LegDateKey_T lLegDateKey (iBoardingPoint); + LegDate& oLegDate = FacBomContent::instance().create<LegDate> (lLegDateKey); + // Link the created leg-date with the flight-date. + FacBomContent::linkWithParent (oLegDate, iFlightDate); + + return oLegDate; + } - // If there is no Inventory object for that airline already, create one - if (lInventory_ptr == NULL) { - // Instantiate an Inventory object with the given airline code - lInventory_ptr = &createInventoryInternal (ioBomRoot, iAirlineCode); - assert (lInventory_ptr != NULL); - - // Set the AirlineFeature for the inventory. - addAirlineFeature (ioBomRoot, iAirlineCode); - } - assert (lInventory_ptr != NULL); - - return *lInventory_ptr; + // ////////////////////////////////////////////////////////////////////// + LegCabin& CmdBomManager:: + createLegCabin (const LegDate& iLegDate, + const CabinCode_T& iCabinCode) { + // Instantiate a leg-cabin object with the given cabin code + LegCabinKey_T lLegCabinKey (iCabinCode); + LegCabin& oLegCabin = + FacBomContent::instance().create<LegCabin> (lLegCabinKey); + // Link the created leg-cabin with the leg-date. + FacBomContent::linkWithParent (oLegCabin, iLegDate); + + return oLegCabin; } // ////////////////////////////////////////////////////////////////////// - YieldStore& CmdBomManager:: - createYieldStoreInternal (BomRoot& ioBomRoot, - const AirlineCode_T& iAirlineCode) { - YieldStoreKey_T lYieldStoreKey (iAirlineCode); - - // Instantiate an YieldStore object with the given airline code - YieldStore& lYieldStore = - stdair::FacBomContent::instance().create<YieldStore> (lYieldStoreKey); - - // Link the created YieldStore with the bom root. - FacBomContent::linkWithParent (lYieldStore, ioBomRoot); - - return lYieldStore; + SegmentDate& CmdBomManager:: + createSegmentDate (const FlightDate& iFlightDate, + const SegmentDateKey_T& iSegmentDateKey) { + // Instantiate a segment-date object with the given key. + SegmentDate& oSegmentDate = + FacBomContent::instance().create<SegmentDate> (iSegmentDateKey); + // Link the created segment-date with the flight-date. + FacBomContent::linkWithParent (oSegmentDate, iFlightDate); + + return oSegmentDate; } // ////////////////////////////////////////////////////////////////////// - YieldStore& CmdBomManager:: - getOrCreateYieldStore (BomRoot& ioBomRoot, - const AirlineCode_T& iAirlineCode) { - YieldStore* lYieldStore_ptr = ioBomRoot.getYieldStore (iAirlineCode); + SegmentCabin& CmdBomManager:: + createSegmentCabin (const SegmentDate& iSegmentDate, + const CabinCode_T& iCabinCode) { + // Instantiate a segment-cabin object with the given cabin code + SegmentCabinKey_T lSegmentCabinKey (iCabinCode); + SegmentCabin& oSegmentCabin = + FacBomContent::instance().create<SegmentCabin> (lSegmentCabinKey); + // Link the created segment-cabin with the segment-date. + FacBomContent::linkWithParent (oSegmentCabin, iSegmentDate); + + return oSegmentCabin; + } - // If there is no YieldStore object for that airline already, create one - if (lYieldStore_ptr == NULL) { - const YieldStoreKey_T lYieldStoreKey (iAirlineCode); + // //////////////////////////////////////////////////////////////////// + void CmdBomManager::createBookingClass (const SegmentCabin& iSegmentCabin, + const ClassCode_T& iClassCode) { + // Instantiate a booking class object with the given class code + const BookingClassKey_T lClassKey (iClassCode); + BookingClass& lClass = + FacBomContent::instance().create<BookingClass> (lClassKey); + // Link the created booking-class with its parent segment-cabin. + FacBomContent::linkWithParent (lClass, iSegmentCabin); + } - // Instantiate a YieldStore object with the given airline code - lYieldStore_ptr = &createYieldStoreInternal (ioBomRoot, iAirlineCode); - assert (lYieldStore_ptr != NULL); - } - assert (lYieldStore_ptr != NULL); + // ////////////////////////////////////////////////////////////////////// + Network& CmdBomManager:: + createNetwork (const BomRoot& iBomRoot, + const NetworkKey_T& iNetworkKey) { + // Instantiate an network object with the given key + Network& oNetwork = + FacBomContent::instance().create<Network> (iNetworkKey); + // Link the created inventory with the bom root. + FacBomContent::linkWithParent (oNetwork, iBomRoot); + + return oNetwork; + } + + // ////////////////////////////////////////////////////////////////////// + NetworkDate& CmdBomManager:: + createNetworkDate (const Network& iNetwork, const Date_T& iDate) { + // Instantiate a network-date object with the given date. + const NetworkDateKey_T lNetworkDateKey (iDate); + NetworkDate& oNetworkDate = + FacBomContent::instance().create<NetworkDate> (lNetworkDateKey); + // Link the created network with the bom root + FacBomContent::linkWithParent (oNetworkDate, iNetwork); + + return oNetworkDate; + } - return *lYieldStore_ptr; + // ////////////////////////////////////////////////////////////////////// + AirportDate& CmdBomManager:: + createAirportDate (const NetworkDate& iNetworkDate, + const AirportCode_T& iBoardingPoint) { + // Instantiate a airport-date object with the given boarding point + AirportDateKey_T lAirportDateKey (iBoardingPoint); + AirportDate& oAirportDate = + FacBomContent::instance().create<AirportDate> (lAirportDateKey); + // Link the created airport-date with the network-date. + FacBomContent::linkWithParent (oAirportDate, iNetworkDate); + + return oAirportDate; } + // ////////////////////////////////////////////////////////////////////// + OutboundPath& CmdBomManager:: + createOutboundPath (const AirportDate& iAirportDate, + const OutboundPathKey_T& iOutboundPathKey) { + // Instantiate a outbound path object with the given key. + OutboundPath& oOutboundPath = + FacBomContent::instance().create<OutboundPath> (iOutboundPathKey); + // Link the created outbound path with the airport-date + FacBomContent::linkWithParent (oOutboundPath, iAirportDate); + + return oOutboundPath; + } + } Modified: trunk/stdair/stdair/command/CmdBomManager.hpp =================================================================== --- trunk/stdair/stdair/command/CmdBomManager.hpp 2010-04-22 14:41:11 UTC (rev 182) +++ trunk/stdair/stdair/command/CmdBomManager.hpp 2010-04-23 08:53:34 UTC (rev 183) @@ -13,58 +13,79 @@ // Forward declarations class BomRoot; class Inventory; + class FlightDate; + class SegmentDate; + class SegmentCabin; + class LegDate; + class LegCabin; + class Bucket; + class Network; + class NetworkDate; + class AirportDate; + class OutboundPath; + class YieldStore; + class DemandStream; + struct FlightDateKey_T; + struct SegmentDateKey_T; + struct NetworkKey_T; + struct OutboundPathKey_T; /** Class wrapping utility functions for handling the BOM tree objects. */ class CmdBomManager : public CmdAbstract { public: - - /** If needed, create the Inventory corresponding to the given airline code - (Inventory key), link it to the BomRoot object and to the - associated AirlineFeature object, itself retrieved from the - AirlineFeatureSet object. - Otherwise, just retrieve the reference on the existing Inventory object - corresponding to the given airline code. - <br>If not existing, a ObjectNotFoundException exception is thrown. + + /** Create the airline-specific AirlineFeature object to the BomRoot + and its corresponding Inventory. @param BomRoot& Root of the BOM tree. @param const AirlineCode_T& Airline code for the inventory to be created . */ - static Inventory& getOrCreateInventory (BomRoot&, const AirlineCode_T&); + static void createAirlineFeature (const BomRoot&, const AirlineCode_T&); - /** If needed, create the YieldStore corresponding to the given airline code - (YieldStore key), link it to the BomRoot object and to the - associated AirlineFeature object, itself retrieved from the - AirlineFeatureSet object. - Otherwise, just retrieve the reference on the existing YieldStore object - corresponding to the given airline code. - <br>If not existing, a ObjectNotFoundException exception is thrown. - @param BomRoot& Root of the BOM tree. - @param const AirlineCode_T& Airline code for the YieldStore to be - created . */ - static YieldStore& getOrCreateYieldStore (BomRoot&, const AirlineCode_T&); - - /** Add the airline-specific AirlineFeature object to its AirlineFeatureSet - parent. - @param BomRoot& Root of the BOM tree. - @param const AirlineCode_T& Airline code for the inventory to be - created . */ - static void addAirlineFeature (BomRoot&, const AirlineCode_T& iAirlineCode); + /** Create the YieldStore corresponding to the given airline code + (YieldStore key). */ + static YieldStore& createYieldStore (const BomRoot&, const AirlineCode_T&); + + /** Create the inventory corresponding to the given airline code + (Inventory key), link it to the BomRoot object and to the + associated AirlineFeature object. */ + static Inventory& createInventory (const BomRoot&, const AirlineCode_T&); + + /** Create the flight-date corresponding to the given key. */ + static FlightDate& createFlightDate (const Inventory&, + const FlightDateKey_T&); + + /** Create the leg-date corresponding to the given boarding point. */ + static LegDate& createLegDate (const FlightDate&, const AirportCode_T&); + + /** Create the leg-cabin corresponding to the given cabin code. */ + static LegCabin& createLegCabin (const LegDate&, const CabinCode_T&); - private: - // ///////////////////// Internal support methods //////////////////////// - /** Create the Inventory corresponding to the given airline code - (Inventory key). - @param BomRoot& Root of the BOM tree. - @param const AirlineCode_T& Airline code for the inventory to be - created . */ - static Inventory& createInventoryInternal (BomRoot&, const AirlineCode_T&); + /** Create the segment-date corresponding to the given key. */ + static SegmentDate& createSegmentDate (const FlightDate&, + const SegmentDateKey_T&); - /** Create the YieldStore corresponding to the given airline code - (YieldStore key). - @param BomRoot& Root of the BOM tree. - @param const AirlineCode_T& Airline code for the YieldStore to be - created . */ - static YieldStore& createYieldStoreInternal (BomRoot&, - const AirlineCode_T&); + /** Create the segment-cabin corresponding to the given cabin code. */ + static SegmentCabin& createSegmentCabin (const SegmentDate&, + const CabinCode_T&); + + /** Create the booking class corresponding to the given class code. */ + static void createBookingClass (const SegmentCabin&, const ClassCode_T&); + + /** Create the inventory corresponding to the given network key, + then link it to the BomRoot object. */ + static Network& createNetwork (const BomRoot&, const NetworkKey_T&); + + /** Create the network-date corresponding to the given date. */ + static NetworkDate& createNetworkDate (const Network&, const Date_T&); + + /** Create the airport-date corresponding to the given boarding point. */ + static AirportDate& createAirportDate (const NetworkDate&, + const AirportCode_T&); + + /** Create the outbound path corresponding to the given key. */ + static OutboundPath& createOutboundPath (const AirportDate&, + const OutboundPathKey_T&); + }; } Modified: trunk/stdair/stdair/service/STDAIR_Service.cpp =================================================================== --- trunk/stdair/stdair/service/STDAIR_Service.cpp 2010-04-22 14:41:11 UTC (rev 182) +++ trunk/stdair/stdair/service/STDAIR_Service.cpp 2010-04-23 08:53:34 UTC (rev 183) @@ -82,67 +82,10 @@ } // ////////////////////////////////////////////////////////////////////// - void STDAIR_Service:: - addAirlineFeature (const AirlineCode_T& iAirlineCode) const { - // Delegate to the dedicated command - CmdBomManager::addAirlineFeature (_bomRoot, iAirlineCode); - } - - // ////////////////////////////////////////////////////////////////////// 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; } - // ////////////////////////////////////////////////////////////////////// - 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; - } - - // ////////////////////////////////////////////////////////////////////// - YieldStore& STDAIR_Service:: - getYieldStore (const AirlineCode_T& iAirlineCode) const { - - YieldStore* lYieldStore_ptr = _bomRoot.getYieldStore (iAirlineCode); - if (lYieldStore_ptr == NULL) { - throw ObjectNotFoundException(); - } - assert (lYieldStore_ptr != NULL); - - return *lYieldStore_ptr; - } - - /** - Note that the AirlineFeature is linked both to the Inventory - and to the AirlineFeatureSet, which in turn is linked to the BomRoot. - There is therefore a duplication of the structure links. - */ - - // ////////////////////////////////////////////////////////////////////// - Inventory& STDAIR_Service:: - createInventory (const AirlineCode_T& iAirlineCode) const { - // Delegate to the dedicated command - Inventory& oInventory = - CmdBomManager::getOrCreateInventory (_bomRoot, iAirlineCode); - return oInventory; - } - - // ////////////////////////////////////////////////////////////////////// - YieldStore& STDAIR_Service:: - createYieldStore (const AirlineCode_T& iAirlineCode) const { - // Delegate to the dedicated command - YieldStore& oYieldStore = - CmdBomManager::getOrCreateYieldStore (_bomRoot, iAirlineCode); - return oYieldStore; - } - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |