From: <qua...@us...> - 2010-04-06 15:34:27
|
Revision: 169 http://stdair.svn.sourceforge.net/stdair/?rev=169&view=rev Author: quannaus Date: 2010-04-06 15:34:20 +0000 (Tue, 06 Apr 2010) Log Message: ----------- [dev] test new implementation. Modified Paths: -------------- trunk/stdair/stdair/batches/stdair.cpp trunk/stdair/stdair/bom/BR.hpp trunk/stdair/stdair/bom/FD.hpp trunk/stdair/stdair/bom/IN.hpp trunk/stdair/stdair/bom/ND.hpp trunk/stdair/stdair/bom/Structure.hpp trunk/stdair/stdair/bom/sources.mk trunk/stdair/stdair/factory/FacBomContent.hpp trunk/stdair/stdair/factory/FacBomStructure.hpp Removed Paths: ------------- trunk/stdair/stdair/bom/BS.hpp trunk/stdair/stdair/bom/BSKey.hpp trunk/stdair/stdair/bom/BSTypes.hpp Modified: trunk/stdair/stdair/batches/stdair.cpp =================================================================== --- trunk/stdair/stdair/batches/stdair.cpp 2010-04-06 14:33:30 UTC (rev 168) +++ trunk/stdair/stdair/batches/stdair.cpp 2010-04-06 15:34:20 UTC (rev 169) @@ -18,6 +18,7 @@ #include <stdair/bom/ND.hpp> #include <stdair/bom/NDKey.hpp> #include <stdair/bom/NDTypes.hpp> +#include <stdair/bom/BomList.hpp> #include <stdair/factory/FacBomContent.hpp> @@ -31,7 +32,40 @@ stdair::INKey_T lINKey ("BA"); stdair::IN& lIN = stdair::FacBomContent::instance().testCreate<stdair::IN> (lINKey); - + stdair::FacBomContent::testLink<stdair::IN> (lIN, lBR); + + stdair::FDKey_T lFDKey (17); + stdair::FD& lFD = + stdair::FacBomContent::instance().testCreate<stdair::FD> (lFDKey); + stdair::FacBomContent::testLink<stdair::FD> (lFD, lIN); + + stdair::NDKey_T lNDKey (1); + stdair::ND& lND = + stdair::FacBomContent::instance().testCreate<stdair::ND> (lNDKey); + stdair::FacBomContent::testLink<stdair::ND> (lND, lIN); + + + // Browse + stdair::INList_T lINList = lBR.getINList(); + for (stdair::INList_T::iterator it = lINList.begin(); + it != lINList.end(); ++it) { + const stdair::IN& lCurrentIN = *it; + std::cout << "Current IN: " << lCurrentIN.toString() << std::endl; + + stdair::FDList_T lFDList = lIN.getFDList(); + for (stdair::FDList_T::iterator it = lFDList.begin(); + it != lFDList.end(); ++it) { + const stdair::FD& lCurrentFD = *it; + std::cout << "Current FD: " << lCurrentFD.toString() << std::endl; + } + stdair::NDList_T lNDList = lIN.getNDList(); + for (stdair::NDList_T::iterator it = lNDList.begin(); + it != lNDList.end(); ++it) { + const stdair::ND& lCurrentND = *it; + std::cout << "Current ND: " << lCurrentND.toString() << std::endl; + } + + } } catch (const std::exception& stde) { std::cerr << "Standard exception: " << stde.what() << std::endl; Modified: trunk/stdair/stdair/bom/BR.hpp =================================================================== --- trunk/stdair/stdair/bom/BR.hpp 2010-04-06 14:33:30 UTC (rev 168) +++ trunk/stdair/stdair/bom/BR.hpp 2010-04-06 15:34:20 UTC (rev 169) @@ -15,6 +15,8 @@ #include <stdair/bom/BRKey.hpp> #include <stdair/bom/BRTypes.hpp> #include <stdair/bom/INTypes.hpp> +#include <stdair/bom/IN.hpp> +#include <stdair/bom/BomList.hpp> namespace stdair { // Forward declarations. @@ -29,7 +31,7 @@ public: // ///////////////////////////////////////////////////////////////////////// /** Definition allowing to retrieve the associated BOM structure type. */ - typedef BRStructure_T Structure_T; + typedef BRStructure_T BomStructure_T; /** Definition allowing to retrieve the associated BOM key type. */ typedef BRKey_T Key_T; @@ -66,13 +68,17 @@ const Key_T& getKey () const { return _key; } + + const INList_T getINList () const { + return _structure.getChildrenHolder<IN> (); + } public: // //////////// Setters ////////////// private: /** Retrieve the BOM structure object. */ - Structure_T& getStructure () { + BomStructure_T& getStructure () { return _structure; } @@ -82,7 +88,7 @@ /** Default constructors. */ BR (); BR (const BR&); - BR (const Key_T& iKey, Structure_T& ioStructure) + BR (const Key_T& iKey, BomStructure_T& ioStructure) : _key (iKey), _structure (ioStructure) { } /** Destructor. */ virtual ~BR() { } @@ -93,8 +99,7 @@ Key_T _key; /** Reference structure. */ - Structure_T& _structure; - + BomStructure_T& _structure; }; } Deleted: trunk/stdair/stdair/bom/BS.hpp =================================================================== --- trunk/stdair/stdair/bom/BS.hpp 2010-04-06 14:33:30 UTC (rev 168) +++ trunk/stdair/stdair/bom/BS.hpp 2010-04-06 15:34:20 UTC (rev 169) @@ -1,99 +0,0 @@ -#ifndef __STDAIR_BOM_BS_HPP -#define __STDAIR_BOM_BS_HPP - -// ////////////////////////////////////////////////////////////////////// -// Import section -// ////////////////////////////////////////////////////////////////////// -// STL -#include <iosfwd> -// BOOST Fusion -#include <boost/fusion/container/map.hpp> -#include <boost/fusion/include/map.hpp> -// STDAIR -#include <stdair/bom/Structure.hpp> -#include <stdair/bom/BomContent.hpp> -#include <stdair/bom/BSKey.hpp> -#include <stdair/bom/BSTypes.hpp> - -namespace stdair { - // Forward declarations. - class FacBomContent; - - /** Class representing the actual functional/business content - for the Bom root. */ - class BS : public BomContent { - friend class FacBomContent; - - public: - // ///////////////////////////////////////////////////////////////////////// - /** Definition allowing to retrieve the associated BOM structure type. */ - typedef BSStructure_T Structure_T; - - /** Definition allowing to retrieve the associated BOM key type. */ - typedef BSKey_T Key_T; - - /** Define the list of children holder types. */ - typedef boost::fusion::map< - boost::fusion::pair<BS, BSHolder_T*> > ChildrenHolderTypeMap_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 describeKey(); } - - /** Get a string describing the whole key (differentiating two objects - at any level). */ - const std::string describeKey() const { return std::string (""); } - - /** Get a string describing the short key (differentiating two objects - at the same level). */ - const std::string describeShortKey() const { return std::string (""); } - - - public: - // /////////// Getters ///////////// - const Key_T& getKey () const { - return _key; - } - - public: - // //////////// Setters ////////////// - - private: - /** Retrieve the BOM structure object. */ - Structure_T& getStructure () { - return _structure; - } - - protected: - /** Constructors are private so as to force the usage of the Factory - layer. */ - /** Default constructors. */ - BS (); - BS (const BS&); - BS (const Key_T& iKey, Structure_T& ioStructure) - : _key (iKey), _structure (ioStructure) { } - /** Destructor. */ - virtual ~BS() { } - - private: - // Attributes - /** Key. */ - Key_T _key; - - /** Reference structure. */ - Structure_T& _structure; - - }; - -} -#endif // __STDAIR_BOM_BS_HPP Deleted: trunk/stdair/stdair/bom/BSKey.hpp =================================================================== --- trunk/stdair/stdair/bom/BSKey.hpp 2010-04-06 14:33:30 UTC (rev 168) +++ trunk/stdair/stdair/bom/BSKey.hpp 2010-04-06 15:34:20 UTC (rev 169) @@ -1,28 +0,0 @@ -#ifndef __STDAIR_BOM_BSKEY_HPP -#define __STDAIR_BOM_BSKEY_HPP - -namespace stdair { - struct BSKey_T { - - // /////////// Display support methods ///////// - void toStream (std::ostream& ioOut) const { - ioOut << "BSKey: " << toString() << std::endl; - } - - void fromStream (std::istream& ioIn) { - } - - const std::string toString() const { - std::ostringstream oStr; - oStr << " -- STOP -- "; - return oStr.str(); - } - - const std::string describe() const { - return toString(); - } - - }; -} - -#endif // __STDAIR_BOM_BSKEY_HPP Deleted: trunk/stdair/stdair/bom/BSTypes.hpp =================================================================== --- trunk/stdair/stdair/bom/BSTypes.hpp 2010-04-06 14:33:30 UTC (rev 168) +++ trunk/stdair/stdair/bom/BSTypes.hpp 2010-04-06 15:34:20 UTC (rev 169) @@ -1,23 +0,0 @@ -// ////////////////////////////////////////////////////////////////////// -#ifndef __STDAIR_BOM_BSTYPES_HPP -#define __STDAIR_BOM_BSTYPES_HPP - -// ////////////////////////////////////////////////////////////////////// -// Import section -// ////////////////////////////////////////////////////////////////////// - -namespace stdair { - // Forward declarations. - template <typename CONTENT> class Structure; - template <typename CONTENT> class BomChildrenHolderImp; - class BS; - - /** Define the BomRootStructure. */ - typedef Structure<BS> BSStructure_T; - - /** Define the BS holder type. */ - typedef BomChildrenHolderImp<BS> BSHolder_T; - -} -#endif // __STDAIR_BOM_BSTYPES_HPP - Modified: trunk/stdair/stdair/bom/FD.hpp =================================================================== --- trunk/stdair/stdair/bom/FD.hpp 2010-04-06 14:33:30 UTC (rev 168) +++ trunk/stdair/stdair/bom/FD.hpp 2010-04-06 15:34:20 UTC (rev 169) @@ -6,15 +6,18 @@ // ////////////////////////////////////////////////////////////////////// // STL #include <iosfwd> +// BOOST Fusion +#include <boost/fusion/container/map.hpp> +#include <boost/fusion/include/map.hpp> // STDAIR #include <stdair/bom/Structure.hpp> #include <stdair/bom/BomContent.hpp> #include <stdair/bom/FDKey.hpp> #include <stdair/bom/FDTypes.hpp> -#include <stdair/bom/BSTypes.hpp> namespace stdair { // Forward declarations. + class IN; class FacBomContent; /** Class representing the actual functional/business content @@ -24,15 +27,17 @@ public: // ///////////////////////////////////////////////////////////////////////// + /** Definition allowing to retrieve the associated parent. */ + typedef IN Parent_T; + /** Definition allowing to retrieve the associated BOM structure type. */ - typedef FDStructure_T Structure_T; + typedef FDStructure_T BomStructure_T; /** Definition allowing to retrieve the associated BOM key type. */ typedef FDKey_T Key_T; /** Define the list of children holder types. */ - typedef boost::fusion::map< - boost::fusion::pair<BS, BSHolder_T*> > ChildrenHolderTypeMap_T; + typedef boost::fusion::map< > ChildrenHolderTypeMap_T; // ///////////////////////////////////////////////////////////////////////// @@ -69,7 +74,7 @@ private: /** Retrieve the BOM structure object. */ - Structure_T& getStructure () { + BomStructure_T& getStructure () { return _structure; } @@ -79,7 +84,7 @@ /** Default constructors. */ FD (); FD (const FD&); - FD (const Key_T& iKey, Structure_T& ioStructure) + FD (const Key_T& iKey, BomStructure_T& ioStructure) : _key (iKey), _structure (ioStructure) { } /** Destructor. */ virtual ~FD() { } @@ -90,7 +95,7 @@ Key_T _key; /** Reference structure. */ - Structure_T& _structure; + BomStructure_T& _structure; }; Modified: trunk/stdair/stdair/bom/IN.hpp =================================================================== --- trunk/stdair/stdair/bom/IN.hpp 2010-04-06 14:33:30 UTC (rev 168) +++ trunk/stdair/stdair/bom/IN.hpp 2010-04-06 15:34:20 UTC (rev 169) @@ -6,6 +6,9 @@ // ////////////////////////////////////////////////////////////////////// // STL #include <iosfwd> +// BOOST Fusion +#include <boost/fusion/container/map.hpp> +#include <boost/fusion/include/map.hpp> // STDAIR #include <stdair/bom/Structure.hpp> #include <stdair/bom/BomContent.hpp> @@ -13,9 +16,13 @@ #include <stdair/bom/INTypes.hpp> #include <stdair/bom/FDTypes.hpp> #include <stdair/bom/NDTypes.hpp> +#include <stdair/bom/FD.hpp> +#include <stdair/bom/ND.hpp> +#include <stdair/bom/BomList.hpp> namespace stdair { // Forward declarations. + class BR; class FacBomContent; /** Class representing the actual functional/business content @@ -25,8 +32,11 @@ public: // ///////////////////////////////////////////////////////////////////////// + /** Definition allowing to retrieve the associated parent. */ + typedef BR Parent_T; + /** Definition allowing to retrieve the associated BOM structure type. */ - typedef INStructure_T Structure_T; + typedef INStructure_T BomStructure_T; /** Definition allowing to retrieve the associated BOM key type. */ typedef INKey_T Key_T; @@ -64,13 +74,21 @@ const Key_T& getKey () const { return _key; } + + const FDList_T getFDList () const { + return _structure.getChildrenHolder<FD> (); + } + + const NDList_T getNDList () const { + return _structure.getChildrenHolder<ND> (); + } public: // //////////// Setters ////////////// private: /** Retrieve the BOM structure object. */ - Structure_T& getStructure () { + BomStructure_T& getStructure () { return _structure; } @@ -80,7 +98,7 @@ /** Default constructors. */ IN (); IN (const IN&); - IN (const Key_T& iKey, Structure_T& ioStructure) + IN (const Key_T& iKey, BomStructure_T& ioStructure) : _key (iKey), _structure (ioStructure) { } /** Destructor. */ virtual ~IN() { } @@ -91,7 +109,7 @@ Key_T _key; /** Reference structure. */ - Structure_T& _structure; + BomStructure_T& _structure; }; Modified: trunk/stdair/stdair/bom/ND.hpp =================================================================== --- trunk/stdair/stdair/bom/ND.hpp 2010-04-06 14:33:30 UTC (rev 168) +++ trunk/stdair/stdair/bom/ND.hpp 2010-04-06 15:34:20 UTC (rev 169) @@ -6,6 +6,9 @@ // ////////////////////////////////////////////////////////////////////// // STL #include <iosfwd> +// BOOST Fusion +#include <boost/fusion/container/map.hpp> +#include <boost/fusion/include/map.hpp> // STDAIR #include <stdair/bom/Structure.hpp> #include <stdair/bom/BomContent.hpp> @@ -14,6 +17,7 @@ namespace stdair { // Forward declarations. + class IN; class FacBomContent; /** Class representing the actual functional/business content @@ -23,8 +27,11 @@ public: // ///////////////////////////////////////////////////////////////////////// + /** Definition allowing to retrieve the associated parent. */ + typedef IN Parent_T; + /** Definition allowing to retrieve the associated BOM structure type. */ - typedef NDStructure_T Structure_T; + typedef NDStructure_T BomStructure_T; /** Definition allowing to retrieve the associated BOM key type. */ typedef NDKey_T Key_T; @@ -67,7 +74,7 @@ private: /** Retrieve the BOM structure object. */ - Structure_T& getStructure () { + BomStructure_T& getStructure () { return _structure; } @@ -77,7 +84,7 @@ /** Default constructors. */ ND (); ND (const ND&); - ND (const Key_T& iKey, Structure_T& ioStructure) + ND (const Key_T& iKey, BomStructure_T& ioStructure) : _key (iKey), _structure (ioStructure) { } /** Destructor. */ virtual ~ND() { } @@ -88,7 +95,7 @@ Key_T _key; /** Reference structure. */ - Structure_T& _structure; + BomStructure_T& _structure; }; Modified: trunk/stdair/stdair/bom/Structure.hpp =================================================================== --- trunk/stdair/stdair/bom/Structure.hpp 2010-04-06 14:33:30 UTC (rev 168) +++ trunk/stdair/stdair/bom/Structure.hpp 2010-04-06 15:34:20 UTC (rev 169) @@ -6,10 +6,17 @@ // ////////////////////////////////////////////////////////////////////// // STL #include <cassert> +// BOOST Fusion +#include <boost/fusion/container/map.hpp> +#include <boost/fusion/include/map.hpp> +#include <boost/fusion/sequence/intrinsic/at_key.hpp> // STDAIR #include <stdair/bom/BomStructure.hpp> namespace stdair { + // Forward declarations. + template <typename CONTENT> class BomChildrenHolderImp; + /** Wrapper class aimed at holding the actual content, modeled by a specific BomContentRoot class. */ template <typename CONTENT> @@ -20,6 +27,9 @@ public: // Type definitions + /** Definition allowing to retrieve the associated content. */ + typedef CONTENT Content_T; + /** Definition allowing to retrieve the associated key type. */ typedef typename CONTENT::Key_T Key_T; @@ -33,6 +43,15 @@ return _content->getKey(); } + template <typename CHILD> + BomChildrenHolderImp<CHILD>& getChildrenHolder () { + BomChildrenHolderImp<CHILD>* lHolder_ptr = + boost::fusion::at_key<CHILD> (_holderMap); + assert (lHolder_ptr != NULL); + + return *lHolder_ptr; + } + private: public: // /////////// Display support methods ///////// Modified: trunk/stdair/stdair/bom/sources.mk =================================================================== --- trunk/stdair/stdair/bom/sources.mk 2010-04-06 14:33:30 UTC (rev 168) +++ trunk/stdair/stdair/bom/sources.mk 2010-04-06 15:34:20 UTC (rev 169) @@ -95,9 +95,6 @@ $(top_srcdir)/stdair/bom/EventTypes.hpp \ $(top_srcdir)/stdair/bom/BomManager.hpp \ $(top_srcdir)/stdair/bom/Structure.hpp \ - $(top_srcdir)/stdair/bom/BS.hpp \ - $(top_srcdir)/stdair/bom/BSKey.hpp \ - $(top_srcdir)/stdair/bom/BSTypes.hpp \ $(top_srcdir)/stdair/bom/BRKey.hpp \ $(top_srcdir)/stdair/bom/BRTypes.hpp \ $(top_srcdir)/stdair/bom/IN.hpp \ Modified: trunk/stdair/stdair/factory/FacBomContent.hpp =================================================================== --- trunk/stdair/stdair/factory/FacBomContent.hpp 2010-04-06 14:33:30 UTC (rev 168) +++ trunk/stdair/stdair/factory/FacBomContent.hpp 2010-04-06 15:34:20 UTC (rev 169) @@ -13,6 +13,7 @@ #include <stdair/basic/BasConst_Inventory.hpp> #include <stdair/basic/DemandCharacteristicTypes.hpp> #include <stdair/bom/BomStructure.hpp> +#include <stdair/bom/Structure.hpp> #include <stdair/factory/FacBomStructure.hpp> namespace stdair { @@ -47,7 +48,7 @@ typedef typename CONTENT::Key_T KEY_T; // Create the structure/holder object - typedef typename CONTENT::Structure_T STRUCTURE_T; + typedef typename CONTENT::BomStructure_T STRUCTURE_T; STRUCTURE_T& lStructure = FacBomStructure::instance().testCreate<STRUCTURE_T> (); @@ -64,11 +65,41 @@ return *aContent_ptr; } + /** Link a child content objet with his parent. */ + template <typename CHILD> + static void testLink (CHILD& ioChild, typename CHILD::Parent_T& ioParent) { + // Type for the child Bom structure + typedef typename CHILD::BomStructure_T CHILD_STRUCTURE_T; + + // Type for the parent Bom content + typedef typename CHILD::Parent_T PARENT_T; + + // Type for the parent Bom structure + typedef typename PARENT_T::BomStructure_T PARENT_STRUCTURE_T; + + + // Retrieve the child structure object + CHILD_STRUCTURE_T& lStructureChild = ioChild.getStructure (); + + // Retrieve the parent structure object + PARENT_STRUCTURE_T& lStructureParent = ioParent.getStructure (); + + // Link both the parent and child structure objects + const bool hasLinkBeenSuccessful = FacBomStructure:: + testLinkParentWithChild<CHILD_STRUCTURE_T> (lStructureParent, + lStructureChild); + + if (hasLinkBeenSuccessful == false) { + throw ObjectLinkingException(); + } + } + private: /** Link the structure/holder object with its corresponding content object. */ template<typename STRUCTURE, typename CONTENT> static void testSetContent (STRUCTURE& ioStructure, + CONTENT& ioContent) { ioStructure._content = &ioContent; } Modified: trunk/stdair/stdair/factory/FacBomStructure.hpp =================================================================== --- trunk/stdair/stdair/factory/FacBomStructure.hpp 2010-04-06 14:33:30 UTC (rev 168) +++ trunk/stdair/stdair/factory/FacBomStructure.hpp 2010-04-06 15:34:20 UTC (rev 169) @@ -17,6 +17,10 @@ #include <boost/mpl/erase.hpp> #include <boost/mpl/begin_end.hpp> #include <boost/type_traits/is_same.hpp> +// BOOST Fusion +#include <boost/fusion/container/map.hpp> +#include <boost/fusion/include/map.hpp> +#include <boost/fusion/sequence/intrinsic/at_key.hpp> // STDAIR #include <stdair/STDAIR_Types.hpp> #include <stdair/basic/BasConst_Inventory.hpp> @@ -83,13 +87,66 @@ } + + template <typename STRUCTURE_CHILD> + static bool testLinkParentWithChild + (typename STRUCTURE_CHILD::Content_T::Parent_T::BomStructure_T& ioParent, + STRUCTURE_CHILD& ioChild) { + typedef typename STRUCTURE_CHILD::Content_T CHILD_CONTENT_T; + + // Retrive the bom children holder corresponding the the children type. + typedef BomChildrenHolderImp<CHILD_CONTENT_T> CHILDREN_HOLDER_T; + + CHILDREN_HOLDER_T*& lChildrenHolder_ptr = + boost::fusion::at_key<CHILD_CONTENT_T> (ioParent._holderMap); + if (lChildrenHolder_ptr == NULL) { + lChildrenHolder_ptr = &instance().createBomHolder<CHILD_CONTENT_T> (); + } + + bool hasInsertBeenSuccessful = + testAddObjectToHolder <CHILD_CONTENT_T> (*lChildrenHolder_ptr, + ioChild); + + return hasInsertBeenSuccessful; + } + /** Add a BOM object into a dedicated BOM holder by using the + short key of the object. */ + template <typename CONTENT> + static bool testAddObjectToHolder (BomChildrenHolderImp<CONTENT>& ioHolder, + typename CONTENT::BomStructure_T& ioStructure) { + // Retrieve the bom structure type. + typedef typename CONTENT::BomStructure_T STRUCTURE_T; + // Define the bom holder type. + typedef BomChildrenHolderImp<CONTENT> HOLDER_T; + + // Retrieve the short key + const typename STRUCTURE_T::Key_T& lKey = ioStructure.getKey(); + const std::string& lKeyStr = lKey.toString(); + + // 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, + &ioStructure)).second; + + if (hasInsertBeenSuccessful == false) { + return hasInsertBeenSuccessful; + } + + ioHolder._bomChildrenList.push_back (&ioStructure); + + return true; + } + + // ////////////////////////////////////////////////////////////////// This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |