From: <qua...@us...> - 2010-08-24 16:56:30
|
Revision: 280 http://stdair.svn.sourceforge.net/stdair/?rev=280&view=rev Author: quannaus Date: 2010-08-24 16:56:23 +0000 (Tue, 24 Aug 2010) Log Message: ----------- [dev] added the detailed list to RelationShip. Modified Paths: -------------- trunk/stdair/stdair/bom/BomManager.hpp trunk/stdair/stdair/bom/RelationShip.hpp trunk/stdair/stdair/bom/SegmentPeriodTypes.hpp trunk/stdair/stdair/factory/FacBomManager.hpp Modified: trunk/stdair/stdair/bom/BomManager.hpp =================================================================== --- trunk/stdair/stdair/bom/BomManager.hpp 2010-08-24 14:57:23 UTC (rev 279) +++ trunk/stdair/stdair/bom/BomManager.hpp 2010-08-24 16:56:23 UTC (rev 280) @@ -18,12 +18,16 @@ 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&); /** 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. */ @@ -47,6 +51,14 @@ } // //////////////////////////////////////////////////////////////////// + template <typename CHILD, typename PARENT> + std::list<std::pair<MapKey_T, CHILD*> >& BomManager:: + getDetailedList (const PARENT& iParent) { + return RelationShip<PARENT, CHILD>:: + instance().getChildrenDetailedList (iParent); + } + + // //////////////////////////////////////////////////////////////////// template <typename CHILD, typename PARENT> std::map<const MapKey_T, CHILD*>& BomManager::getMap (const PARENT& iParent) { return RelationShip<PARENT, CHILD>::instance().getChildrenMap (iParent); @@ -60,6 +72,13 @@ // //////////////////////////////////////////////////////////////////// template <typename CHILD, typename PARENT> + bool BomManager::hasDetailedList (const PARENT& iParent) { + return RelationShip<PARENT, CHILD>:: + instance().hasChildrenDetailedList (iParent); + } + + // //////////////////////////////////////////////////////////////////// + template <typename CHILD, typename PARENT> bool BomManager::hasMap (const PARENT& iParent) { return RelationShip<PARENT, CHILD>::instance().hasChildrenMap (iParent); } Modified: trunk/stdair/stdair/bom/RelationShip.hpp =================================================================== --- trunk/stdair/stdair/bom/RelationShip.hpp 2010-08-24 14:57:23 UTC (rev 279) +++ trunk/stdair/stdair/bom/RelationShip.hpp 2010-08-24 16:56:23 UTC (rev 280) @@ -27,8 +27,11 @@ // ////////////////////////////////////////////////////////////////// // 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; // ////////////////////////////////////////////////////////////////// @@ -43,6 +46,7 @@ // ////////////////////// 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 PARENT given the CHILD. */ @@ -57,11 +61,13 @@ /** 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&); @@ -79,6 +85,7 @@ static RelationShip* _instance; /** The containers of relation ships. */ ParentChildrentList_T _parentChildrenList; + ParentChildrentDetailedList_T _parentChildrenDetailedList; ParentChildrentMap_T _parentChildrenMap; ChildParentMap_T _childParentMap; }; @@ -117,6 +124,24 @@ // //////////////////////////////////////////////////////////////////// template <typename PARENT, typename CHILD> + typename RelationShip<PARENT, CHILD>::ChildrenDetailedList_T& + RelationShip<PARENT, CHILD>::getChildrenDetailedList (const PARENT& iParent) { + ParentChildrentDetailedList_T& lParentChildrenDetailedList = + instance()._parentChildrenDetailedList; + typename ParentChildrentDetailedList_T::iterator itDetailedList = + lParentChildrenDetailedList.find (&iParent); + + if (itDetailedList == lParentChildrenDetailedList.end()) { + STDAIR_LOG_ERROR ("Cannot find the detailed list within: " + << iParent.describeKey()); + throw NonInitialisedContainerException (); + } + + return itDetailedList->second; + } + + // //////////////////////////////////////////////////////////////////// + template <typename PARENT, typename CHILD> typename RelationShip<PARENT, CHILD>::ChildrenMap_T& RelationShip<PARENT, CHILD>::getChildrenMap (const PARENT& iParent) { ParentChildrentMap_T& lParentChildrenMap = instance()._parentChildrenMap; @@ -146,6 +171,20 @@ // //////////////////////////////////////////////////////////////////// template <typename PARENT, typename CHILD> bool RelationShip<PARENT, CHILD>:: + hasChildrenDetailedList (const PARENT& iParent) { + ParentChildrentDetailedList_T& lParentChildrenDetailedList = + instance()._parentChildrenDetailedList; + typename ParentChildrentDetailedList_T::iterator itDetailedList = + lParentChildrenDetailedList.find (&iParent); + + if (itDetailedList == lParentChildrenDetailedList.end()) { + return false; + } + return true; + } + + // //////////////////////////////////////////////////////////////////// + template <typename PARENT, typename CHILD> bool RelationShip<PARENT, CHILD>:: hasChildrenMap (const PARENT& iParent) { ParentChildrentMap_T& lParentChildrenMap = instance()._parentChildrenMap; typename ParentChildrentMap_T::iterator itMap = @@ -225,6 +264,16 @@ // //////////////////////////////////////////////////////////////////// template <typename PARENT, typename CHILD> void RelationShip<PARENT, CHILD>:: + addChildToTheDetailedList (const PARENT& iParent, CHILD& ioChild, + const MapKey_T& iKey) { + ParentChildrentDetailedList_T& lParentChildrenDetailedList = + instance()._parentChildrenDetailedList; + lParentChildrenDetailedList[&iParent]. + push_back (std::pair<const MapKey_T, CHILD*> (iKey, &ioChild)); + } + + // //////////////////////////////////////////////////////////////////// + template <typename PARENT, typename CHILD> void RelationShip<PARENT, CHILD>:: addChildToTheMap (const PARENT& iParent, CHILD& ioChild) { ParentChildrentMap_T& lParentChildrenMap = instance()._parentChildrenMap; Modified: trunk/stdair/stdair/bom/SegmentPeriodTypes.hpp =================================================================== --- trunk/stdair/stdair/bom/SegmentPeriodTypes.hpp 2010-08-24 14:57:23 UTC (rev 279) +++ trunk/stdair/stdair/bom/SegmentPeriodTypes.hpp 2010-08-24 16:56:23 UTC (rev 280) @@ -20,7 +20,11 @@ typedef std::list<SegmentPeriod*> SegmentPeriodList_T; /** Define the segment-period map. */ - typedef std::map<const MapKey_T&, SegmentPeriod*> SegmentPeriodMap_T; + typedef std::map<const MapKey_T, SegmentPeriod*> SegmentPeriodMap_T; + + /** Define the list of pair<MapKey_T, SegmentPeriod>. */ + typedef std::pair<MapKey_T, SegmentPeriod*> SegmentPeriodWithKey_T; + typedef std::list<SegmentPeriodWithKey_T> SegmentPeriodDetailedList_T; } #endif // __STDAIR_BOM_SEGMENTPERIODTYPES_HPP Modified: trunk/stdair/stdair/factory/FacBomManager.hpp =================================================================== --- trunk/stdair/stdair/factory/FacBomManager.hpp 2010-08-24 14:57:23 UTC (rev 279) +++ trunk/stdair/stdair/factory/FacBomManager.hpp 2010-08-24 16:56:23 UTC (rev 280) @@ -23,6 +23,8 @@ template <typename PARENT, typename CHILD> static void addToList (const PARENT&, CHILD&); template <typename PARENT, typename CHILD> + static void addToDetailedList (const PARENT&, CHILD&, const MapKey_T&); + template <typename PARENT, typename CHILD> static void addToMap (const PARENT&, CHILD&); template <typename PARENT, typename CHILD> static void addToMap (const PARENT&, CHILD&, const MapKey_T&); @@ -37,7 +39,7 @@ /** Clone the list of children between two objects. */ template <typename CHILD, typename PARENT> - static void cloneChildrenList (const PARENT&, const PARENT&); + static void cloneChildrenDetailedList (const PARENT&, const PARENT&); }; @@ -55,6 +57,15 @@ // //////////////////////////////////////////////////////////////////// template <typename PARENT, typename CHILD> void FacBomManager:: + addToDetailedList (const PARENT& iParent, CHILD& ioChild, + const MapKey_T& iKey) { + RelationShip<PARENT, CHILD>::instance().addChildToTheDetailedList (iParent, + ioChild, + iKey); + } + + // //////////////////////////////////////////////////////////////////// + template <typename PARENT, typename CHILD> void FacBomManager:: addToMap (const PARENT& iParent, CHILD& ioChild) { RelationShip<PARENT, CHILD>::instance().addChildToTheMap (iParent, ioChild); } @@ -89,10 +100,10 @@ // //////////////////////////////////////////////////////////////////// template <typename CHILD, typename PARENT> void FacBomManager:: - cloneChildrenList (const PARENT& iP1, const PARENT& iP2) { - const std::list<CHILD*>& lList = - RelationShip<PARENT, CHILD>::instance().getChildrenList (iP2); - RelationShip<PARENT, CHILD>::instance()._parentChildrenList[&iP1] = lList; + cloneChildrenDetailedList (const PARENT& iP1, const PARENT& iP2) { + const std::list<std::pair<MapKey_T, CHILD*> >& lDetailedList = + RelationShip<PARENT, CHILD>::instance().getChildrenDetailedList (iP2); + RelationShip<PARENT, CHILD>::instance()._parentChildrenDetailedList[&iP1] = lDetailedList; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |