From: <qua...@us...> - 2010-04-06 12:47:33
|
Revision: 165 http://stdair.svn.sourceforge.net/stdair/?rev=165&view=rev Author: quannaus Date: 2010-04-06 12:47:26 +0000 (Tue, 06 Apr 2010) Log Message: ----------- [dev] test new implementation. Modified Paths: -------------- trunk/stdair/stdair/Makefile.am trunk/stdair/stdair/bom/sources.mk trunk/stdair/stdair/factory/FacBomContent.hpp trunk/stdair/stdair/factory/FacBomStructure.hpp Added Paths: ----------- trunk/stdair/stdair/batches/Makefile.am trunk/stdair/stdair/batches/sources.mk trunk/stdair/stdair/batches/stdair.cpp trunk/stdair/stdair/bom/BR.hpp trunk/stdair/stdair/bom/BRKey.hpp trunk/stdair/stdair/bom/BRTypes.hpp trunk/stdair/stdair/bom/IN.hpp trunk/stdair/stdair/bom/INKey.hpp trunk/stdair/stdair/bom/INTypes.hpp trunk/stdair/stdair/bom/Structure.hpp Modified: trunk/stdair/stdair/Makefile.am =================================================================== --- trunk/stdair/stdair/Makefile.am 2010-03-27 18:17:00 UTC (rev 164) +++ trunk/stdair/stdair/Makefile.am 2010-04-06 12:47:26 UTC (rev 165) @@ -6,7 +6,7 @@ MAINTAINERCLEANFILES = Makefile.in -SUBDIRS = basic bom dbadaptor factory command config service core +SUBDIRS = basic bom dbadaptor factory command config service core batches #EXTRA_DIST = config_msvc.h EXTRA_DIST = Added: trunk/stdair/stdair/batches/Makefile.am =================================================================== --- trunk/stdair/stdair/batches/Makefile.am (rev 0) +++ trunk/stdair/stdair/batches/Makefile.am 2010-04-06 12:47:26 UTC (rev 165) @@ -0,0 +1,18 @@ +# batches +include $(top_srcdir)/Makefile.common +include $(srcdir)/sources.mk + +## Source directory + +MAINTAINERCLEANFILES = Makefile.in + + +# Binaries (batches) +bin_PROGRAMS = stdair + +stdair_SOURCES = $(batches_h_sources) $(batches_cc_sources) +stdair_CXXFLAGS = $(BOOST_CFLAGS) +stdair_LDADD = +stdair_LDFLAGS = $(BOOST_PROGRAM_OPTIONS_LIB) \ + $(top_builddir)/stdair/core/libstdair.la \ + $(top_builddir)/stdair/core/libstdair.la Added: trunk/stdair/stdair/batches/sources.mk =================================================================== --- trunk/stdair/stdair/batches/sources.mk (rev 0) +++ trunk/stdair/stdair/batches/sources.mk 2010-04-06 12:47:26 UTC (rev 165) @@ -0,0 +1,2 @@ +batches_h_sources = +batches_cc_sources = $(top_srcdir)/stdair/batches/stdair.cpp Added: trunk/stdair/stdair/batches/stdair.cpp =================================================================== --- trunk/stdair/stdair/batches/stdair.cpp (rev 0) +++ trunk/stdair/stdair/batches/stdair.cpp 2010-04-06 12:47:26 UTC (rev 165) @@ -0,0 +1,37 @@ +// STL +#include <cassert> +#include <iostream> +#include <sstream> +#include <fstream> +#include <string> +// StdAir +#include <stdair/STDAIR_Types.hpp> +#include <stdair/STDAIR_Service.hpp> +#include <stdair/bom/BR.hpp> +#include <stdair/bom/BRKey.hpp> +#include <stdair/bom/BRTypes.hpp> +#include <stdair/bom/IN.hpp> +#include <stdair/bom/INKey.hpp> +#include <stdair/bom/INTypes.hpp> +#include <stdair/factory/FacBomContent.hpp> + + +// ///////// M A I N //////////// +int main (int argc, char* argv[]) { + try { + + stdair::BRKey_T lBRKey (); + stdair::BR& lBR = + stdair::FacBomContent::instance().testCreate<stdair::BR> (lBRKey); + + + } catch (const std::exception& stde) { + std::cerr << "Standard exception: " << stde.what() << std::endl; + return -1; + + } catch (...) { + return -1; + } + + return 0; +} Added: trunk/stdair/stdair/bom/BR.hpp =================================================================== --- trunk/stdair/stdair/bom/BR.hpp (rev 0) +++ trunk/stdair/stdair/bom/BR.hpp 2010-04-06 12:47:26 UTC (rev 165) @@ -0,0 +1,97 @@ +#ifndef __STDAIR_BOM_BR_HPP +#define __STDAIR_BOM_BR_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/BRKey.hpp> +#include <stdair/bom/BRTypes.hpp> +#include <stdair/bom/INTypes.hpp> + +namespace stdair { + // Forward declarations. + class FacBomContent; + class IN; + + /** Class representing the actual functional/business content + for the Bom root. */ + class BR : public BomContent { + friend class FacBomContent; + + public: + // ///////////////////////////////////////////////////////////////////////// + /** Definition allowing to retrieve the associated BOM structure type. */ + typedef BRStructure_T Structure_T; + + /** Definition allowing to retrieve the associated BOM key type. */ + typedef BRKey_T Key_T; + + /** Define the list of children holder types. */ + typedef boost::fusion::map<boost::fusion::pair<IN, INHolder_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 ///////////// + + + 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. */ + BR (); + BR (const BR&); + BR (const Key_T&, Structure_T&); + /** Destructor. */ + virtual ~BR(); + + private: + // Attributes + /** Key. */ + Key_T _key; + + /** Reference structure. */ + Structure_T& _structure; + + }; + +} +#endif // __STDAIR_BOM_BR_HPP Added: trunk/stdair/stdair/bom/BRKey.hpp =================================================================== --- trunk/stdair/stdair/bom/BRKey.hpp (rev 0) +++ trunk/stdair/stdair/bom/BRKey.hpp 2010-04-06 12:47:26 UTC (rev 165) @@ -0,0 +1,10 @@ +#ifndef __STDAIR_BOM_BRKEY_HPP +#define __STDAIR_BOM_BRKEY_HPP + +namespace stdair { + struct BRKey_T { + + }; +} + +#endif // __STDAIR_BOM_BRKEY_HPP Added: trunk/stdair/stdair/bom/BRTypes.hpp =================================================================== --- trunk/stdair/stdair/bom/BRTypes.hpp (rev 0) +++ trunk/stdair/stdair/bom/BRTypes.hpp 2010-04-06 12:47:26 UTC (rev 165) @@ -0,0 +1,19 @@ +// ////////////////////////////////////////////////////////////////////// +#ifndef __STDAIR_BOM_BRTYPES_HPP +#define __STDAIR_BOM_BRTYPES_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// + +namespace stdair { + // Forward declarations. + template <typename CONTENT> class Structure; + class BR; + + /** Define the BomRootStructure. */ + typedef Structure<BR> BRStructure_T; + +} +#endif // __STDAIR_BOM_BRTYPES_HPP + Added: trunk/stdair/stdair/bom/IN.hpp =================================================================== --- trunk/stdair/stdair/bom/IN.hpp (rev 0) +++ trunk/stdair/stdair/bom/IN.hpp 2010-04-06 12:47:26 UTC (rev 165) @@ -0,0 +1,91 @@ +#ifndef __STDAIR_BOM_IN_HPP +#define __STDAIR_BOM_IN_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <iosfwd> +// STDAIR +#include <stdair/bom/Structure.hpp> +#include <stdair/bom/BomContent.hpp> +#include <stdair/bom/INTypes.hpp> +#include <stdair/bom/INKey.hpp> + +namespace stdair { + // Forward declarations. + class FacBomContent; + + /** Class representing the actual functional/business content + for the Bom root. */ + class IN : public BomContent { + friend class FacBomContent; + + public: + // ///////////////////////////////////////////////////////////////////////// + /** Definition allowing to retrieve the associated BOM structure type. */ + typedef INStructure_T Structure_T; + + /** Definition allowing to retrieve the associated BOM key type. */ + typedef INKey_T Key_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 ///////////// + + + 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. */ + IN (); + IN (const IN&); + IN (const Key_T&, Structure_T&); + /** Destructor. */ + virtual ~IN(); + + private: + // Attributes + /** Key. */ + Key_T _key; + + /** Reference structure. */ + Structure_T& _structure; + + }; + +} +#endif // __STDAIR_BOM_IN_HPP Added: trunk/stdair/stdair/bom/INKey.hpp =================================================================== --- trunk/stdair/stdair/bom/INKey.hpp (rev 0) +++ trunk/stdair/stdair/bom/INKey.hpp 2010-04-06 12:47:26 UTC (rev 165) @@ -0,0 +1,10 @@ +#ifndef __STDAIR_BOM_INKEY_HPP +#define __STDAIR_BOM_INKEY_HPP + +namespace stdair { + struct INKey_T { + + }; +} + +#endif // __STDAIR_BOM_INKEY_HPP Added: trunk/stdair/stdair/bom/INTypes.hpp =================================================================== --- trunk/stdair/stdair/bom/INTypes.hpp (rev 0) +++ trunk/stdair/stdair/bom/INTypes.hpp 2010-04-06 12:47:26 UTC (rev 165) @@ -0,0 +1,23 @@ +// ////////////////////////////////////////////////////////////////////// +#ifndef __STDAIR_BOM_INTYPES_HPP +#define __STDAIR_BOM_INTYPES_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// + +namespace stdair { + // Forward declarations. + template <typename CONTENT> class Structure; + template <typename CONTENT> class BomChildrenHolderImp; + class IN; + + /** Define the BomRootStructure. */ + typedef Structure<IN> INStructure_T; + + /** Define the Inventory holder type. */ + typedef BomChildrenHolderImp<IN> INHolder_T; + +} +#endif // __STDAIR_BOM_INTYPES_HPP + Added: trunk/stdair/stdair/bom/Structure.hpp =================================================================== --- trunk/stdair/stdair/bom/Structure.hpp (rev 0) +++ trunk/stdair/stdair/bom/Structure.hpp 2010-04-06 12:47:26 UTC (rev 165) @@ -0,0 +1,81 @@ +#ifndef __STDAIR_BOM_STRUCTURE_HPP +#define __STDAIR_BOM_STRUCTURE_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +// STDAIR +#include <stdair/bom/BomStructure.hpp> + +namespace stdair { + /** Wrapper class aimed at holding the actual content, modeled + by a specific BomContentRoot class. */ + template <typename CONTENT> + class Structure : public BomStructure { + friend class FacBomStructure; + friend class FacBomContent; + friend class BomStructure; + + public: + // Type definitions + /** Definition allowing to retrieve the associated key type. */ + typedef typename CONTENT::Key_T Key_T; + + /** Definition allowing to retrieve the map of children holder type. */ + typedef typename CONTENT::ChildrenHolderTypeMap_T ChildrenHolderTypeMap_T; + + public: + // ////////// GETTERS //////////// + const Key_T& getKey () { + assert (_content != NULL); + return _content->getKey(); + } + + private: + 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() << std::endl; + } + + /** 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 describeShortKey(); } + + /** Get a string describing the whole key (differentiating two objects + at any level). */ + const std::string describeKey() const { return getKey().describe(); } + + /** Get a string describing the short key (differentiating two objects + at the same level). */ + const std::string describeShortKey() const { return getKey().toString(); } + + private: + /** Constructors are private so as to force the usage of the Factory + layer. */ + /** Default constructors. */ + Structure () : _content (NULL) { }; + Structure (const Structure&); + + /** Destructor. */ + ~Structure () { } + + private: + // Attributes + /** The actual functional (Business Object) content. */ + CONTENT* _content; + + /** The map of children holders. */ + ChildrenHolderTypeMap_T _holderMap; + }; + +} +#endif // __STDAIR_BOM_STRUCTURE_HPP + Modified: trunk/stdair/stdair/bom/sources.mk =================================================================== --- trunk/stdair/stdair/bom/sources.mk 2010-03-27 18:17:00 UTC (rev 164) +++ trunk/stdair/stdair/bom/sources.mk 2010-04-06 12:47:26 UTC (rev 165) @@ -93,7 +93,14 @@ $(top_srcdir)/stdair/bom/EventStruct.hpp \ $(top_srcdir)/stdair/bom/EventQueue.hpp \ $(top_srcdir)/stdair/bom/EventTypes.hpp \ - $(top_srcdir)/stdair/bom/BomManager.hpp + $(top_srcdir)/stdair/bom/BomManager.hpp \ + $(top_srcdir)/stdair/bom/Structure.hpp \ + $(top_srcdir)/stdair/bom/BR.hpp \ + $(top_srcdir)/stdair/bom/BRKey.hpp \ + $(top_srcdir)/stdair/bom/BRTypes.hpp \ + $(top_srcdir)/stdair/bom/IN.hpp \ + $(top_srcdir)/stdair/bom/INKey.hpp \ + $(top_srcdir)/stdair/bom/INTypes.hpp bom_cc_sources = \ $(top_srcdir)/stdair/bom/BomRootKey.cpp \ $(top_srcdir)/stdair/bom/InventoryKey.cpp \ Modified: trunk/stdair/stdair/factory/FacBomContent.hpp =================================================================== --- trunk/stdair/stdair/factory/FacBomContent.hpp 2010-03-27 18:17:00 UTC (rev 164) +++ trunk/stdair/stdair/factory/FacBomContent.hpp 2010-04-06 12:47:26 UTC (rev 165) @@ -33,7 +33,55 @@ public: /** Define the list (pool) of Bom objects. */ typedef std::vector<BomContent*> BomContentPool_T; + + + + + + + // ////////////////////////////////////////////////////////////////// public: + template <typename CONTENT> + CONTENT& testCreate (const typename CONTENT::Key_T& iKey) { + typedef typename CONTENT::Key_T KEY_T; + + // Create the structure/holder object + typedef typename CONTENT::Structure_T STRUCTURE_T; + STRUCTURE_T& lStructure = + FacBomStructure::instance().testCreate<STRUCTURE_T> (); + + + CONTENT* aContent_ptr = new CONTENT (iKey, lStructure); + assert (aContent_ptr != NULL); + + // The new object is added to the pool of content objects + _contentPool.push_back (aContent_ptr); + + // Link the structure/holder object with its corresponding content object + testSetContent<STRUCTURE_T, CONTENT> (lStructure, *aContent_ptr); + + return *aContent_ptr; + } + + 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; + } + + + + + + + + + // ////////////////////////////////////////////////////////////////// + + public: /** Create the root of the BOM tree, i.e., a pair of linked BomRootStructure and BomRoot objects. */ template <typename BOM_ROOT> Modified: trunk/stdair/stdair/factory/FacBomStructure.hpp =================================================================== --- trunk/stdair/stdair/factory/FacBomStructure.hpp 2010-03-27 18:17:00 UTC (rev 164) +++ trunk/stdair/stdair/factory/FacBomStructure.hpp 2010-04-06 12:47:26 UTC (rev 165) @@ -62,8 +62,38 @@ <br>The singleton is instantiated when first used. @return FacBomStructure& */ static FacBomStructure& instance(); + + + // ////////////////////////////////////////////////////////////////// + + public: /** Create a structure object with the given key. */ + template <typename STRUCTURE> + STRUCTURE& testCreate () { + STRUCTURE* aStructure_ptr = NULL; + + aStructure_ptr = new STRUCTURE (); + assert (aStructure_ptr != NULL); + + // The new object is added to the pool of structure objects + _structurePool.push_back (aStructure_ptr); + + return *aStructure_ptr; + } + + + + + + + + + + // ////////////////////////////////////////////////////////////////// + + + /** Create a structure object with the given key. */ template <typename BOM_STRUCTURE> BOM_STRUCTURE& create () { BOM_STRUCTURE* aBomStructure_ptr = NULL; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |