From: <qua...@us...> - 2010-09-03 08:17:05
|
Revision: 300 http://stdair.svn.sourceforge.net/stdair/?rev=300&view=rev Author: quannaus Date: 2010-09-03 08:16:59 +0000 (Fri, 03 Sep 2010) Log Message: ----------- [dev] some changes for the improvement of airsched. Modified Paths: -------------- trunk/stdair/stdair/bom/BomManager.hpp trunk/stdair/stdair/bom/RelationShip.hpp Modified: trunk/stdair/stdair/bom/BomManager.hpp =================================================================== --- trunk/stdair/stdair/bom/BomManager.hpp 2010-08-29 20:54:34 UTC (rev 299) +++ trunk/stdair/stdair/bom/BomManager.hpp 2010-09-03 08:16:59 UTC (rev 300) @@ -22,6 +22,14 @@ template <typename CHILD, typename PARENT> static std::map<const MapKey_T, CHILD*>& getMap (const PARENT&); + /** 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 children has been initialised. */ template <typename CHILD, typename PARENT> static bool hasList (const PARENT&); @@ -38,10 +46,16 @@ 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 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&); }; // //////////////////////////////////////////////////////////////////// @@ -65,6 +79,20 @@ } // //////////////////////////////////////////////////////////////////// + template <typename PARENT, typename CHILD> + const std::map<const PARENT*, std::list<CHILD*> >& BomManager:: + getParentChildrenList() { + return RelationShip<PARENT, CHILD>::instance().getParentChildrenList(); + } + + // //////////////////////////////////////////////////////////////////// + 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 CHILD, typename PARENT> bool BomManager::hasList (const PARENT& iParent) { return RelationShip<PARENT, CHILD>::instance().hasChildrenList (iParent); @@ -100,6 +128,30 @@ CHILD& BomManager::getChild (const PARENT& iParent, const MapKey_T& iKey) { return RelationShip<PARENT, CHILD>::instance().getChild (iParent, iKey); } + + // //////////////////////////////////////////////////////////////////// + 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; + } + 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; + assert (oBom_ptr != NULL); + return *oBom_ptr; + } } #endif // __STDAIR_BOM_BOMMANAGER_HPP Modified: trunk/stdair/stdair/bom/RelationShip.hpp =================================================================== --- trunk/stdair/stdair/bom/RelationShip.hpp 2010-08-29 20:54:34 UTC (rev 299) +++ trunk/stdair/stdair/bom/RelationShip.hpp 2010-09-03 08:16:59 UTC (rev 300) @@ -49,6 +49,10 @@ 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&); @@ -157,6 +161,20 @@ } // //////////////////////////////////////////////////////////////////// + template <typename PARENT, typename CHILD> + const typename RelationShip<PARENT, CHILD>::ParentChildrentList_T& + RelationShip<PARENT, CHILD>::getParentChildrenList () { + return instance()._parentChildrenList; + } + + // //////////////////////////////////////////////////////////////////// + template <typename PARENT, typename CHILD> + const typename RelationShip<PARENT, CHILD>::ParentChildrentMap_T& + RelationShip<PARENT, CHILD>::getParentChildrenMap () { + return instance()._parentChildrenMap; + } + + // //////////////////////////////////////////////////////////////////// template <typename PARENT, typename CHILD> bool RelationShip<PARENT, CHILD>:: hasChildrenList (const PARENT& iParent) { ParentChildrentList_T& lParentChildrenList = instance()._parentChildrenList; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |