From: <qua...@us...> - 2010-04-22 14:02:37
|
Revision: 181 http://stdair.svn.sourceforge.net/stdair/?rev=181&view=rev Author: quannaus Date: 2010-04-22 14:02:30 +0000 (Thu, 22 Apr 2010) Log Message: ----------- [dev] 'linkTwoObjects' in FacBomContent now uses the full keys. Modified Paths: -------------- trunk/stdair/stdair/command/CmdBomManager.cpp trunk/stdair/stdair/factory/FacBomContent.hpp trunk/stdair/stdair/factory/FacBomStructure.hpp Modified: trunk/stdair/stdair/command/CmdBomManager.cpp =================================================================== --- trunk/stdair/stdair/command/CmdBomManager.cpp 2010-04-22 12:25:56 UTC (rev 180) +++ trunk/stdair/stdair/command/CmdBomManager.cpp 2010-04-22 14:02:30 UTC (rev 181) @@ -48,15 +48,6 @@ // Link the created inventory with the bom root. FacBomContent::linkWithParent (lInventory, ioBomRoot); - - // DEBUG - STDAIR_LOG_DEBUG ("Generated inventory: " << iAirlineCode); - const InventoryList_T lInvList = ioBomRoot.getInventoryList(); - for (InventoryList_T::iterator itInv = lInvList.begin(); - itInv != lInvList.end(); ++itInv) { - const Inventory& lCurrentInv = *itInv; - STDAIR_LOG_DEBUG ("Current inventory: " << lCurrentInv.describeKey()); - } return lInventory; } Modified: trunk/stdair/stdair/factory/FacBomContent.hpp =================================================================== --- trunk/stdair/stdair/factory/FacBomContent.hpp 2010-04-22 12:25:56 UTC (rev 180) +++ trunk/stdair/stdair/factory/FacBomContent.hpp 2010-04-22 14:02:30 UTC (rev 181) @@ -73,7 +73,8 @@ } // ////////////////////////////////////////////////////////////////// - /** Link two child content objects, the second one into the first one. */ + /** Link two child content objects, the second one into the first one, + using the short key. */ template <typename PARENT, typename CHILD> static void addObjectToTheDedicatedList (PARENT& ioParent, const CHILD& iChild) { @@ -89,11 +90,28 @@ } // ////////////////////////////////////////////////////////////////// + /** Link two child content objects, the second one into the first one, + using the full key. */ + template <typename PARENT, typename CHILD> + static void addFullObjectToTheDedicatedList (PARENT& ioParent, + const CHILD& iChild) { + + // Link both the parent and child structure objects + const bool hasLinkBeenSuccessful = + FacBomStructure::addFullObjectToTheDedicatedList (ioParent._structure, + iChild._structure); + + if (hasLinkBeenSuccessful == false) { + throw ObjectLinkingException(); + } + } + + // ////////////////////////////////////////////////////////////////// /** Link two child content objects. */ template <typename OBJECT1, typename OBJECT2> static void linkTwoObjects (OBJECT1& ioObject1, OBJECT2& ioObject2) { - addObjectToTheDedicatedList (ioObject1, ioObject2); - addObjectToTheDedicatedList (ioObject2, ioObject1); + addFullObjectToTheDedicatedList (ioObject1, ioObject2); + addFullObjectToTheDedicatedList (ioObject2, ioObject1); } // ////////////////////////////////////////////////////////////////// Modified: trunk/stdair/stdair/factory/FacBomStructure.hpp =================================================================== --- trunk/stdair/stdair/factory/FacBomStructure.hpp 2010-04-22 12:25:56 UTC (rev 180) +++ trunk/stdair/stdair/factory/FacBomStructure.hpp 2010-04-22 14:02:30 UTC (rev 181) @@ -49,7 +49,8 @@ } // ////////////////////////////////////////////////////////////////// - /** Link two child structure objects, the second one into the first one. */ + /** Link two child structure objects, the second one into the first one, + using the short key. */ template <typename PARENT, typename CHILD> static bool addObjectToTheDedicatedList (PARENT& ioParent, const CHILD& iChild) { @@ -69,6 +70,28 @@ } // ////////////////////////////////////////////////////////////////// + /** Link two child structure objects, the second one into the first one, + using the full key. */ + template <typename PARENT, typename CHILD> + static bool addFullObjectToTheDedicatedList (PARENT& ioParent, + const CHILD& iChild) { + // Retrive the bom children holder corresponding the the children type. + typedef typename CHILD::Content_T CHILD_CONTENT_T; + typedef BomChildrenHolderImp<CHILD_CONTENT_T> CHILDREN_HOLDER_T; + + CHILDREN_HOLDER_T*& lChildrenHolder_ptr = + boost::fusion::at_key<CHILD_CONTENT_T> (ioParent._holderMap); + + // If the holder does not existe, then create it. + if (lChildrenHolder_ptr == NULL) { + lChildrenHolder_ptr = &instance().create<CHILDREN_HOLDER_T> (); + } + + return addFullObjectToHolder<CHILD_CONTENT_T> (*lChildrenHolder_ptr, + iChild); + } + + // ////////////////////////////////////////////////////////////////// /** Link a child structure object with its parent. <br>For instance, link a SegmentDate structure object with its parent FlightDate structure object. @@ -111,6 +134,34 @@ return true; } + // ////////////////////////////////////////////////////////////////// + /** Add a BOM object into a dedicated BOM holder by using the + full key of the object. */ + template <typename CONTENT> + static bool addFullObjectToHolder (BomChildrenHolderImp<CONTENT>& ioHolder, + const typename CONTENT::Structure_T& iStructure) { + // Retrieve the bom structure type. + typedef typename CONTENT::Structure_T STRUCTURE_T; + // Define the bom holder type. + typedef BomChildrenHolderImp<CONTENT> HOLDER_T; + + // Retrieve the short key + const std::string& lKeyStr = iStructure.getContent().describeKey(); + + // Insert the structure object in the dedicated lists + typedef typename HOLDER_T::BomChildrenMap_T BOM_MAP_T; + const bool hasInsertBeenSuccessful = ioHolder._bomChildrenMap. + insert (typename BOM_MAP_T::value_type (lKeyStr, &iStructure)).second; + + if (hasInsertBeenSuccessful == false) { + return hasInsertBeenSuccessful; + } + + ioHolder._bomChildrenList.push_back (&iStructure); + + return true; + } + protected: /** Default Constructor. <br>This constructor is protected to ensure the class is structure. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |