From: <den...@us...> - 2010-09-03 13:15:28
|
Revision: 302 http://stdair.svn.sourceforge.net/stdair/?rev=302&view=rev Author: denis_arnaud Date: 2010-09-03 13:15:21 +0000 (Fri, 03 Sep 2010) Log Message: ----------- [Test] Fixed the architecture test. Modified Paths: -------------- trunk/stdair/test/architecture/BomRoot.cpp trunk/stdair/test/architecture/BomRoot.hpp trunk/stdair/test/architecture/Inventory.cpp trunk/stdair/test/architecture/Inventory.hpp trunk/stdair/test/architecture/architecture.cpp trunk/stdair/test/architecture/sources.mk Removed Paths: ------------- trunk/stdair/test/architecture/LH.cpp trunk/stdair/test/architecture/Structure.hpp trunk/stdair/test/architecture/StructureTypes.hpp Modified: trunk/stdair/test/architecture/BomRoot.cpp =================================================================== --- trunk/stdair/test/architecture/BomRoot.cpp 2010-09-03 09:49:28 UTC (rev 301) +++ trunk/stdair/test/architecture/BomRoot.cpp 2010-09-03 13:15:21 UTC (rev 302) @@ -3,13 +3,17 @@ // ////////////////////////////////////////////////////////////////////// // STL #include <cassert> -#include "BomRoot.hpp" +// Local +#include <test/architecture/BomRoot.hpp> -// //////////////////////////////////////////////////////////////////// -BomRoot::BomRoot (const Key_T& iKey, Structure_T& ioBomRootStructure) - : BomRootContent (iKey), _structure (ioBomRootStructure) { -} +namespace myairline { + + // //////////////////////////////////////////////////////////////////// + BomRoot::BomRoot (const Key_T& iKey) : stdair::BomRoot (iKey) { + } + + // //////////////////////////////////////////////////////////////////// + BomRoot::~BomRoot () { + } -// //////////////////////////////////////////////////////////////////// -BomRoot::~BomRoot () { } Modified: trunk/stdair/test/architecture/BomRoot.hpp =================================================================== --- trunk/stdair/test/architecture/BomRoot.hpp 2010-09-03 09:49:28 UTC (rev 301) +++ trunk/stdair/test/architecture/BomRoot.hpp 2010-09-03 13:15:21 UTC (rev 302) @@ -1,54 +1,39 @@ -#ifndef __BOMROOT_HPP -#define __BOMROOT_HPP +#ifndef __MYAIRLINE_BOMROOT_HPP +#define __MYAIRLINE_BOMROOT_HPP // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// +// STL #include <string> -#include "StructureTypes.hpp" // StdAir -#include <stdair/bom/BomRootContent.hpp> +#include <stdair/bom/BomRoot.hpp> -/** Class representing the actual functional/business content - for the Bom root. */ -class BomRoot : public stdair::BomRootContent { -public: - /** Definition allowing to retrieve the associated BOM structure type. */ - typedef BomRootStructure_T Structure_T; - /** Definition allowing to retrieve the map/multimap type using by - BomChildrenHolder. */ - typedef std::map<const std::string, const Structure_T*> Map_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(); } +namespace myairline { + + /** Class representing the actual functional/business content + for the Bom root. */ + class BomRoot : public stdair::BomRoot { + public: + // /////////// Display support methods ///////// + /** 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 (""); } - -public: -/** Constructors are private so as to force the usage of the Factory - layer. */ -/** Constructors. */ -BomRoot (const Key_T&, Structure_T&); -/** Destructor. */ -~BomRoot(); -/** Default constructors. */ -BomRoot (); -BomRoot (const BomRoot&); - -// Attributes -/** Reference structure. */ -Structure_T& _structure; -}; -#endif // __BOMROOT_HPP + /** Get a string describing the whole key (differentiating two objects + at any level). */ + const std::string describeKey() const { return std::string (""); } + + public: + /** Constructors are private so as to force the usage of the Factory + layer. */ + /** Constructors. */ + BomRoot (const Key_T&); + /** Destructor. */ + ~BomRoot(); + /** Default constructors. */ + BomRoot (); + BomRoot (const BomRoot&); + }; + +} +#endif // __MYAIRLINE_BOMROOT_HPP Modified: trunk/stdair/test/architecture/Inventory.cpp =================================================================== --- trunk/stdair/test/architecture/Inventory.cpp 2010-09-03 09:49:28 UTC (rev 301) +++ trunk/stdair/test/architecture/Inventory.cpp 2010-09-03 13:15:21 UTC (rev 302) @@ -3,34 +3,29 @@ // ////////////////////////////////////////////////////////////////////// // STL #include <cassert> -#include "Inventory.hpp" +// Local +#include <test/architecture/Inventory.hpp> -// //////////////////////////////////////////////////////////////////// -Inventory::Inventory (const Key_T& iKey, - Structure_T& ioInventoryStructure) - : InventoryContent (iKey), _structure (ioInventoryStructure) { -} +namespace myairline { + + // //////////////////////////////////////////////////////////////////// + Inventory::Inventory (const Key_T& iKey) : stdair::Inventory (iKey) { + } -// //////////////////////////////////////////////////////////////////// -Inventory::~Inventory () { -} -// //////////////////////////////////////////////////////////////////// -void Inventory::toStream (std::ostream& ioOut) const { - ioOut << toString() << std::endl; -} + // //////////////////////////////////////////////////////////////////// + Inventory::~Inventory () { + } -// //////////////////////////////////////////////////////////////////// -void Inventory::fromStream (std::istream& ioIn) { + // //////////////////////////////////////////////////////////////////// + std::string Inventory::toString() const { + std::ostringstream oStr; + oStr << _key.toString(); + return oStr.str(); + } + + // //////////////////////////////////////////////////////////////////// + const std::string Inventory::describeKey() const { + return _key.toString(); + } + } - -// //////////////////////////////////////////////////////////////////// -std::string Inventory::toString() const { - std::ostringstream oStr; - oStr << _key.toString(); - return oStr.str(); -} - -// //////////////////////////////////////////////////////////////////// -const std::string Inventory::describeKey() const { - return _key.toString(); -} Modified: trunk/stdair/test/architecture/Inventory.hpp =================================================================== --- trunk/stdair/test/architecture/Inventory.hpp 2010-09-03 09:49:28 UTC (rev 301) +++ trunk/stdair/test/architecture/Inventory.hpp 2010-09-03 13:15:21 UTC (rev 302) @@ -1,55 +1,41 @@ -#ifndef __INVENTORY_HPP -#define __INVENTORY_HPP +#ifndef __MYAIRLINE_INVENTORY_HPP +#define __MYAIRLINE_INVENTORY_HPP // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// -#include <string> -#include "StructureTypes.hpp" -#include <stdair/bom/InventoryContent.hpp> +// STL +#include <list> +// StdAir +#include <stdair/bom/Inventory.hpp> -class Inventory : public stdair::InventoryContent { - friend class FacBomContent; -public: - /** Definition allowing to retrieve the associated BOM structure type. */ - typedef InventoryStructure_T Structure_T; - /** Definition allowing to retrieve the map/multimap type using by - BomChildrenHolder. */ - typedef std::map<const std::string, const Structure_T*> Map_T; - -public: -// /////////// Display support methods ///////// -/** Dump a Business Object into an output stream. - @param ostream& the output stream. */ -void toStream (std::ostream& ioOut) const; - -/** 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; +namespace myairline { + + class Inventory : public stdair::Inventory { + public: + // /////////// Display support methods ///////// + /** Get the serialised version of the Business Object. */ + std::string toString() const; -/** Get a string describing the whole key (differentiating two objects - at any level). */ -const std::string describeKey() const; - - -public: -/** Constructors are private so as to force the usage of the Factory - layer. */ -/** Constructors. */ -Inventory (const Key_T&, Structure_T&); -/** Destructor. */ -~Inventory(); -/** Default constructors. */ -Inventory (); -Inventory (const Inventory&); - -// Attributes -/** Reference structure. */ -Structure_T& _structure; -}; - -#endif // __INVENTORY_HPP - + /** Get a string describing the whole key (differentiating two objects + at any level). */ + const std::string describeKey() const; + + public: + /** Constructors are private so as to force the usage of the Factory + layer. */ + /** Constructors. */ + Inventory (const Key_T&); + /** Destructor. */ + ~Inventory(); + /** Default constructors. */ + Inventory (); + Inventory (const Inventory&); + }; + + // ////////// Type definitions ///////// + /** Type for the list of inventories. */ + typedef std::list<Inventory*> InventoryList_T; + +} +#endif // __MYAIRLINE_INVENTORY_HPP Deleted: trunk/stdair/test/architecture/LH.cpp =================================================================== --- trunk/stdair/test/architecture/LH.cpp 2010-09-03 09:49:28 UTC (rev 301) +++ trunk/stdair/test/architecture/LH.cpp 2010-09-03 13:15:21 UTC (rev 302) @@ -1,33 +0,0 @@ - -// StdAir -#include <stdair/bom/BomRoot.hpp> -#include <stdair/bom/Inventory.hpp> -#include <stdair/bom/FlightDate.hpp> - -namespace LH { - - /** - * \brief LH own implementation of the BomRoot class - */ - class BomRootImpl : public stdair::BomRootContent { - }; - - /** - * \brief LH own implementation of the FlightDate class - */ - class FlightDateImpl : public stdair::FlightDateContent { - }; - - /** - * \brief Initialisation of objects - */ - void init() { - stdair::BomRoot<BomRootImpl> lhBomRoot; - stdair::Inventory<stdair::InventoryImpl> lhInventory; - stdair::link(lhBomRoot, lhInventory); - - stdair::FlightDate<lh::FlightDateImpl> lhFlightDate; - stdair::link (lhInventory, lhFlightDate); - } - -} Deleted: trunk/stdair/test/architecture/Structure.hpp =================================================================== --- trunk/stdair/test/architecture/Structure.hpp 2010-09-03 09:49:28 UTC (rev 301) +++ trunk/stdair/test/architecture/Structure.hpp 2010-09-03 13:15:21 UTC (rev 302) @@ -1,171 +0,0 @@ -#ifndef __STRUCTURE_HPP -#define __STRUCTURE_HPP - -// ////////////////////////////////////////////////////////////////////// -// Import section -// ////////////////////////////////////////////////////////////////////// -#include "StructureTypes.hpp" -#include <stdair/bom/BomStructure.hpp> -// STL -#include <cassert> - -namespace stdair { - // Forward declarations. - template <typename CONTENT> class BomChildrenHolderImp; - template <typename CONTENT> class BomMap_T; - template <typename CONTENT> class BomMultimap_T; - template <typename CONTENT> class BomList_T; -} - -/** Wrapper class aimed at holding the actual content, modeled - by a specific BomContentRoot class. */ -template <typename CONTENT> -class Structure : public stdair::BomStructure { - -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_T::Key_T Key_T; - - /** Definition allowing to retrieve the map of children holder type. */ - typedef typename boost::mpl::at< - ChildrenHolderMapMap_T, Content_T>::type ChildrenHolderMap_T; - - /** Definition allowing to retrieve the parent structure type. */ - typedef typename boost::mpl::at< - ParentMap_T, Content_T>::type::Structure_T Parent_T; - -public: - // ////////// Getters //////////// - /** Get the content object. */ - const Content_T& getContent () const { - assert (_content != NULL); - return *_content; - } - - /** Get the key of the content object. */ - const Key_T& getKey () const { - assert (_content != NULL); - return _content->getKey(); - } - - /** Get the parent structure. */ - const Parent_T& getParent () const { - assert (_parent != NULL); - return *_parent; - } - - /** The the holder which corresponds to the CHILD type. */ - template <typename CHILD> - stdair::BomChildrenHolderImp<CHILD>& getChildrenHolder () const { - - stdair::BomChildrenHolderImp<CHILD>* lHolder_ptr = - boost::fusion::at_key<CHILD> (_holderMap); - - assert (lHolder_ptr != NULL); - return *lHolder_ptr; - } - - /** Retrieve, if existing, the pointer of CHILD type corresponding to the - given key. - <br>If not exissting, return the NULL pointer. */ - template <typename CHILD> - CHILD* getChildPtr (const std::string& iKey) const { - CHILD* oContentChild_ptr = NULL; - - stdair::BomChildrenHolderImp<CHILD>* lHolder_ptr = - boost::fusion::at_key<CHILD> (_holderMap); - - if (lHolder_ptr != NULL) { - // Look for the child in the map, then in the multimap - stdair::BomMap_T<CHILD> lChildrenMap (*lHolder_ptr); - typename stdair::BomMap_T<CHILD>::iterator itContentChild = - lChildrenMap.find (iKey); - if (itContentChild != lChildrenMap.end()) { - oContentChild_ptr = itContentChild->second; - } - } - - return oContentChild_ptr; - } - - /** Retrieve, child of CHILD type corresponding to the given key. */ - template <typename CHILD> - CHILD& getChild (const std::string& iKey) const { - CHILD* lChild_ptr = NULL; - - const stdair::BomChildrenHolderImp<CHILD>& lHolder = getChildrenHolder<CHILD>(); - stdair::BomMap_T<CHILD> lChildrenMap (lHolder); - - typename stdair::BomMap_T<CHILD>::iterator itContentChild = - lChildrenMap.find (iKey); - - if (itContentChild != lChildrenMap.end()) { - lChild_ptr = itContentChild->second; - } - - assert (lChild_ptr != NULL); - return *lChild_ptr; - } - - // /////////// Business method //////////// - /** Initialise the pointer of children holder to NULL. */ - template <typename CHILD> - void initChildrenHolder() { - - stdair::BomChildrenHolderImp<CHILD>*& lHolder_ptr = - boost::fusion::at_key<CHILD> (_holderMap); - lHolder_ptr = NULL; - } - -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 short key (differentiating two objects - at the same level). */ - const std::string describeShortKey() const { return getKey().toString(); } - - /** Get a string describing the parent's whole key - (differentiating two objects at any level). */ - const std::string describeParentKey() const { - assert (_parent != NULL); - return _parent->getContent().describeKey(); - } - -public: - /** Constructors are private so as to force the usage of the Factory - layer. */ - /** Default constructors. */ - Structure () : _parent (NULL), _content (NULL) { } - Structure (const Structure&) { assert (false); }; - /** Destructor. */ - ~Structure () { } - -public: - // Attributes - /** The parent structure. */ - Parent_T* _parent; - - /** The actual functional (Business Object) content. */ - Content_T* _content; - - /** The map of children holders. */ - ChildrenHolderMap_T _holderMap; -}; - -#endif // __STRUCTURE_HPP Deleted: trunk/stdair/test/architecture/StructureTypes.hpp =================================================================== --- trunk/stdair/test/architecture/StructureTypes.hpp 2010-09-03 09:49:28 UTC (rev 301) +++ trunk/stdair/test/architecture/StructureTypes.hpp 2010-09-03 13:15:21 UTC (rev 302) @@ -1,46 +0,0 @@ -// ////////////////////////////////////////////////////////////////////// -#ifndef __STRUCTURETYPES_HPP -#define __STRUCTURETYPES_HPP - -// ////////////////////////////////////////////////////////////////////// -// Import section -// ///////////////////////////////////////////// -// BOOST -#include <boost/fusion/include/map.hpp> -#include <boost/mpl/map.hpp> - -// Forward declarations. -namespace stdair { - template <typename CONTENT> class BomChildrenHolderImp; - template <typename BOM> struct BomList_T; - template <typename BOM> struct BomMap_T; -} -template <typename CONTENT> class Structure; -class BomRoot; -class Inventory; - -// ///////////////////////////////////////////////// -typedef Structure<BomRoot> BomRootStructure_T; -typedef Structure<Inventory> InventoryStructure_T; -typedef stdair::BomChildrenHolderImp<Inventory> InventoryHolder_T; -typedef stdair::BomList_T<Inventory> InventoryList_T; -typedef stdair::BomMap_T<Inventory> InventoryMap_T; - -// ///////////////////////////////////////////////// -typedef boost::mpl::map < - boost::mpl::pair<Inventory, BomRoot>, - boost::mpl::pair<BomRoot, BomRoot> > ParentMap_T; - -typedef boost::fusion::map< - boost::fusion::pair<Inventory, InventoryHolder_T*> - >BomRootChildrenHolderMap_T; -typedef boost::fusion::map< > InventoryChildrenHolderMap_T; - -typedef boost::mpl::map < - boost::mpl::pair<BomRoot, BomRootChildrenHolderMap_T>, - boost::mpl::pair<Inventory, InventoryChildrenHolderMap_T> - > ChildrenHolderMapMap_T; - - -#endif // __STRUCTURETYPES_HPP - Modified: trunk/stdair/test/architecture/architecture.cpp =================================================================== --- trunk/stdair/test/architecture/architecture.cpp 2010-09-03 09:49:28 UTC (rev 301) +++ trunk/stdair/test/architecture/architecture.cpp 2010-09-03 13:15:21 UTC (rev 302) @@ -2,35 +2,46 @@ #include <cassert> #include <iostream> #include <string> -#include <stdair/factory/FacBomContent.hpp> -#include <stdair/bom/BomSource.hpp> -#include "BomRoot.hpp" -#include "Inventory.hpp" -#include "Structure.hpp" -#include "StructureTypes.hpp" +// StdAir +#include <stdair/bom/BomRoot.hpp> +#include <stdair/bom/BomManager.hpp> +#include <stdair/factory/FacBom.hpp> +#include <stdair/factory/FacBomManager.hpp> +// Local +//#include <test/architecture/BomRoot.hpp> +#include <test/architecture/Inventory.hpp> // ////////// M A I N ////////////// int main (int argc, char* argv[]) { + // Step 0.0: initialisation // Create the root of the Bom tree (i.e., a BomRoot object) - BomRoot& lBomRoot = - stdair::FacBomContent::instance().create<BomRoot>(); + stdair::BomRoot& lBomRoot = + stdair::FacBom<stdair::BomRoot>::instance().create(); // Step 0.1: Inventory level // Create an Inventory (BA) const stdair::AirlineCode_T lAirlineCode ("BA"); - stdair::InventoryKey_T lInventoryKey (lAirlineCode); - - Inventory& lInventory = - stdair::FacBomContent::instance().create<Inventory>(lInventoryKey); - stdair::FacBomContent::linkWithParent (lInventory, lBomRoot); + const stdair::InventoryKey lBAKey (lAirlineCode); + myairline::Inventory& lBAInv = + stdair::FacBom<myairline::Inventory>::instance().create (lBAKey); + stdair::FacBomManager::addToList (lBomRoot, lBAInv); - const InventoryList_T& lInventoryList = - lBomRoot._structure.getChildrenHolder<Inventory>(); - for (InventoryList_T::iterator itInv = lInventoryList.begin(); - itInv != lInventoryList.end(); ++itInv) { - const Inventory& lCurrentInventory = *itInv; - std::cout << "Inventory: " << lCurrentInventory.toString() << std::endl; + // Create an Inventory for AF + const stdair::InventoryKey lAFKey ("AF"); + myairline::Inventory& lAFInv = + stdair::FacBom<myairline::Inventory>::instance().create (lAFKey); + stdair::FacBomManager::addToList (lBomRoot, lAFInv); + + // Browse the inventories + const myairline::InventoryList_T& lInventoryList = + stdair::BomManager::getList<myairline::Inventory> (lBomRoot); + for (myairline::InventoryList_T::const_iterator itInv = + lInventoryList.begin(); itInv != lInventoryList.end(); ++itInv) { + const myairline::Inventory* lInv_ptr = *itInv; + assert (lInv_ptr != NULL); + + std::cout << "Inventory: " << lInv_ptr->toString() << std::endl; } return 0; Modified: trunk/stdair/test/architecture/sources.mk =================================================================== --- trunk/stdair/test/architecture/sources.mk 2010-09-03 09:49:28 UTC (rev 301) +++ trunk/stdair/test/architecture/sources.mk 2010-09-03 13:15:21 UTC (rev 302) @@ -1,7 +1,7 @@ -architecture_h_sources = $(srcdir)/StructureTypes.hpp \ - $(srcdir)/Structure.hpp \ - $(srcdir)/BomRoot.hpp \ - $(srcdir)/Inventory.hpp -architecture_cc_sources = $(srcdir)/architecture.cpp \ - $(srcdir)/BomRoot.cpp \ - $(srcdir)/Inventory.cpp +architecture_h_sources = \ + $(srcdir)/Inventory.hpp +# $(srcdir)/BomRoot.hpp +architecture_cc_sources = \ + $(srcdir)/Inventory.cpp \ + $(srcdir)/architecture.cpp +# $(srcdir)/BomRoot.cpp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |