From: <qua...@us...> - 2010-09-15 12:50:15
|
Revision: 331 http://stdair.svn.sourceforge.net/stdair/?rev=331&view=rev Author: quannaus Date: 2010-09-15 12:50:01 +0000 (Wed, 15 Sep 2010) Log Message: ----------- [dev] New architecture for stdair. Modified Paths: -------------- trunk/stdair/batches/stdair.cpp trunk/stdair/configure.ac trunk/stdair/stdair/STDAIR_Types.hpp trunk/stdair/stdair/bom/BomAbstract.hpp trunk/stdair/stdair/bom/BomManager.hpp trunk/stdair/stdair/bom/BomRoot.hpp trunk/stdair/stdair/bom/BookingClass.cpp trunk/stdair/stdair/bom/BookingClass.hpp trunk/stdair/stdair/bom/Bucket.cpp trunk/stdair/stdair/bom/Bucket.hpp trunk/stdair/stdair/bom/FlightDate.cpp trunk/stdair/stdair/bom/FlightDate.hpp trunk/stdair/stdair/bom/FlightPeriod.cpp trunk/stdair/stdair/bom/FlightPeriod.hpp trunk/stdair/stdair/bom/Inventory.cpp trunk/stdair/stdair/bom/Inventory.hpp trunk/stdair/stdair/bom/LegCabin.cpp trunk/stdair/stdair/bom/LegCabin.hpp trunk/stdair/stdair/bom/LegDate.cpp trunk/stdair/stdair/bom/LegDate.hpp trunk/stdair/stdair/bom/SegmentCabin.cpp trunk/stdair/stdair/bom/SegmentCabin.hpp trunk/stdair/stdair/bom/SegmentDate.cpp trunk/stdair/stdair/bom/SegmentDate.hpp trunk/stdair/stdair/bom/SegmentPeriod.cpp trunk/stdair/stdair/bom/SegmentPeriod.hpp trunk/stdair/stdair/bom/YieldStore.cpp trunk/stdair/stdair/bom/YieldStore.hpp trunk/stdair/stdair/bom/sources.mk trunk/stdair/stdair/command/CmdBomManager.hpp trunk/stdair/stdair/factory/FacBomManager.cpp trunk/stdair/stdair/factory/FacBomManager.hpp trunk/stdair/stdair/service/FacSupervisor.cpp trunk/stdair/stdair/service/FacSupervisor.hpp trunk/stdair/test/Makefile.am trunk/stdair/test/archi_intru/RelationShipHolderSet.hpp trunk/stdair/test/archi_static_cast/BomRoot.cpp trunk/stdair/test/archi_static_cast/BomRoot.hpp trunk/stdair/test/archi_static_cast/Inventory.cpp trunk/stdair/test/archi_static_cast/Inventory.hpp trunk/stdair/test/archi_static_cast/Makefile.am trunk/stdair/test/archi_static_cast/sources.mk Added Paths: ----------- trunk/stdair/stdair/bom/BomHolder.hpp trunk/stdair/stdair/bom/BomHolderKey.cpp trunk/stdair/stdair/bom/BomHolderKey.hpp trunk/stdair/test/archi_static_cast/ trunk/stdair/test/archi_static_cast/BomHolder.hpp trunk/stdair/test/archi_static_cast/BomManager.hpp trunk/stdair/test/archi_static_cast/FacBom.hpp trunk/stdair/test/archi_static_cast/FacBomManager.hpp trunk/stdair/test/archi_static_cast/Types.hpp trunk/stdair/test/archi_static_cast/archi_static_cast.cpp Removed Paths: ------------- trunk/stdair/stdair/bom/RelationShip.hpp trunk/stdair/stdair/bom/RelationShipAbstract.hpp trunk/stdair/test/archi_static_cast/architecture.cpp Modified: trunk/stdair/batches/stdair.cpp =================================================================== --- trunk/stdair/batches/stdair.cpp 2010-09-13 06:49:06 UTC (rev 330) +++ trunk/stdair/batches/stdair.cpp 2010-09-15 12:50:01 UTC (rev 331) @@ -167,13 +167,13 @@ const stdair::InventoryKey lBAKey ("BA"); stdair::Inventory& lBAInv = stdair::FacBom<stdair::Inventory>::instance().create (lBAKey); - stdair::FacBomManager::addToList (lBomRoot, lBAInv); + stdair::FacBomManager::instance().addToList (lBomRoot, lBAInv); // Create an Inventory for AF const stdair::InventoryKey lAFKey ("AF"); stdair::Inventory& lAFInv = stdair::FacBom<stdair::Inventory>::instance().create (lAFKey); - stdair::FacBomManager::addToList (lBomRoot, lAFInv); + stdair::FacBomManager::instance().addToList (lBomRoot, lAFInv); // ////// BA /////// // Step 0.2: Flight-date level @@ -184,7 +184,7 @@ stdair::FlightDate& lBA15_20100610_FD = stdair::FacBom<stdair::FlightDate>::instance().create (lFlightDateKey); - stdair::FacBomManager::addToList (lBAInv, lBA15_20100610_FD); + stdair::FacBomManager::instance().addToList (lBAInv, lBA15_20100610_FD); // Display the flight-date // STDAIR_LOG_DEBUG ("FlightDate: " << lBA15_20100610_FD.toString()); @@ -197,7 +197,8 @@ stdair::SegmentDate& lLHRSYDSegment = stdair::FacBom<stdair::SegmentDate>::instance().create (lSegmentDateKey); - stdair::FacBomManager::addToList (lBA15_20100610_FD, lLHRSYDSegment); + stdair::FacBomManager::instance().addToList (lBA15_20100610_FD, + lLHRSYDSegment); // Display the segment-date // STDAIR_LOG_DEBUG ("SegmentDate: " << lLHRSYDSegment.toString()); @@ -208,7 +209,8 @@ stdair::SegmentDate& lLHRBKKSegment = stdair::FacBom<stdair::SegmentDate>::instance().create (lSegmentDateKey); - stdair::FacBomManager::addToList (lBA15_20100610_FD, lLHRBKKSegment); + stdair::FacBomManager::instance().addToList (lBA15_20100610_FD, + lLHRBKKSegment); // Display the segment-date // STDAIR_LOG_DEBUG ("SegmentDate: " << lLHRBKKSegment.toString()); @@ -219,7 +221,8 @@ stdair::SegmentDate& lBKKSYDSegment = stdair::FacBom<stdair::SegmentDate>::instance().create (lSegmentDateKey); - stdair::FacBomManager::addToList (lBA15_20100610_FD, lBKKSYDSegment); + stdair::FacBomManager::instance().addToList (lBA15_20100610_FD, + lBKKSYDSegment); // Display the segment-date // STDAIR_LOG_DEBUG ("SegmentDate: " << lBKKSYDSegment.toString()); @@ -230,7 +233,7 @@ stdair::LegDate& lLHRLeg = stdair::FacBom<stdair::LegDate>::instance().create (lLegDateKey); - stdair::FacBomManager::addToList (lBA15_20100610_FD, lLHRLeg); + stdair::FacBomManager::instance().addToList (lBA15_20100610_FD, lLHRLeg); // Display the leg-date // STDAIR_LOG_DEBUG ("LegDate: " << lLHRLeg.toString()); @@ -240,7 +243,7 @@ stdair::LegDate& lBKKLeg = stdair::FacBom<stdair::LegDate>::instance().create (lLegDateKey); - stdair::FacBomManager::addToList (lBA15_20100610_FD, lBKKLeg); + stdair::FacBomManager::instance().addToList (lBA15_20100610_FD, lBKKLeg); // Display the leg-date // STDAIR_LOG_DEBUG ("LegDate: " << lBKKLeg.toString()); @@ -252,7 +255,8 @@ stdair::SegmentCabin& lLHRBKKSegmentYCabin = stdair::FacBom<stdair::SegmentCabin>::instance().create(lYSegmentCabinKey); - stdair::FacBomManager::addToList (lLHRBKKSegment, lLHRBKKSegmentYCabin); + stdair::FacBomManager::instance().addToList (lLHRBKKSegment, + lLHRBKKSegmentYCabin); // Display the segment-cabin // STDAIR_LOG_DEBUG ("SegmentCabin: " << lLHRBKKSegmentYCabin.toString()); @@ -260,7 +264,8 @@ // Create a SegmentCabin (Y) of the Segment BKK-SYD; stdair::SegmentCabin& lBKKSYDSegmentYCabin = stdair::FacBom<stdair::SegmentCabin>::instance().create(lYSegmentCabinKey); - stdair::FacBomManager::addToList (lBKKSYDSegment, lBKKSYDSegmentYCabin); + stdair::FacBomManager::instance().addToList (lBKKSYDSegment, + lBKKSYDSegmentYCabin); // Display the segment-cabin // STDAIR_LOG_DEBUG ("SegmentCabin: " << lBKKSYDSegmentYCabin.toString()); @@ -268,7 +273,8 @@ // Create a SegmentCabin (Y) of the Segment LHR-SYD; stdair::SegmentCabin& lLHRSYDSegmentYCabin = stdair::FacBom<stdair::SegmentCabin>::instance().create(lYSegmentCabinKey); - stdair::FacBomManager::addToList (lLHRSYDSegment, lLHRSYDSegmentYCabin); + stdair::FacBomManager::instance().addToList (lLHRSYDSegment, + lLHRSYDSegmentYCabin); // Display the segment-cabin // STDAIR_LOG_DEBUG ("SegmentCabin: " << lLHRSYDSegmentYCabin.toString()); @@ -279,7 +285,7 @@ stdair::LegCabin& lLHRLegYCabin = stdair::FacBom<stdair::LegCabin>::instance().create (lYLegCabinKey); - stdair::FacBomManager::addToList (lLHRLeg, lLHRLegYCabin); + stdair::FacBomManager::instance().addToList (lLHRLeg, lLHRLegYCabin); // Display the leg-cabin // STDAIR_LOG_DEBUG ("LegCabin: " << lLHRLegYCabin.toString()); @@ -287,7 +293,7 @@ // Create a LegCabin (Y) for the Leg BKK-SYD stdair::LegCabin& lBKKLegYCabin = stdair::FacBom<stdair::LegCabin>::instance().create (lYLegCabinKey); - stdair::FacBomManager::addToList (lBKKLeg, lBKKLegYCabin); + stdair::FacBomManager::instance().addToList (lBKKLeg, lBKKLegYCabin); // Display the leg-cabin // STDAIR_LOG_DEBUG ("LegCabin: " << lBKKLegYCabin.toString()); @@ -299,8 +305,8 @@ stdair::BookingClass& lLHRBKKSegmentYCabinQClass = stdair::FacBom<stdair::BookingClass>::instance().create(lQBookingClassKey); - stdair::FacBomManager::addToList (lLHRBKKSegmentYCabin, - lLHRBKKSegmentYCabinQClass); + stdair::FacBomManager::instance().addToList (lLHRBKKSegmentYCabin, + lLHRBKKSegmentYCabinQClass); // Display the booking class // STDAIR_LOG_DEBUG ("BookingClass: " @@ -309,9 +315,9 @@ // Create a BookingClass (Q) for the Segment BKK-LHR, cabin Y stdair::BookingClass& lBKKSYDSegmentYCabinQClass = stdair::FacBom<stdair::BookingClass>::instance().create(lQBookingClassKey); - stdair::FacBomManager::addToList (lBKKSYDSegmentYCabin, - lBKKSYDSegmentYCabinQClass); - + stdair::FacBomManager::instance().addToList (lBKKSYDSegmentYCabin, + lBKKSYDSegmentYCabinQClass); + // Display the booking class // STDAIR_LOG_DEBUG ("BookingClass: " // << lLHRBKKSegmentYCabinQClass.toString()); @@ -319,8 +325,8 @@ // Create a BookingClass (Q) for the Segment LHR-SYD, cabin Y stdair::BookingClass& lLHRSYDSegmentYCabinQClass = stdair::FacBom<stdair::BookingClass>::instance().create(lQBookingClassKey); - stdair::FacBomManager::addToList (lLHRSYDSegmentYCabin, - lLHRSYDSegmentYCabinQClass); + stdair::FacBomManager::instance().addToList (lLHRSYDSegmentYCabin, + lLHRSYDSegmentYCabinQClass); // Display the booking class // STDAIR_LOG_DEBUG ("BookingClass: " @@ -336,7 +342,7 @@ stdair::FlightDate& lAF102_20100320_FD = stdair::FacBom<stdair::FlightDate>::instance().create (lFlightDateKey); - stdair::FacBomManager::addToList (lAFInv, lAF102_20100320_FD); + stdair::FacBomManager::instance().addToList (lAFInv, lAF102_20100320_FD); // Display the flight-date // STDAIR_LOG_DEBUG ("FlightDate: " << lAF102_20100320_FD.toString()); @@ -349,7 +355,8 @@ stdair::SegmentDate& lCDGSFOSegment = stdair::FacBom<stdair::SegmentDate>::instance().create (lSegmentDateKey); - stdair::FacBomManager::addToList (lAF102_20100320_FD, lCDGSFOSegment); + stdair::FacBomManager::instance().addToList (lAF102_20100320_FD, + lCDGSFOSegment); // Display the segment-date // STDAIR_LOG_DEBUG ("SegmentDate: " << lCDGSFOSegment.toString()); @@ -360,7 +367,7 @@ stdair::LegDate& lCDGLeg = stdair::FacBom<stdair::LegDate>::instance().create (lLegDateKey); - stdair::FacBomManager::addToList (lAF102_20100320_FD, lCDGLeg); + stdair::FacBomManager::instance().addToList (lAF102_20100320_FD, lCDGLeg); // Display the leg-date // STDAIR_LOG_DEBUG ("LegDate: " << lCDGLeg.toString()); @@ -369,7 +376,8 @@ // Create a SegmentCabin (Y) for the Segment CDG-SFO of AF's Inventory stdair::SegmentCabin& lCDGSFOSegmentYCabin = stdair::FacBom<stdair::SegmentCabin>::instance().create(lYSegmentCabinKey); - stdair::FacBomManager::addToList (lCDGSFOSegment, lCDGSFOSegmentYCabin); + stdair::FacBomManager::instance().addToList (lCDGSFOSegment, + lCDGSFOSegmentYCabin); // Display the segment-cabin // STDAIR_LOG_DEBUG ("SegmentCabin: " << lCDGSFOSegmentYCabin.toString()); @@ -378,7 +386,7 @@ // Create a LegCabin (Y) for the Leg CDG-SFO on AF's Inventory stdair::LegCabin& lCDGLegYCabin = stdair::FacBom<stdair::LegCabin>::instance().create (lYLegCabinKey); - stdair::FacBomManager::addToList (lCDGLeg, lCDGLegYCabin); + stdair::FacBomManager::instance().addToList (lCDGLeg, lCDGLegYCabin); // Display the leg-cabin // STDAIR_LOG_DEBUG ("LegCabin: " << lLHRLegYCabin.toString()); @@ -387,8 +395,8 @@ // Create a BookingClass (Q) for the Segment CDG-SFO, cabin Y on AF's Inv stdair::BookingClass& lCDGSFOSegmentYCabinQClass = stdair::FacBom<stdair::BookingClass>::instance().create(lQBookingClassKey); - stdair::FacBomManager::addToList (lCDGSFOSegmentYCabin, - lCDGSFOSegmentYCabinQClass); + stdair::FacBomManager::instance().addToList (lCDGSFOSegmentYCabin, + lCDGSFOSegmentYCabinQClass); // Display the booking class // STDAIR_LOG_DEBUG ("BookingClass: " Modified: trunk/stdair/configure.ac =================================================================== --- trunk/stdair/configure.ac 2010-09-13 06:49:06 UTC (rev 330) +++ trunk/stdair/configure.ac 2010-09-15 12:50:01 UTC (rev 331) @@ -224,6 +224,7 @@ test/inheritance/Makefile test/architecture/Makefile test/archi_intru/Makefile + test/archi_static_cast/Makefile test/mpl/Makefile test/mpl/contrib/Makefile test/stdair/Makefile Modified: trunk/stdair/stdair/STDAIR_Types.hpp =================================================================== --- trunk/stdair/stdair/STDAIR_Types.hpp 2010-09-13 06:49:06 UTC (rev 330) +++ trunk/stdair/stdair/STDAIR_Types.hpp 2010-09-15 12:50:01 UTC (rev 331) @@ -41,7 +41,7 @@ class NonInitialisedContainerException : public RootException { }; - class NonInitialisedRelationShip : public RootException { }; + class NonInitialisedRelationShipException : public RootException { }; class MemoryAllocationException : public RootException { }; @@ -478,7 +478,7 @@ } -#define CATCH \ +#define CATCH_ALL_EXCEPTIONS \ catch (const stdair::FileNotFoundException& ex) { \ std::cerr << "FileNotFoundException" << std::endl; \ return -1; \ @@ -499,8 +499,8 @@ std::cerr << "NonInitialisedContainerException" << std::endl; \ return -1; \ \ - } catch (const stdair::NonInitialisedRelationShip& ex) { \ - std::cerr << "NonInitialisedRelationShip" << std::endl; \ + } catch (const stdair::NonInitialisedRelationShipException& ex) { \ + std::cerr << "NonInitialisedRelationShipException" << std::endl; \ return -1; \ \ } catch (const stdair::MemoryAllocationException& ex) { \ Modified: trunk/stdair/stdair/bom/BomAbstract.hpp =================================================================== --- trunk/stdair/stdair/bom/BomAbstract.hpp 2010-09-13 06:49:06 UTC (rev 330) +++ trunk/stdair/stdair/bom/BomAbstract.hpp 2010-09-15 12:50:01 UTC (rev 331) @@ -12,6 +12,8 @@ // STL #include <iosfwd> #include <string> +#include <map> +#include <typeinfo> // StdAir #include <stdair/STDAIR_Types.hpp> @@ -42,7 +44,10 @@ public: /** Destructor. */ virtual ~BomAbstract() {} - }; + }; + + /* Define the map of object holder type. */ + typedef std::map<const std::type_info*, BomAbstract*> HolderMap_T; } /** Copied: trunk/stdair/stdair/bom/BomHolder.hpp (from rev 330, trunk/stdair/test/architecture/BomRoot.hpp) =================================================================== --- trunk/stdair/stdair/bom/BomHolder.hpp (rev 0) +++ trunk/stdair/stdair/bom/BomHolder.hpp 2010-09-15 12:50:01 UTC (rev 331) @@ -0,0 +1,63 @@ +#ifndef __STDAIR_BOM_BOMHOLDER_HPP +#define __STDAIR_BOM_BOMHOLDER_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <string> +#include <list> +#include <map> +// StdAir +#include <stdair/bom/BomAbstract.hpp> +#include <stdair/bom/BomHolderKey.hpp> + +namespace stdair { + /** Class representing the holders of BOM. */ + template <typename BOM> + class BomHolder : public stdair::BomAbstract { + template <typename> friend class FacBom; + friend class FacBomManager; + + public: + // Type definitions. + /** Definition allowing to retrieve the associated BOM key type. */ + typedef stdair::BomHolderKey Key_T; + + // Definition of diffrent container types. + typedef std::list<BOM*> BomList_T; + typedef std::map<const MapKey_T, BOM*> BomMap_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(); } + + /** 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 ""; } + + /** Get a string describing the key. */ + const std::string describeKey() const { return ""; } + + protected: + /** Default constructors. */ + BomHolder (); + BomHolder (const BomHolder&); + BomHolder (const Key_T& iKey) : _key (iKey) { } + /** Destructor. */ + ~BomHolder() { }; + + public: + // Attributes + Key_T _key; + BomList_T _bomList; + BomMap_T _bomMap; + }; + +} +#endif // __STDAIR_BOM_BOMHOLDER_HPP Copied: trunk/stdair/stdair/bom/BomHolderKey.cpp (from rev 330, trunk/stdair/stdair/bom/BomRootKey.cpp) =================================================================== --- trunk/stdair/stdair/bom/BomHolderKey.cpp (rev 0) +++ trunk/stdair/stdair/bom/BomHolderKey.cpp 2010-09-15 12:50:01 UTC (rev 331) @@ -0,0 +1,33 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STDAIR +#include <stdair/bom/BomHolderKey.hpp> + +namespace stdair { + + // //////////////////////////////////////////////////////////////////// + BomHolderKey::BomHolderKey () { + } + + // //////////////////////////////////////////////////////////////////// + BomHolderKey::~BomHolderKey () { + } + + // //////////////////////////////////////////////////////////////////// + void BomHolderKey::toStream (std::ostream& ioOut) const { + ioOut << "BomHolderKey: " << toString() << std::endl; + } + + // //////////////////////////////////////////////////////////////////// + void BomHolderKey::fromStream (std::istream& ioIn) { + } + + // //////////////////////////////////////////////////////////////////// + const std::string BomHolderKey::toString() const { + std::ostringstream oStr; + oStr << " -- HOLDER -- "; + return oStr.str(); + } + +} Copied: trunk/stdair/stdair/bom/BomHolderKey.hpp (from rev 330, trunk/stdair/stdair/bom/BomRootKey.hpp) =================================================================== --- trunk/stdair/stdair/bom/BomHolderKey.hpp (rev 0) +++ trunk/stdair/stdair/bom/BomHolderKey.hpp 2010-09-15 12:50:01 UTC (rev 331) @@ -0,0 +1,43 @@ +#ifndef __STDAIR_BOM_BOMHOLDERKEY_HPP +#define __STDAIR_BOM_BOMHOLDERKEY_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STDAIR +#include <stdair/bom/KeyAbstract.hpp> + +namespace stdair { + /** Key of the BOM structure holder. */ + struct BomHolderKey : public KeyAbstract { + + public: + // /////////// Construction /////////// + /** Constructor. */ + BomHolderKey (); + /** Destructor. */ + ~BomHolderKey (); + + // /////////// 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; + + }; + +} +#endif // __STDAIR_BOM_BOMHOLDERKEY_HPP Modified: trunk/stdair/stdair/bom/BomManager.hpp =================================================================== --- trunk/stdair/stdair/bom/BomManager.hpp 2010-09-13 06:49:06 UTC (rev 330) +++ trunk/stdair/stdair/bom/BomManager.hpp 2010-09-15 12:50:01 UTC (rev 331) @@ -7,151 +7,185 @@ // STL #include <iosfwd> // STDAIR -#include <stdair/bom/RelationShip.hpp> +#include <stdair/STDAIR_Types.hpp> +#include <stdair/bom/BomAbstract.hpp> +#include <stdair/bom/BomHolder.hpp> +#include <stdair/service/Logger.hpp> namespace stdair { /** Utility class for StdAir objects. */ class BomManager { + friend class FacBomManager; + public: - /** Get the list of BOM objects within the given parent. */ - template <typename CHILD, typename PARENT> - static std::list<CHILD*>& getList (const PARENT&); - template <typename CHILD, typename PARENT> - static std::list<std::pair<MapKey_T, CHILD*> >& getDetailedList (const PARENT&); - template <typename CHILD, typename PARENT> - static std::map<const MapKey_T, CHILD*>& getMap (const PARENT&); + /** Get the container of object2 within the object1. */ + template <typename OBJECT2, typename OBJECT1> + static const std::list<OBJECT2*>& getList (const OBJECT1&); + template <typename OBJECT2, typename OBJECT1> + static const std::map<const MapKey_T, OBJECT2*>& getMap (const OBJECT1&); - /** Get the map of parent and children holder. */ - template <typename PARENT, typename CHILD> - static const std::map<const PARENT*, - std::list<CHILD*> >& getParentChildrenList(); - template <typename PARENT, typename CHILD> - static const std::map<const PARENT*, - std::map<const MapKey_T, CHILD*> >& getParentChildrenMap(); + /** Check if the list/map of object2 has benn initialised. */ + template <typename OBJECT2, typename OBJECT1> + static bool hasList (const OBJECT1&); + template <typename OBJECT2, typename OBJECT1> + static bool hasMap (const OBJECT1&); - /** Check if the list/map of children has been initialised. */ - template <typename CHILD, typename PARENT> - static bool hasList (const PARENT&); - template <typename CHILD, typename PARENT> - static bool hasDetailedList (const PARENT&); - template <typename CHILD, typename PARENT> - static bool hasMap (const PARENT&); - /** Getter of the PARENT given the CHILD. */ template <typename PARENT, typename CHILD> static PARENT& getParent (const CHILD&); - /** Return the CHILD pointer corresponding to the given string key. - If such a CHILD does not exist, return NULL. */ - template <typename CHILD, typename PARENT> - static CHILD* getChildPtr (const PARENT&, const MapKey_T&); - template <typename BOM> - static BOM* const getObjectPtr (const std::map<const MapKey_T, BOM*>&, - const MapKey_T&); + /** Return the OBJECT2 pointer corresponding to the given string key. + If such a OBJECT2 does not exist, return NULL. */ + template <typename OBJECT2, typename OBJECT1> + static OBJECT2* getObjectPtr (const OBJECT1&, const MapKey_T&); - /** Return the CHILD corresponding the the given string key. */ - template <typename CHILD, typename PARENT> - static CHILD& getChild (const PARENT&, const MapKey_T&); - template <typename BOM> - static BOM& getObject (const std::map<const MapKey_T, BOM*>&, - const MapKey_T&); + /** Return the OBJECT2 corresponding the the given string key. */ + template <typename OBJECT2, typename OBJECT1> + static OBJECT2& getObject (const OBJECT1&, const MapKey_T&); + + + private: + /** Get the holder of object2 within the object1. If the holder does not + exist, then throw an exception. */ + template <typename OBJECT2, typename OBJECT1> + static const BomHolder<OBJECT2>& getBomHolder (const OBJECT1&); }; // //////////////////////////////////////////////////////////////////// - template <typename CHILD, typename PARENT> std::list<CHILD*>& BomManager:: - getList (const PARENT& iParent) { - return RelationShip<PARENT, CHILD>::instance().getChildrenList (iParent); - } + template <typename OBJECT2, typename OBJECT1> + const BomHolder<OBJECT2>& BomManager::getBomHolder (const OBJECT1& iObject1) { + const HolderMap_T& lHolderMap = iObject1.getHolderMap(); + + HolderMap_T::const_iterator itHolder = lHolderMap.find (&typeid (OBJECT2)); + + if (itHolder == lHolderMap.end()) { + std::string lName (typeid (OBJECT2).name()); + + STDAIR_LOG_ERROR ("Cannot find the holder of type " << lName + << " within: " << iObject1.describeKey()); + throw NonInitialisedContainerException (); + } + + const BomHolder<OBJECT2>* lBomHolder_ptr = + static_cast<const BomHolder<OBJECT2>*> (itHolder->second); + assert (lBomHolder_ptr != NULL); - // //////////////////////////////////////////////////////////////////// - template <typename CHILD, typename PARENT> - std::list<std::pair<MapKey_T, CHILD*> >& BomManager:: - getDetailedList (const PARENT& iParent) { - return RelationShip<PARENT, CHILD>:: - instance().getChildrenDetailedList (iParent); + return *lBomHolder_ptr; } - + // //////////////////////////////////////////////////////////////////// - template <typename CHILD, typename PARENT> std::map<const MapKey_T, CHILD*>& - BomManager::getMap (const PARENT& iParent) { - return RelationShip<PARENT, CHILD>::instance().getChildrenMap (iParent); + template <typename OBJECT2, typename OBJECT1> + const std::list<OBJECT2*>& BomManager::getList (const OBJECT1& iObject1) { + const BomHolder<OBJECT2>& lBomHolder = getBomHolder<OBJECT2> (iObject1); + return lBomHolder._bomList; } - + // //////////////////////////////////////////////////////////////////// - template <typename PARENT, typename CHILD> - const std::map<const PARENT*, std::list<CHILD*> >& BomManager:: - getParentChildrenList() { - return RelationShip<PARENT, CHILD>::instance().getParentChildrenList(); + template <typename OBJECT2, typename OBJECT1> + const std::map<const MapKey_T, OBJECT2*>& BomManager:: + getMap (const OBJECT1& iObject1) { + const BomHolder<OBJECT2>& lBomHolder = getBomHolder<OBJECT2> (iObject1); + return lBomHolder._bomMap; } - + // //////////////////////////////////////////////////////////////////// - template <typename PARENT, typename CHILD> - const std::map<const PARENT*, std::map<const MapKey_T, CHILD*> >& BomManager:: - getParentChildrenMap() { - return RelationShip<PARENT, CHILD>::instance().getParentChildrenMap(); - } + template <typename OBJECT2, typename OBJECT1> + bool BomManager::hasList (const OBJECT1& iObject1) { + const HolderMap_T& lHolderMap = iObject1.getHolderMap(); + HolderMap_T::const_iterator itHolder = lHolderMap.find (&typeid (OBJECT2)); + + if (itHolder == lHolderMap.end()) { + return false; + } + const BomHolder<OBJECT2>* lBomHolder_ptr = + static_cast<const BomHolder<OBJECT2>*> (itHolder->second); + assert (lBomHolder_ptr != NULL); - // //////////////////////////////////////////////////////////////////// - template <typename CHILD, typename PARENT> - bool BomManager::hasList (const PARENT& iParent) { - return RelationShip<PARENT, CHILD>::instance().hasChildrenList (iParent); + return !lBomHolder_ptr._bomList.empty(); } - + // //////////////////////////////////////////////////////////////////// - template <typename CHILD, typename PARENT> - bool BomManager::hasDetailedList (const PARENT& iParent) { - return RelationShip<PARENT, CHILD>:: - instance().hasChildrenDetailedList (iParent); - } + template <typename OBJECT2, typename OBJECT1> + bool BomManager::hasMap (const OBJECT1& iObject1) { + const HolderMap_T& lHolderMap = iObject1.getHolderMap(); + HolderMap_T::const_iterator itHolder = lHolderMap.find (&typeid (OBJECT2)); + + if (itHolder == lHolderMap.end()) { + return false; + } + const BomHolder<OBJECT2>* lBomHolder_ptr = + static_cast<const BomHolder<OBJECT2>*> (itHolder->second); + assert (lBomHolder_ptr != NULL); - // //////////////////////////////////////////////////////////////////// - template <typename CHILD, typename PARENT> - bool BomManager::hasMap (const PARENT& iParent) { - return RelationShip<PARENT, CHILD>::instance().hasChildrenMap (iParent); + return !lBomHolder_ptr._bomMap.empty(); } // //////////////////////////////////////////////////////////////////// template <typename PARENT, typename CHILD> PARENT& BomManager::getParent (const CHILD& iChild) { - return RelationShip<PARENT, CHILD>::instance().getParent (iChild); - } + PARENT* const lParent_ptr = + static_cast<PARENT* const> (iChild.getParent()); + assert (lParent_ptr != NULL); - // //////////////////////////////////////////////////////////////////// - template <typename CHILD, typename PARENT> - CHILD* BomManager::getChildPtr (const PARENT& iParent, const MapKey_T& iKey) { - return RelationShip<PARENT, CHILD>::instance().getChildPtr (iParent, iKey); + return *lParent_ptr; } // //////////////////////////////////////////////////////////////////// - template <typename CHILD, typename PARENT> - CHILD& BomManager::getChild (const PARENT& iParent, const MapKey_T& iKey) { - return RelationShip<PARENT, CHILD>::instance().getChild (iParent, iKey); - } + template <typename OBJECT2, typename OBJECT1> + OBJECT2* BomManager::getObjectPtr (const OBJECT1& iObject1, + const MapKey_T& iKey) { + OBJECT2* oBom_ptr = NULL; + + typedef std::map<const MapKey_T, OBJECT2*> BomMap_T; + const HolderMap_T& lHolderMap = iObject1.getHolderMap(); - // //////////////////////////////////////////////////////////////////// - template <typename BOM> - BOM* const BomManager::getObjectPtr (const std::map<const MapKey_T,BOM*>& iMap, - const MapKey_T& iKey) { - typename std::map<const MapKey_T, BOM*>::const_iterator it = iMap.find (iKey); - if (it == iMap.end()) { - return NULL; + typename HolderMap_T::const_iterator itHolder = + lHolderMap.find (&typeid (OBJECT2)); + + if (itHolder != lHolderMap.end()) { + + BomHolder<OBJECT2>* const lBomHolder_ptr = + static_cast<BomHolder<OBJECT2>* const> (itHolder->second); + assert (lBomHolder_ptr != NULL); + + BomMap_T& lBomMap = lBomHolder_ptr->_bomMap; + + typename BomMap_T::iterator itBom = lBomMap.find (iKey); + + if (itBom != lBomMap.end()) { + oBom_ptr = itBom->second; + assert (oBom_ptr != NULL); + } } - BOM* const oBom_ptr = it->second; - assert (oBom_ptr != NULL); + return oBom_ptr; } // //////////////////////////////////////////////////////////////////// - template <typename BOM> - BOM& BomManager::getObject (const std::map<const MapKey_T, BOM*>& iMap, - const MapKey_T& iKey) { - typename std::map<const MapKey_T, BOM*>::const_iterator it = iMap.find (iKey); - assert (it != iMap.end()); - BOM* const oBom_ptr = it->second; + template <typename OBJECT2, typename OBJECT1> + OBJECT2& BomManager::getObject (const OBJECT1& iObject1, const MapKey_T& iKey){ + + typedef std::map<const MapKey_T, OBJECT2*> BomMap_T; + const BomMap_T& lBomMap = getMap<OBJECT2> (iObject1); + + typename BomMap_T::const_iterator itBom = lBomMap.find (iKey); + + if (itBom == lBomMap.end()) { + std::string lName (typeid (OBJECT2).name()); + + STDAIR_LOG_ERROR ("Cannot find the objet of type " << lName + << " with key " << iKey << " within: " + << iObject1.describeKey()); + assert (false); + } + + OBJECT2* oBom_ptr = itBom->second; assert (oBom_ptr != NULL); + return *oBom_ptr; } + } #endif // __STDAIR_BOM_BOMMANAGER_HPP Modified: trunk/stdair/stdair/bom/BomRoot.hpp =================================================================== --- trunk/stdair/stdair/bom/BomRoot.hpp 2010-09-13 06:49:06 UTC (rev 330) +++ trunk/stdair/stdair/bom/BomRoot.hpp 2010-09-15 12:50:01 UTC (rev 331) @@ -12,6 +12,7 @@ /** Class representing the actual attributes for the Bom root. */ class BomRoot : public BomAbstract { template <typename BOM> friend class FacBom; + friend class FacBomManager; public: /** Definition allowing to retrieve the associated BOM key type. */ @@ -19,10 +20,8 @@ public: // /////////// Getters ////////////// - /** Get the BomRoot key. */ - const Key_T& getKey() const { - return _key; - } + const Key_T& getKey() const { return _key; } + const HolderMap_T& getHolderMap() const { return _holderMap; } public: // /////////// Display support methods ///////// @@ -50,8 +49,8 @@ protected: // Attributes - /** The key of both structure and objects. */ - Key_T _key; + Key_T _key; + HolderMap_T _holderMap; }; } Modified: trunk/stdair/stdair/bom/BookingClass.cpp =================================================================== --- trunk/stdair/stdair/bom/BookingClass.cpp 2010-09-13 06:49:06 UTC (rev 330) +++ trunk/stdair/stdair/bom/BookingClass.cpp 2010-09-15 12:50:01 UTC (rev 331) @@ -11,7 +11,7 @@ namespace stdair { // //////////////////////////////////////////////////////////////////// - BookingClass::BookingClass (const Key_T& iKey) : _key (iKey) { + BookingClass::BookingClass (const Key_T& iKey) : _key (iKey), _parent (NULL) { } // //////////////////////////////////////////////////////////////////// Modified: trunk/stdair/stdair/bom/BookingClass.hpp =================================================================== --- trunk/stdair/stdair/bom/BookingClass.hpp 2010-09-13 06:49:06 UTC (rev 330) +++ trunk/stdair/stdair/bom/BookingClass.hpp 2010-09-15 12:50:01 UTC (rev 331) @@ -14,6 +14,7 @@ /** Class representing the actual attributes for an airline booking class. */ class BookingClass : public BomAbstract { template <typename BOM> friend class FacBom; + friend class FacBomManager; public: // Type definitions. @@ -23,15 +24,17 @@ public: // /////////// Getters //////////// /** Get the booking class key. */ - const Key_T& getKey() const { - return _key; - } + const Key_T& getKey() const { return _key; } /** Get the booking code (part of the primary key). */ - const ClassCode_T& getClassCode() const { - return _key.getClassCode(); - } + const ClassCode_T& getClassCode() const { return _key.getClassCode(); } + /** Get the parent object. */ + BomAbstract* const getParent() const { return _parent; } + + /** Get the map of children holders. */ + const HolderMap_T& getHolderMap() const { return _holderMap; } + public: // /////////// Display support methods ///////// /** Dump a Business Object into an output stream. @@ -63,6 +66,7 @@ public: // Attributes Key_T _key; + BomAbstract* _parent; SubclassCode_T _subclassCode; AuthorizationLevel_T _cumulatedProtection; AuthorizationLevel_T _protection; @@ -78,6 +82,7 @@ Availability_T _netClassAvailability; Availability_T _segmentAvailability; Availability_T _netRevenueAvailability; + HolderMap_T _holderMap; }; Modified: trunk/stdair/stdair/bom/Bucket.cpp =================================================================== --- trunk/stdair/stdair/bom/Bucket.cpp 2010-09-13 06:49:06 UTC (rev 330) +++ trunk/stdair/stdair/bom/Bucket.cpp 2010-09-15 12:50:01 UTC (rev 331) @@ -10,7 +10,7 @@ // //////////////////////////////////////////////////////////////////// Bucket::Bucket (const Key_T& iKey) - : _key (iKey) { + : _key (iKey), _parent (NULL) { } // //////////////////////////////////////////////////////////////////// Modified: trunk/stdair/stdair/bom/Bucket.hpp =================================================================== --- trunk/stdair/stdair/bom/Bucket.hpp 2010-09-13 06:49:06 UTC (rev 330) +++ trunk/stdair/stdair/bom/Bucket.hpp 2010-09-15 12:50:01 UTC (rev 331) @@ -14,6 +14,7 @@ /** Class representing the actual attributes for an airline booking class. */ class Bucket : public BomAbstract { template <typename BOM> friend class FacBom; + friend class FacBomManager; public: // Type definitions. @@ -23,10 +24,14 @@ public: // /////////// Getters //////////// /** Get the booking class key. */ - const Key_T& getKey() const { - return _key; - } + const Key_T& getKey() const { return _key; } + /** Get the parent object. */ + BomAbstract* const getParent() const { return _parent; } + + /** Get the map of children holders. */ + const HolderMap_T& getHolderMap() const { return _holderMap; } + public: // /////////// Display support methods ///////// /** Dump a Business Object into an output stream. @@ -52,8 +57,9 @@ public: // Attributes - /** The key of both structure and objects. */ Key_T _key; + BomAbstract* _parent; + HolderMap_T _holderMap; // test AIRINV stdair::Yield_T _yieldRangeUpperValue; stdair::CabinCapacity_T _availability; Modified: trunk/stdair/stdair/bom/FlightDate.cpp =================================================================== --- trunk/stdair/stdair/bom/FlightDate.cpp 2010-09-13 06:49:06 UTC (rev 330) +++ trunk/stdair/stdair/bom/FlightDate.cpp 2010-09-15 12:50:01 UTC (rev 331) @@ -10,7 +10,7 @@ // //////////////////////////////////////////////////////////////////// FlightDate::FlightDate (const Key_T& iKey) - : _key (iKey) { + : _key (iKey), _parent (NULL) { } // //////////////////////////////////////////////////////////////////// Modified: trunk/stdair/stdair/bom/FlightDate.hpp =================================================================== --- trunk/stdair/stdair/bom/FlightDate.hpp 2010-09-13 06:49:06 UTC (rev 330) +++ trunk/stdair/stdair/bom/FlightDate.hpp 2010-09-15 12:50:01 UTC (rev 331) @@ -14,6 +14,7 @@ /** Class representing the actual attributes for an airline flight-date. */ class FlightDate : public BomAbstract { template <typename BOM> friend class FacBom; + friend class FacBomManager; public: // Type definitions. @@ -23,9 +24,10 @@ public: // /////////// Getters /////////////// /** Get the flight-date key. */ - const Key_T& getKey() const { - return _key; - } + const Key_T& getKey() const { return _key; } + + /** Get the parent object. */ + BomAbstract* const getParent() const { return _parent; } /** Get the flight number (part of the primary key). */ const FlightNumber_T& getFlightNumber() const { @@ -33,10 +35,11 @@ } /** Get the flight date (part of the primary key). */ - const Date_T& getFlightDate() const { - return _key.getFlightDate(); - } + const Date_T& getFlightDate() const { return _key.getFlightDate(); } + /** Get the map of children holders. */ + const HolderMap_T& getHolderMap() const { return _holderMap; } + public: // /////////// Display support methods ///////// /** Dump a Business Object into an output stream. @@ -62,8 +65,9 @@ protected: // Attributes - /** The key of both structure and objects. */ Key_T _key; + BomAbstract* _parent; + HolderMap_T _holderMap; }; } Modified: trunk/stdair/stdair/bom/FlightPeriod.cpp =================================================================== --- trunk/stdair/stdair/bom/FlightPeriod.cpp 2010-09-13 06:49:06 UTC (rev 330) +++ trunk/stdair/stdair/bom/FlightPeriod.cpp 2010-09-15 12:50:01 UTC (rev 331) @@ -10,7 +10,7 @@ // //////////////////////////////////////////////////////////////////// FlightPeriod::FlightPeriod (const Key_T& iKey) - : _key (iKey) { + : _key (iKey), _parent (NULL) { } // //////////////////////////////////////////////////////////////////// Modified: trunk/stdair/stdair/bom/FlightPeriod.hpp =================================================================== --- trunk/stdair/stdair/bom/FlightPeriod.hpp 2010-09-13 06:49:06 UTC (rev 330) +++ trunk/stdair/stdair/bom/FlightPeriod.hpp 2010-09-15 12:50:01 UTC (rev 331) @@ -14,6 +14,7 @@ /** Class representing the actual attributes for an airline flight-period. */ class FlightPeriod : public BomAbstract { template <typename BOM> friend class FacBom; + friend class FacBomManager; public: // Type definitions. @@ -23,9 +24,10 @@ public: // /////////// Getters /////////////// /** Get the flight-period key. */ - const Key_T& getKey () const { - return _key; - } + const Key_T& getKey () const { return _key; } + + /** Get the parent object. */ + BomAbstract* const getParent() const { return _parent; } /** Get the flight number (part of the primary key). */ const FlightNumber_T& getFlightNumber () const { @@ -33,10 +35,12 @@ } /** Get the departure period (part of the key). */ - const PeriodStruct_T& getPeriod () const { - return _key.getPeriod(); - } + const PeriodStruct_T& getPeriod () const { return _key.getPeriod(); } + /** Get the map of children holders. */ + const HolderMap_T& getHolderMap() const { return _holderMap; } + + public: // /////////// Display support methods ///////// /** Dump a Business Object into an output stream. @@ -62,8 +66,9 @@ protected: // Attributes - /** The key of both structure and objects. */ Key_T _key; + BomAbstract* _parent; + HolderMap_T _holderMap; }; } Modified: trunk/stdair/stdair/bom/Inventory.cpp =================================================================== --- trunk/stdair/stdair/bom/Inventory.cpp 2010-09-13 06:49:06 UTC (rev 330) +++ trunk/stdair/stdair/bom/Inventory.cpp 2010-09-15 12:50:01 UTC (rev 331) @@ -9,7 +9,7 @@ namespace stdair { // //////////////////////////////////////////////////////////////////// - Inventory::Inventory (const Key_T& iKey) : _key (iKey) { + Inventory::Inventory (const Key_T& iKey) : _key (iKey), _parent (NULL) { } // //////////////////////////////////////////////////////////////////// Modified: trunk/stdair/stdair/bom/Inventory.hpp =================================================================== --- trunk/stdair/stdair/bom/Inventory.hpp 2010-09-13 06:49:06 UTC (rev 330) +++ trunk/stdair/stdair/bom/Inventory.hpp 2010-09-15 12:50:01 UTC (rev 331) @@ -18,6 +18,7 @@ */ class Inventory : public BomAbstract { template <typename BOM> friend class FacBom; + friend class FacBomManager; public : // Type definitions @@ -42,16 +43,11 @@ public: // ////////// Getters //////////// - /** Get the inventory key. */ - const Key_T& getKey() const { - return _key; - } + const Key_T& getKey() const { return _key; } + const AirlineCode_T& getAirlineCode() const { return _key.getAirlineCode();} + BomAbstract* const getParent() const { return _parent; } + const HolderMap_T& getHolderMap() const { return _holderMap; } - /** Get the airline code. */ - const AirlineCode_T& getAirlineCode () const { - return _key.getAirlineCode(); - } - public: // /////////// Setters //////////// /** Set the airline feature. */ @@ -68,11 +64,10 @@ protected: // Attributes - /** The key of both structure and objects. */ Key_T _key; - - /** The feature set of the correspondent airline. */ + BomAbstract* _parent; const AirlineFeature* _airlineFeature; + HolderMap_T _holderMap; }; } Modified: trunk/stdair/stdair/bom/LegCabin.cpp =================================================================== --- trunk/stdair/stdair/bom/LegCabin.cpp 2010-09-13 06:49:06 UTC (rev 330) +++ trunk/stdair/stdair/bom/LegCabin.cpp 2010-09-15 12:50:01 UTC (rev 331) @@ -12,15 +12,15 @@ // //////////////////////////////////////////////////////////////////// LegCabin::LegCabin (const Key_T& iKey) - : _key (iKey), - _offeredCapacity (DEFAULT_CABIN_CAPACITY), - _physicalCapacity (DEFAULT_CABIN_CAPACITY), - _soldSeat (DEFAULT_CLASS_NB_OF_BOOKINGS), - _commitedSpace (DEFAULT_COMMITED_SPACE), - _availabilityPool (DEFAULT_AVAILABILITY), - _availability (DEFAULT_AVAILABILITY), - _bidPriceVector (DEFAULT_BID_PRICE_VECTOR), - _currentBidPrice (DEFAULT_BID_PRICE) { + : _key (iKey), _parent (NULL), + _offeredCapacity (DEFAULT_CABIN_CAPACITY), + _physicalCapacity (DEFAULT_CABIN_CAPACITY), + _soldSeat (DEFAULT_CLASS_NB_OF_BOOKINGS), + _commitedSpace (DEFAULT_COMMITED_SPACE), + _availabilityPool (DEFAULT_AVAILABILITY), + _availability (DEFAULT_AVAILABILITY), + _bidPriceVector (DEFAULT_BID_PRICE_VECTOR), + _currentBidPrice (DEFAULT_BID_PRICE) { } // //////////////////////////////////////////////////////////////////// Modified: trunk/stdair/stdair/bom/LegCabin.hpp =================================================================== --- trunk/stdair/stdair/bom/LegCabin.hpp 2010-09-13 06:49:06 UTC (rev 330) +++ trunk/stdair/stdair/bom/LegCabin.hpp 2010-09-15 12:50:01 UTC (rev 331) @@ -14,6 +14,7 @@ /** Class representing the actual attributes for an airline leg-cabin. */ class LegCabin : public BomAbstract { template <typename BOM> friend class FacBom; + friend class FacBomManager; public: // Type definitions. @@ -23,19 +24,16 @@ public: // /////////// Getters //////////// /** Get the leg-cabin key. */ - const Key_T& getKey() const { - return _key; - } + const Key_T& getKey() const { return _key; } + + /** Get the parent object. */ + BomAbstract* const getParent() const { return _parent; } /** Get the cabin code (from key). */ - const CabinCode_T& getCabinCode() const { - return _key.getCabinCode(); - } + const CabinCode_T& getCabinCode() const { return _key.getCabinCode(); } /** Get the cabin offered capacity. */ - const CabinCapacity_T& getOfferedCapacity () const { - return _offeredCapacity; - } + const CabinCapacity_T& getOfferedCapacity () const {return _offeredCapacity;} /** Get the cabin physical capacity. */ const CabinCapacity_T& getPhysicalCapacity () const { @@ -43,14 +41,10 @@ } /** Get the number of sold seat. */ - const NbOfBookings_T& getSoldSeat () const { - return _soldSeat; - } + const NbOfBookings_T& getSoldSeat () const { return _soldSeat; } /** Get the value of commited space. */ - const CommitedSpace_T& getCommitedSpace () const { - return _commitedSpace; - } + const CommitedSpace_T& getCommitedSpace () const { return _commitedSpace; } /** Get the value of the availability pool. */ const Availability_T& getAvailabilityPool () const { @@ -58,20 +52,17 @@ } /** Get the value of the availability. */ - const Availability_T& getAvailability () const { - return _availability; - } + const Availability_T& getAvailability () const { return _availability; } /** Retrive the current Bid-Price. */ - const BidPrice_T& getCurrentBidPrice () const { - return _currentBidPrice; - } + const BidPrice_T& getCurrentBidPrice () const { return _currentBidPrice; } /** Retrive the Bid-Price Vector. */ - BidPriceVector_T& getBidPriceVector () { - return _bidPriceVector; - } + BidPriceVector_T& getBidPriceVector () { return _bidPriceVector; } + /** Get the map of children holders. */ + const HolderMap_T& getHolderMap() const { return _holderMap; } + public: // ///////////// Setters /////////////// /** Set the offered and physical capacities. */ @@ -147,33 +138,17 @@ stdair::NbOfBookings_T _groupNbOfBookings; protected: - // Attributes - /** The key of both structure and objects. */ Key_T _key; - - /** Offered capacity of the cabin. */ + BomAbstract* _parent; CabinCapacity_T _offeredCapacity; - - /** Physical capacity of the cabin. */ CabinCapacity_T _physicalCapacity; - - /** Sold seat into the cabin. */ NbOfBookings_T _soldSeat; - - /** Commited space for all segmentCabin composed by this LegCabin. */ CommitedSpace_T _commitedSpace; - - /** Availability Pool between capacity and commited spaces. */ Availability_T _availabilityPool; - - /** Availability Pool between capacity and commited spaces. */ Availability_T _availability; - - /** Bid Price Vector. */ BidPriceVector_T _bidPriceVector; - - /** Current BidPrice. */ BidPrice_T _currentBidPrice; + HolderMap_T _holderMap; }; } Modified: trunk/stdair/stdair/bom/LegDate.cpp =================================================================== --- trunk/stdair/stdair/bom/LegDate.cpp 2010-09-13 06:49:06 UTC (rev 330) +++ trunk/stdair/stdair/bom/LegDate.cpp 2010-09-15 12:50:01 UTC (rev 331) @@ -11,8 +11,7 @@ // //////////////////////////////////////////////////////////////////// LegDate::LegDate (const Key_T& iKey) \ - : _key (iKey), - _distance (DEFAULT_DISTANCE_VALUE), + : _key (iKey), _parent (NULL), _distance (DEFAULT_DISTANCE_VALUE), _capacity (DEFAULT_CABIN_CAPACITY) { } Modified: trunk/stdair/stdair/bom/LegDate.hpp =================================================================== --- trunk/stdair/stdair/bom/LegDate.hpp 2010-09-13 06:49:06 UTC (rev 330) +++ trunk/stdair/stdair/bom/LegDate.hpp 2010-09-15 12:50:01 UTC (rev 331) @@ -14,6 +14,7 @@ /** Class representing the actual attributes for an airline leg-date. */ class LegDate : public BomAbstract { template <typename BOM> friend class FacBom; + friend class FacBomManager; public: // Type definitions. @@ -23,59 +24,42 @@ public: // /////////// Getters ///////////// /** Get the leg-date key. */ - const Key_T& getKey() const { - return _key; - } + const Key_T& getKey() const { return _key; } + /** Get the parent object. */ + BomAbstract* const getParent() const { return _parent; } + /** Get the boarding point (part of the primary key). */ const AirportCode_T& getBoardingPoint () const { return _key.getBoardingPoint(); } /** Get the off point. */ - const AirportCode_T& getOffPoint () const { - return _offPoint; - } + const AirportCode_T& getOffPoint () const { return _offPoint; } /** Get the boarding date. */ - const Date_T& getBoardingDate () const { - return _boardingDate; - } + const Date_T& getBoardingDate () const { return _boardingDate; } /** Get the boarding time. */ - const Duration_T& getBoardingTime () const { - return _boardingTime; - } + const Duration_T& getBoardingTime () const { return _boardingTime; } /** Get the off date. */ - const Date_T& getOffDate () const { - return _offDate; - } + const Date_T& getOffDate () const { return _offDate; } /** Get the off time. */ - const Duration_T& getOffTime () const { - return _offTime; - } + const Duration_T& getOffTime () const { return _offTime; } /** Get the elapsed time. */ - const Duration_T& getElapsedTime() const { - return _elapsedTime; - } + const Duration_T& getElapsedTime() const { return _elapsedTime; } /** Get the distance. */ - const Distance_T& getDistance() const { - return _distance; - } + const Distance_T& getDistance() const { return _distance; } /** Get the leg capacity. */ - const CabinCapacity_T& getCapacity () const { - return _capacity; - } + const CabinCapacity_T& getCapacity () const { return _capacity; } /** Get the date offset (off date - boarding date). */ - const DateOffset_T getDateOffset () const { - return _offDate - _boardingDate; - } + const DateOffset_T getDateOffset () const { return _offDate - _boardingDate;} /** Get the time off set between boarding and off points. <br>It is defined as being: @@ -83,12 +67,13 @@ - ElapsedTime. */ const Duration_T getTimeOffset() const; + /** Get the map of children holders. */ + const HolderMap_T& getHolderMap() const { return _holderMap; } + public: // ///////// Setters ////////// /** Set the off point. */ - void setOffPoint (const AirportCode_T& iOffPoint) { - _offPoint = iOffPoint; - } + void setOffPoint (const AirportCode_T& iOffPoint) { _offPoint = iOffPoint; } /** Set the boarding date. */ void setBoardingDate (const Date_T& iBoardingDate) { @@ -101,14 +86,10 @@ } /** Set the off date. */ - void setOffDate (const Date_T& iOffDate) { - _offDate = iOffDate; - } + void setOffDate (const Date_T& iOffDate) { _offDate = iOffDate; } /** Set the off time. */ - void setOffTime (const Duration_T& iOffTime) { - _offTime = iOffTime; - } + void setOffTime (const Duration_T& iOffTime) { _offTime = iOffTime; } /** Set the elapsed time. */ void setElapsedTime (const Duration_T&); @@ -141,32 +122,17 @@ protected: // Attributes - /** The key of both structure and objects. */ Key_T _key; - - /** Off Point. */ + BomAbstract* _parent; AirportCode_T _offPoint; - - /** Boarding Date. */ Date_T _boardingDate; - - /** Boarding Time. */ Duration_T _boardingTime; - - /** Off Date. */ Date_T _offDate; - - /** Off Time. */ Duration_T _offTime; - - /** Elapsed Time. */ Duration_T _elapsedTime; - - /** Distance. */ Distance_T _distance; - - /** Capacity of the leg. */ CabinCapacity_T _capacity; + HolderMap_T _holderMap; }; } Deleted: trunk/stdair/stdair/bom/RelationShip.hpp =================================================================== --- trunk/stdair/stdair/bom/RelationShip.hpp 2010-09-13 06:49:06 UTC (rev 330) +++ trunk/stdair/stdair/bom/RelationShip.hpp 2010-09-15 12:50:01 UTC (rev 331) @@ -1,332 +0,0 @@ -// ////////////////////////////////////////////////////////////////////// -#ifndef __STDAIR_BOM_RELATIONSHIP_HPP -#define __STDAIR_BOM_RELATIONSHIP_HPP - -// ////////////////////////////////////////////////////////////////////// -// Import section -// ////////////////////////////////////////////////////////////////////// -// STL -#include <map> -#include <list> -#include <cassert> -// STDAIR -#include <stdair/STDAIR_Types.hpp> -#include <stdair/bom/RelationShipAbstract.hpp> -#include <stdair/service/FacSupervisor.hpp> -#include <stdair/service/Logger.hpp> - -namespace stdair { - - /** Class which holds the relation ship between different types of objects - (i.e. Inventory is parent of FlightDate). */ - template <typename PARENT, typename CHILD> - class RelationShip : public RelationShipAbstract { - friend class FacSupervisor; - friend class FacBomManager; - - // ////////////////////////////////////////////////////////////////// - // Internal type definitions. - typedef std::list<CHILD*> ChildrenList_T; - typedef std::list<std::pair<MapKey_T, CHILD*> > ChildrenDetailedList_T; - typedef std::map<const MapKey_T, CHILD*> ChildrenMap_T; - typedef std::map<const PARENT*, ChildrenList_T> ParentChildrentList_T; - typedef std::map<const PARENT*, - ChildrenDetailedList_T> ParentChildrentDetailedList_T; - typedef std::map<const PARENT*, ChildrenMap_T> ParentChildrentMap_T; - typedef std::map<const CHILD*, PARENT*> ChildParentMap_T; - // ////////////////////////////////////////////////////////////////// - - public: - /** Provide the unique instance. - <br> The singleton is instatiated when first used. - @return RelationShip& */ - static RelationShip& instance (); - - public: - // ////////////////////// Business Methods ///////////////////////// - /** Getter of the children conainter given the PARENT pointer. */ - ChildrenList_T& getChildrenList (const PARENT&); - ChildrenDetailedList_T& getChildrenDetailedList (const PARENT&); - ChildrenMap_T& getChildrenMap (const PARENT&); - - /** Getter of the attribute holders. */ - const ParentChildrentList_T& getParentChildrenList (); - const ParentChildrentMap_T& getParentChildrenMap (); - - /** Getter of the PARENT given the CHILD. */ - PARENT& getParent (const CHILD&); - - /** Return the CHILD pointer corresponding to the given string key. - If such a CHILD does not exist, return NULL. */ - CHILD* getChildPtr (const PARENT&, const MapKey_T&); - - /** Return the CHILD corresponding the the given string key. */ - CHILD& getChild (const PARENT&, const MapKey_T&); - - /** Check if the list/map of children has been initialised. */ - bool hasChildrenList (const PARENT&); - bool hasChildrenDetailedList (const PARENT&); - bool hasChildrenMap (const PARENT&); - - private: - /** Add the given CHILD to the children containter of the given PARENT. */ - void addChildToTheList (const PARENT&, CHILD&); - void addChildToTheDetailedList (const PARENT&, CHILD&, const MapKey_T&); - void addChildToTheMap (const PARENT&, CHILD&); - void addChildToTheMap (const PARENT&, CHILD&, const MapKey_T&); - - /** Link the CHILD with the PARENT. */ - void linkWithParent (PARENT&, const CHILD&); - - private: - /** Default constructor. */ - RelationShip () { } - /** Destructor. */ - ~RelationShip () { _instance = NULL; }; - - private: - /** The unique instance. */ - static RelationShip* _instance; - /** The containers of relation ships. */ - ParentChildrentList_T _parentChildrenList; - ParentChildrentDetailedList_T _parentChildrenDetailedList; - ParentChildrentMap_T _parentChildrenMap; - ChildParentMap_T _childParentMap; - }; - - // //////////////////////////////////////////////////////////////////// - template <typename PARENT, typename CHILD> - RelationShip<PARENT, CHILD>* RelationShip<PARENT, CHILD>::_instance = NULL; - - // //////////////////////////////////////////////////////////////////// - template <typename PARENT, typename CHILD> - RelationShip<PARENT, CHILD>& RelationShip<PARENT, CHILD>::instance () { - if (_instance == NULL) { - _instance = new RelationShip (); - assert (_instance != NULL); - - FacSupervisor::instance().registerRelationShip (_instance); - } - return *_instance; - } - - // //////////////////////////////////////////////////////////////////// - template <typename PARENT, typename CHILD> - typename RelationShip<PARENT, CHILD>::ChildrenList_T& - RelationShip<PARENT, CHILD>::getChildrenList (const PARENT& iParent) { - ParentChildrentList_T& lParentChildrenList = instance()._parentChildrenList; - typename ParentChildrentList_T::iterator itList = - lParentChildrenList.find (&iParent); - - if (itList == lParentChildrenList.end()) { - STDAIR_LOG_ERROR ("Cannot find the list within: "<< iParent.describeKey()); - throw NonInitialisedContainerException (); - } - - return itList->second; - } - - // //////////////////////////////////////////////////////////////////// - template <typename PARENT, typename CHILD> - typename Relation... [truncated message content] |