From: <den...@us...> - 2010-04-18 00:01:48
|
Revision: 174 http://stdair.svn.sourceforge.net/stdair/?rev=174&view=rev Author: denis_arnaud Date: 2010-04-18 00:01:41 +0000 (Sun, 18 Apr 2010) Log Message: ----------- [Yield] Added YieldStore BOM object (there is some work in CmdBomManager to switch BomRoot and BR). Modified Paths: -------------- trunk/stdair/stdair/STDAIR_Service.hpp trunk/stdair/stdair/batches/stdair.cpp trunk/stdair/stdair/bom/BR.cpp trunk/stdair/stdair/bom/BR.hpp trunk/stdair/stdair/bom/BomRoot.cpp trunk/stdair/stdair/bom/BomRoot.hpp trunk/stdair/stdair/bom/FD.hpp trunk/stdair/stdair/bom/IN.hpp trunk/stdair/stdair/bom/sources.mk trunk/stdair/stdair/command/CmdBomManager.cpp trunk/stdair/stdair/command/CmdBomManager.hpp trunk/stdair/stdair/service/STDAIR_Service.cpp Added Paths: ----------- trunk/stdair/stdair/bom/YieldStore.cpp trunk/stdair/stdair/bom/YieldStore.hpp trunk/stdair/stdair/bom/YieldStoreContent.cpp trunk/stdair/stdair/bom/YieldStoreContent.hpp trunk/stdair/stdair/bom/YieldStoreKey.cpp trunk/stdair/stdair/bom/YieldStoreKey.hpp trunk/stdair/stdair/bom/YieldStoreTypes.hpp Modified: trunk/stdair/stdair/STDAIR_Service.hpp =================================================================== --- trunk/stdair/stdair/STDAIR_Service.hpp 2010-04-09 15:31:37 UTC (rev 173) +++ trunk/stdair/stdair/STDAIR_Service.hpp 2010-04-18 00:01:41 UTC (rev 174) @@ -14,6 +14,7 @@ // Forward declarations class BomRoot; + class YieldStore; class Inventory; /** Interface for the STDAIR Services. */ @@ -48,6 +49,11 @@ <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. @@ -64,6 +70,11 @@ <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; Modified: trunk/stdair/stdair/batches/stdair.cpp =================================================================== --- trunk/stdair/stdair/batches/stdair.cpp 2010-04-09 15:31:37 UTC (rev 173) +++ trunk/stdair/stdair/batches/stdair.cpp 2010-04-18 00:01:41 UTC (rev 174) @@ -23,7 +23,9 @@ // ///////// M A I N //////////// int main (int argc, char* argv[]) { + try { + stdair::BR& lBR = stdair::FacBomContent::instance().testCreate<stdair::BR> (); Modified: trunk/stdair/stdair/bom/BR.cpp =================================================================== --- trunk/stdair/stdair/bom/BR.cpp 2010-04-09 15:31:37 UTC (rev 173) +++ trunk/stdair/stdair/bom/BR.cpp 2010-04-18 00:01:41 UTC (rev 174) @@ -6,6 +6,7 @@ // STDAIR #include <stdair/bom/Structure.hpp> #include <stdair/bom/BR.hpp> +#include <stdair/bom/YieldStore.hpp> #include <stdair/bom/IN.hpp> #include <stdair/bom/BomList.hpp> #include <stdair/bom/BomMap.hpp> @@ -22,6 +23,16 @@ } // //////////////////////////////////////////////////////////////////// + const YieldStoreList_T BR::getYieldStoreList () const { + return _structure.getChildrenHolder<YieldStore>(); + } + + // //////////////////////////////////////////////////////////////////// + const YieldStoreMap_T BR::getYieldStoreMap () const { + return _structure.getChildrenHolder<YieldStore>(); + } + + // //////////////////////////////////////////////////////////////////// const INList_T BR::getINList () const { return _structure.getChildrenHolder<IN>(); } @@ -30,4 +41,5 @@ const INMap_T BR::getINMap () const { return _structure.getChildrenHolder<IN>(); } + } Modified: trunk/stdair/stdair/bom/BR.hpp =================================================================== --- trunk/stdair/stdair/bom/BR.hpp 2010-04-09 15:31:37 UTC (rev 173) +++ trunk/stdair/stdair/bom/BR.hpp 2010-04-18 00:01:41 UTC (rev 174) @@ -11,10 +11,12 @@ // STDAIR #include <stdair/bom/BomRootContent.hpp> #include <stdair/bom/BRTypes.hpp> +#include <stdair/bom/YieldStoreTypes.hpp> #include <stdair/bom/INTypes.hpp> namespace stdair { // Forward declarations. + class YieldStore; class IN; /** Class representing the actual functional/business content @@ -29,6 +31,7 @@ /** Define the list of children holder types. */ typedef boost::fusion::map< + boost::fusion::pair<YieldStore, YieldStoreHolder_T*>, boost::fusion::pair<IN, INHolder_T*> > ChildrenHolderTypeMap_T; /** Definition allowing to retrieve the parent type. */ @@ -59,8 +62,11 @@ public: // /////////// Getters ///////////// + const YieldStoreList_T getYieldStoreList () const; + const YieldStoreMap_T getYieldStoreMap () const; const INList_T getINList () const; const INMap_T getINMap () const; + private: /** Retrieve the BOM structure object. */ @@ -74,7 +80,7 @@ /** Default constructors. */ BR (); BR (const BR&); - BR (const BomKey_T& iKey, BomStructure_T& ioStructure); + BR (const BomKey_T&, BomStructure_T&); /** Destructor. */ virtual ~BR(); Modified: trunk/stdair/stdair/bom/BomRoot.cpp =================================================================== --- trunk/stdair/stdair/bom/BomRoot.cpp 2010-04-09 15:31:37 UTC (rev 173) +++ trunk/stdair/stdair/bom/BomRoot.cpp 2010-04-18 00:01:41 UTC (rev 174) @@ -8,6 +8,7 @@ #include <stdair/bom/BomRoot.hpp> #include <stdair/bom/BomList.hpp> #include <stdair/bom/BomMap.hpp> +#include <stdair/bom/YieldStore.hpp> #include <stdair/bom/Inventory.hpp> #include <stdair/bom/Network.hpp> #include <stdair/bom/DemandStream.hpp> @@ -56,6 +57,23 @@ } // //////////////////////////////////////////////////////////////////// + YieldStore* BomRoot::getYieldStore (const AirlineCode_T& iAirlineCode) const { + YieldStore* oYieldStore_ptr = NULL; + + // TODO: migrate to the new StdAir structure (e.g., IN, FD, etc.) + /* + YieldStoreMap_T lYieldStoreMap = getYieldStoreMap (); + YieldStoreMap_T::iterator itInv = lYieldStoreMap.find (iAirlineCode); + + if (itInv != lYieldStoreMap.end()) { + oYieldStore_ptr = itInv->second; + } + */ + + return oYieldStore_ptr; + } + + // //////////////////////////////////////////////////////////////////// Inventory* BomRoot::getInventory (const AirlineCode_T& iAirlineCode) const { Inventory* oInventory_ptr = NULL; Modified: trunk/stdair/stdair/bom/BomRoot.hpp =================================================================== --- trunk/stdair/stdair/bom/BomRoot.hpp 2010-04-09 15:31:37 UTC (rev 173) +++ trunk/stdair/stdair/bom/BomRoot.hpp 2010-04-18 00:01:41 UTC (rev 174) @@ -15,9 +15,11 @@ #include <stdair/bom/DemandStreamTypes.hpp> namespace stdair { + // Forward declarations. class FacBomContent; class AirlineFeatureSet; + class YieldStore; class DemandStream; struct BomRootKey_T; @@ -141,6 +143,11 @@ <br>If not existing, return the NULL pointer. */ Network* getNetwork (const NetworkID_T&) const; + /** Retrieve, if existing, the YieldStore corresponding to the + given airline code (YieldStore key). + <br>If not existing, return the NULL pointer. */ + YieldStore* getYieldStore (const AirlineCode_T&) const; + /** Retrieve the DemandStream which corresponds to the given key. */ DemandStream& getDemandStream (const DemandStreamKeyStr_T&) const; Modified: trunk/stdair/stdair/bom/FD.hpp =================================================================== --- trunk/stdair/stdair/bom/FD.hpp 2010-04-09 15:31:37 UTC (rev 173) +++ trunk/stdair/stdair/bom/FD.hpp 2010-04-18 00:01:41 UTC (rev 174) @@ -16,6 +16,7 @@ #include <stdair/bom/LDTypes.hpp> namespace stdair { + // Forward declarations. class IN; class SD; Modified: trunk/stdair/stdair/bom/IN.hpp =================================================================== --- trunk/stdair/stdair/bom/IN.hpp 2010-04-09 15:31:37 UTC (rev 173) +++ trunk/stdair/stdair/bom/IN.hpp 2010-04-18 00:01:41 UTC (rev 174) @@ -15,6 +15,7 @@ #include <stdair/bom/NDTypes.hpp> namespace stdair { + // Forward declarations. class BR; class FD; Added: trunk/stdair/stdair/bom/YieldStore.cpp =================================================================== --- trunk/stdair/stdair/bom/YieldStore.cpp (rev 0) +++ trunk/stdair/stdair/bom/YieldStore.cpp 2010-04-18 00:01:41 UTC (rev 174) @@ -0,0 +1,25 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +// STDAIR +#include <stdair/bom/Structure.hpp> +#include <stdair/bom/BR.hpp> +#include <stdair/bom/YieldStore.hpp> +#include <stdair/bom/BomList.hpp> +#include <stdair/bom/BomMap.hpp> + +namespace stdair { + + // //////////////////////////////////////////////////////////////////// + YieldStore::YieldStore (const BomKey_T& iKey, + BomStructure_T& ioYieldStoreStructure) + : YieldStoreContent (iKey), _structure (ioYieldStoreStructure) { + } + + // //////////////////////////////////////////////////////////////////// + YieldStore::~YieldStore () { + } + +} Added: trunk/stdair/stdair/bom/YieldStore.hpp =================================================================== --- trunk/stdair/stdair/bom/YieldStore.hpp (rev 0) +++ trunk/stdair/stdair/bom/YieldStore.hpp 2010-04-18 00:01:41 UTC (rev 174) @@ -0,0 +1,87 @@ +#ifndef __STDAIR_BOM_YIELDSTORE_HPP +#define __STDAIR_BOM_YIELDSTORE_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <iosfwd> +// BOOST Fusion +#include <boost/fusion/include/map.hpp> +// STDAIR +#include <stdair/bom/YieldStoreContent.hpp> +#include <stdair/bom/YieldStoreTypes.hpp> + +namespace stdair { + + // Forward declarations. + class BR; + + /** Class representing the actual functional/business content + for the Bom root. */ + class YieldStore : public YieldStoreContent { + friend class FacBomContent; + + public: + // ///////////////////////////////////////////////////////////////////////// + /** Definition allowing to retrieve the associated parent. */ + typedef BR Parent_T; + + /** Definition allowing to retrieve the associated BOM structure type. */ + typedef YieldStoreStructure_T BomStructure_T; + + /** Define the list of children holder types. */ + typedef boost::fusion::map< > ChildrenHolderTypeMap_T; + // ///////////////////////////////////////////////////////////////////////// + + public: + // /////////// Getters ///////////// + + + private: + /** Retrieve the BOM structure object. */ + BomStructure_T& getStructure () { + return _structure; + } + + + 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 _key.toString(); } + + /** Get a string describing the short key (differentiating two objects + at the same level). */ + const std::string describeShortKey() const { return _key.toString(); } + + + protected: + /** Constructors are private so as to force the usage of the Factory + layer. */ + /** Default constructors. */ + YieldStore (); + YieldStore (const YieldStore&); + YieldStore (const BomKey_T& iKey, BomStructure_T& ioStructure); + /** Destructor. */ + virtual ~YieldStore(); + + private: + // Attributes + /** Reference structure. */ + BomStructure_T& _structure; + }; + +} +#endif // __STDAIR_BOM_YIELDSTORE_HPP Added: trunk/stdair/stdair/bom/YieldStoreContent.cpp =================================================================== --- trunk/stdair/stdair/bom/YieldStoreContent.cpp (rev 0) +++ trunk/stdair/stdair/bom/YieldStoreContent.cpp 2010-04-18 00:01:41 UTC (rev 174) @@ -0,0 +1,20 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +// STDAIR +#include <stdair/bom/YieldStoreContent.hpp> + +namespace stdair { + + // //////////////////////////////////////////////////////////////////// + YieldStoreContent::YieldStoreContent (const BomKey_T& iKey) : _key (iKey) { + } + + // //////////////////////////////////////////////////////////////////// + YieldStoreContent::~YieldStoreContent () { + } + +} + Added: trunk/stdair/stdair/bom/YieldStoreContent.hpp =================================================================== --- trunk/stdair/stdair/bom/YieldStoreContent.hpp (rev 0) +++ trunk/stdair/stdair/bom/YieldStoreContent.hpp 2010-04-18 00:01:41 UTC (rev 174) @@ -0,0 +1,75 @@ +#ifndef __STDAIR_BOM_YIELDSTORECONTENT_HPP +#define __STDAIR_BOM_YIELDSTORECONTENT_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STDAIR +#include <stdair/STDAIR_Types.hpp> +#include <stdair/bom/BomContent.hpp> +#include <stdair/bom/YieldStoreKey.hpp> + +namespace stdair { + + /** Class representing the actual attributes for an airline YieldStore. */ + class YieldStoreContent : public BomContent { + public : + // Type definitions + /** Definition allowing to retrieve the associated BOM key type. */ + typedef YieldStoreKey_T BomKey_T; + + 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: + // ////////// Getters //////////// + /** Get the airline code. */ + const AirlineCode_T& getAirlineCode () const { + return _key.getAirlineCode(); + } + + /** Get the YieldStore key. */ + const BomKey_T& getKey() const { + return _key; + } + + + public: + // ///////// Setters ////////// + + + protected: + /** Default constructors. */ + YieldStoreContent (const BomKey_T&); + YieldStoreContent (const YieldStoreContent&); + + /** Destructor. */ + virtual ~YieldStoreContent(); + + protected: + // Attributes + /** The key of both structure and content objects. */ + BomKey_T _key; + }; + +} +#endif // __STDAIR_BOM_YIELDSTORECONTENT_HPP + Added: trunk/stdair/stdair/bom/YieldStoreKey.cpp =================================================================== --- trunk/stdair/stdair/bom/YieldStoreKey.cpp (rev 0) +++ trunk/stdair/stdair/bom/YieldStoreKey.cpp 2010-04-18 00:01:41 UTC (rev 174) @@ -0,0 +1,43 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STDAIR +#include <stdair/bom/YieldStoreKey.hpp> + +namespace stdair { + + // //////////////////////////////////////////////////////////////////// + YieldStoreKey_T::YieldStoreKey_T (const AirlineCode_T& iAirlineCode) + : _airlineCode (iAirlineCode) { + } + // //////////////////////////////////////////////////////////////////// + YieldStoreKey_T::YieldStoreKey_T (const YieldStoreKey_T& iKey) + : _airlineCode (iKey._airlineCode) { + } + + // //////////////////////////////////////////////////////////////////// + YieldStoreKey_T::~YieldStoreKey_T () { + } + + // //////////////////////////////////////////////////////////////////// + void YieldStoreKey_T::toStream (std::ostream& ioOut) const { + ioOut << "YieldStoreKey: " << toString() << std::endl; + } + + // //////////////////////////////////////////////////////////////////// + void YieldStoreKey_T::fromStream (std::istream& ioIn) { + } + + // //////////////////////////////////////////////////////////////////// + const std::string YieldStoreKey_T::toString() const { + std::ostringstream oStr; + oStr << _airlineCode; + return oStr.str(); + } + + // //////////////////////////////////////////////////////////////////// + const std::string YieldStoreKey_T::describe() const { + return toString(); + } + +} Added: trunk/stdair/stdair/bom/YieldStoreKey.hpp =================================================================== --- trunk/stdair/stdair/bom/YieldStoreKey.hpp (rev 0) +++ trunk/stdair/stdair/bom/YieldStoreKey.hpp 2010-04-18 00:01:41 UTC (rev 174) @@ -0,0 +1,70 @@ +#ifndef __STDAIR_BOM_YIELDSTOREKEY_HPP +#define __STDAIR_BOM_YIELDSTOREKEY_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STDAIR +#include <stdair/STDAIR_Types.hpp> +#include <stdair/bom/BomKey.hpp> +#include <stdair/bom/BomRootKey.hpp> + +namespace stdair { + + /** Key of YieldStore. */ + struct YieldStoreKey_T : public BomKey_T { + friend struct FlightDateKey_T; + public: + // /////////// Typedefs //////////// + /** Definition allowing to retrieve the parent key type. */ + typedef BomRootKey_T ParentKey_T; + + private: + // /////////// Default constructor ////////// + YieldStoreKey_T () { }; + + public: + // /////////// Construction /////////// + /** Constructors. */ + YieldStoreKey_T (const AirlineCode_T& iAirlineCode); + YieldStoreKey_T (const YieldStoreKey_T&); + /** Destructor. */ + ~YieldStoreKey_T (); + + // /////////// Getters ////////// + /** Get the airline code. */ + const AirlineCode_T& getAirlineCode() const { + return _airlineCode; + } + + // /////////// 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-date. */ + const std::string toString() const; + + /** Display of the key. */ + const std::string describe() const; + + // /////////// Setters ///////////// + /** Set the parent key. */ + void setParentKey (const ParentKey_T& iParentKey) const { } + + private: + // Attributes + /** Airline code. */ + AirlineCode_T _airlineCode; + }; + +} +#endif // __STDAIR_BOM_YIELDSTOREKEY_HPP Added: trunk/stdair/stdair/bom/YieldStoreTypes.hpp =================================================================== --- trunk/stdair/stdair/bom/YieldStoreTypes.hpp (rev 0) +++ trunk/stdair/stdair/bom/YieldStoreTypes.hpp 2010-04-18 00:01:41 UTC (rev 174) @@ -0,0 +1,32 @@ +// ////////////////////////////////////////////////////////////////////// +#ifndef __STDAIR_BOM_YIELDSTORETYPES_HPP +#define __STDAIR_BOM_YIELDSTORETYPES_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// + +namespace stdair { + + // Forward declarations. + template <typename CONTENT> class Structure; + template <typename CONTENT> class BomChildrenHolderImp; + template <typename BOM> struct BomList_T; + template <typename BOM> struct BomMap_T; + class YieldStore; + + /** Define the BomRootStructure. */ + typedef Structure<YieldStore> YieldStoreStructure_T; + + /** Define the Inventory holder type. */ + typedef BomChildrenHolderImp<YieldStore> YieldStoreHolder_T; + + /** Define the Inventory list. */ + typedef BomList_T<YieldStore> YieldStoreList_T; + + /** Define the Inventory map. */ + typedef BomMap_T<YieldStore> YieldStoreMap_T; + +} +#endif // __STDAIR_BOM_YIELDSTORETYPES_HPP + Modified: trunk/stdair/stdair/bom/sources.mk =================================================================== --- trunk/stdair/stdair/bom/sources.mk 2010-04-09 15:31:37 UTC (rev 173) +++ trunk/stdair/stdair/bom/sources.mk 2010-04-18 00:01:41 UTC (rev 174) @@ -3,6 +3,7 @@ $(top_srcdir)/stdair/bom/BomMap.hpp \ $(top_srcdir)/stdair/bom/BomKey.hpp \ $(top_srcdir)/stdair/bom/BomRootKey.hpp \ + $(top_srcdir)/stdair/bom/YieldStoreKey.hpp \ $(top_srcdir)/stdair/bom/InventoryKey.hpp \ $(top_srcdir)/stdair/bom/FlightDateKey.hpp \ $(top_srcdir)/stdair/bom/LegDateKey.hpp \ @@ -98,6 +99,9 @@ $(top_srcdir)/stdair/bom/BomManager.hpp \ $(top_srcdir)/stdair/bom/Structure.hpp \ $(top_srcdir)/stdair/bom/BRTypes.hpp \ + $(top_srcdir)/stdair/bom/YieldStore.hpp \ + $(top_srcdir)/stdair/bom/YieldStoreTypes.hpp \ + $(top_srcdir)/stdair/bom/YieldStoreContent.hpp \ $(top_srcdir)/stdair/bom/IN.hpp \ $(top_srcdir)/stdair/bom/FD.hpp \ $(top_srcdir)/stdair/bom/FDTypes.hpp \ @@ -117,6 +121,7 @@ $(top_srcdir)/stdair/bom/NDTypes.hpp bom_cc_sources = \ $(top_srcdir)/stdair/bom/BomRootKey.cpp \ + $(top_srcdir)/stdair/bom/YieldStoreKey.cpp \ $(top_srcdir)/stdair/bom/InventoryKey.cpp \ $(top_srcdir)/stdair/bom/FlightDateKey.cpp \ $(top_srcdir)/stdair/bom/LegDateKey.cpp \ @@ -171,6 +176,8 @@ $(top_srcdir)/stdair/bom/EventStruct.cpp \ $(top_srcdir)/stdair/bom/EventQueue.cpp \ $(top_srcdir)/stdair/bom/BomManager.cpp \ + $(top_srcdir)/stdair/bom/YieldStore.cpp \ + $(top_srcdir)/stdair/bom/YieldStoreContent.cpp \ $(top_srcdir)/stdair/bom/BR.cpp \ $(top_srcdir)/stdair/bom/IN.cpp \ $(top_srcdir)/stdair/bom/FD.cpp \ Modified: trunk/stdair/stdair/command/CmdBomManager.cpp =================================================================== --- trunk/stdair/stdair/command/CmdBomManager.cpp 2010-04-09 15:31:37 UTC (rev 173) +++ trunk/stdair/stdair/command/CmdBomManager.cpp 2010-04-18 00:01:41 UTC (rev 174) @@ -6,6 +6,8 @@ // Boost #include <boost/make_shared.hpp> // StdAir +#include <stdair/bom/BR.hpp> +#include <stdair/bom/YieldStore.hpp> #include <stdair/bom/BomRoot.hpp> #include <stdair/bom/AirlineFeatureSet.hpp> #include <stdair/bom/AirlineFeature.hpp> @@ -79,7 +81,6 @@ if (lInventory_ptr == NULL) { const InventoryKey_T lInventoryKey (iAirlineCode); - // Instantiate an Inventory object with the given airline code lInventory_ptr = &createInventoryInternal (ioBomRoot, iAirlineCode); assert (lInventory_ptr != NULL); @@ -109,4 +110,40 @@ return *lInventory_ptr; } + // ////////////////////////////////////////////////////////////////////// + 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().testCreate<YieldStore> (lYieldStoreKey); + + // TODO: migrate to the new StdAir structure (e.g., IN, FD, etc.) + // Link the created YieldStore with the bom root. + // FacBomContent::testLink<YieldStore> (lYieldStore, ioBomRoot); + + return lYieldStore; + } + + // ////////////////////////////////////////////////////////////////////// + YieldStore& CmdBomManager:: + getOrCreateYieldStore (BomRoot& ioBomRoot, + const AirlineCode_T& iAirlineCode) { + YieldStore* lYieldStore_ptr = ioBomRoot.getYieldStore (iAirlineCode); + + // If there is no YieldStore object for that airline already, create one + if (lYieldStore_ptr == NULL) { + const YieldStoreKey_T lYieldStoreKey (iAirlineCode); + + // Instantiate a YieldStore object with the given airline code + lYieldStore_ptr = &createYieldStoreInternal (ioBomRoot, iAirlineCode); + assert (lYieldStore_ptr != NULL); + } + assert (lYieldStore_ptr != NULL); + + return *lYieldStore_ptr; + } + } Modified: trunk/stdair/stdair/command/CmdBomManager.hpp =================================================================== --- trunk/stdair/stdair/command/CmdBomManager.hpp 2010-04-09 15:31:37 UTC (rev 173) +++ trunk/stdair/stdair/command/CmdBomManager.hpp 2010-04-18 00:01:41 UTC (rev 174) @@ -30,6 +30,18 @@ created . */ static Inventory& getOrCreateInventory (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&); + /** Initialise the AirlineFeatureSet object, and attach it to the BomRoot. @param BomRoot& Root of the BOM tree. */ static void initAirlineFeatureSet (BomRoot&); @@ -54,6 +66,14 @@ @param const AirlineCode_T& Airline code for the inventory to be created . */ static Inventory& createInventoryInternal (BomRoot&, const AirlineCode_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&); }; } Modified: trunk/stdair/stdair/service/STDAIR_Service.cpp =================================================================== --- trunk/stdair/stdair/service/STDAIR_Service.cpp 2010-04-09 15:31:37 UTC (rev 173) +++ trunk/stdair/stdair/service/STDAIR_Service.cpp 2010-04-18 00:01:41 UTC (rev 174) @@ -9,6 +9,7 @@ #include <stdair/bom/BomRoot.hpp> #include <stdair/bom/Network.hpp> #include <stdair/bom/Inventory.hpp> +#include <stdair/bom/YieldStore.hpp> #include <stdair/factory/FacSupervisor.hpp> #include <stdair/factory/FacBomContent.hpp> #include <stdair/command/CmdBomManager.hpp> @@ -129,6 +130,19 @@ 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. @@ -144,4 +158,13 @@ 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. |