From: <qua...@us...> - 2009-10-12 08:57:49
|
Revision: 41 http://stdair.svn.sourceforge.net/stdair/?rev=41&view=rev Author: quannaus Date: 2009-10-12 08:57:42 +0000 (Mon, 12 Oct 2009) Log Message: ----------- [Dev] Added iterators for Inventory. Bom root now replaces the former WorldSchedule. Modified Paths: -------------- trunk/stdair/stdair/bom/BomStructureRoot.hpp trunk/stdair/stdair/bom/InventoryList.hpp trunk/stdair/stdair/bom/sources.mk Added Paths: ----------- trunk/stdair/stdair/bom/InventoryList.cpp trunk/stdair/stdair/bom/InventoryMap.cpp trunk/stdair/stdair/bom/InventoryMap.hpp Modified: trunk/stdair/stdair/bom/BomStructureRoot.hpp =================================================================== --- trunk/stdair/stdair/bom/BomStructureRoot.hpp 2009-10-09 14:15:42 UTC (rev 40) +++ trunk/stdair/stdair/bom/BomStructureRoot.hpp 2009-10-12 08:57:42 UTC (rev 41) @@ -47,7 +47,16 @@ typedef BomChildrenHolderImp<ContentChild_T> ChildrenBomHolder_T; public: + /** Define the iterators of the inventory list. */ + typedef typename ChildrenBomHolder_T::ListIterator_T InventoryListIterator_T; + typedef typename ChildrenBomHolder_T::ListReverseIterator_T InventoryListReverseIterator_T; + /** Define the iterators of the inventory map. */ + typedef typename ChildrenBomHolder_T::MapIterator_T InventoryMapIterator_T; + typedef typename ChildrenBomHolder_T::MapReverseIterator_T InventoryMapReverseIterator_T; + + public: + // /////////// Getters ///////////// /** Get the BomStructureRoot key. */ const BomKey_T& getKey() const { @@ -97,7 +106,64 @@ at the same level). */ const std::string describeShortKey() const { return _key.toString(); } + public: + // /////////// Iteration methods ////////// + /** Initialise the internal iterator on inventory: + return the iterator at the begining of the list. */ + InventoryListIterator_T inventoryListBegin () const { + assert (_childrenList != NULL); + return _childrenList->listBegin (); + } + + /** Initialise the internal iterator on inventory: + return the iterator at the end of the list. */ + InventoryListIterator_T inventoryListEnd () const { + assert (_childrenList != NULL); + return _childrenList->listEnd (); + } + + /** Initialise the internal reverse iterator on inventory: + return the reverse iterator at the rbegining of the list. */ + InventoryListReverseIterator_T inventoryListRBegin () const { + assert (_childrenList != NULL); + return _childrenList->listRBegin (); + } + + /** Initialise the internal reverse iterator on inventory: + return the reverse iterator at the rend of the list. */ + InventoryListReverseIterator_T inventoryListREnd () const { + assert (_childrenList != NULL); + return _childrenList->listREnd (); + } + /** Initialise the internal iterator on inventory: + return the iterator at the begining of the map. */ + InventoryMapIterator_T inventoryMapBegin () const { + assert (_childrenList != NULL); + return _childrenList->mapBegin (); + } + + /** Initialise the internal iterator on inventory: + return the iterator at the end of the map. */ + InventoryMapIterator_T inventoryMapEnd () const { + assert (_childrenList != NULL); + return _childrenList->mapEnd (); + } + + /** Initialise the internal reverse iterator on inventory: + return the reverse iterator at the rbegining of the map. */ + InventoryMapReverseIterator_T inventoryMapRBegin () const { + assert (_childrenList != NULL); + return _childrenList->mapRBegin (); + } + + /** Initialise the internal reverse iterator on inventory: + return the reverse iterator at the rend of the map. */ + InventoryMapReverseIterator_T inventoryMapREnd () const { + assert (_childrenList != NULL); + return _childrenList->mapREnd (); + } + private: /** Constructors are private so as to force the usage of the Factory layer. */ Copied: trunk/stdair/stdair/bom/InventoryList.cpp (from rev 40, trunk/stdair/stdair/bom/FlightDateList.cpp) =================================================================== --- trunk/stdair/stdair/bom/InventoryList.cpp (rev 0) +++ trunk/stdair/stdair/bom/InventoryList.cpp 2009-10-12 08:57:42 UTC (rev 41) @@ -0,0 +1,51 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +// STDAIR +#include <stdair/bom/BomStructureRoot.hpp> +#include <stdair/bom/BomContentRoot.hpp> +#include <stdair/bom/Inventory.hpp> +#include <stdair/bom/InventoryList.hpp> + +namespace stdair { + + // //////////////////////////////////////////////////////////////////// + InventoryList_T:: + InventoryList_T (const BomStructureRoot_T& iBomStructureRoot) + : _bomStructureRoot (iBomStructureRoot) { + } + + // //////////////////////////////////////////////////////////////////// + InventoryList_T:: + InventoryList_T (const InventoryList_T& iINVList) + : _bomStructureRoot (iINVList._bomStructureRoot) { + } + + // //////////////////////////////////////////////////////////////////// + InventoryList_T::~InventoryList_T () { + } + + // ////////////////////////////////////////////////////////////////////// + InventoryList_T::iterator InventoryList_T::begin () const { + return _bomStructureRoot.inventoryListBegin (); + } + + // ////////////////////////////////////////////////////////////////////// + InventoryList_T::iterator InventoryList_T::end () const { + return _bomStructureRoot.inventoryListEnd (); + } + + // ////////////////////////////////////////////////////////////////////// + InventoryList_T::reverse_iterator InventoryList_T::rbegin () const { + return _bomStructureRoot.inventoryListRBegin (); + } + + // ////////////////////////////////////////////////////////////////////// + InventoryList_T::reverse_iterator InventoryList_T::rend () const { + return _bomStructureRoot.inventoryListREnd (); + } + +} + Modified: trunk/stdair/stdair/bom/InventoryList.hpp =================================================================== --- trunk/stdair/stdair/bom/InventoryList.hpp 2009-10-09 14:15:42 UTC (rev 40) +++ trunk/stdair/stdair/bom/InventoryList.hpp 2009-10-12 08:57:42 UTC (rev 41) @@ -4,16 +4,63 @@ // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// -// STL -#include <string> -#include <map> -#include <vector> -#include <list> +// STDAIR +#include <stdair/bom/BomRootTypes.hpp> +#include <stdair/bom/InventoryTypes.hpp> namespace stdair { + +// Forward declarations + template <typename BOM_CONTENT, typename ITERATOR> struct BomIterator_T; - /** Forward declarations. */ - class Inventory; + /** Structure which handles the iterators for a flight-date list. */ + struct InventoryList_T { + public: + // ///////////////////////////////////////////////////////////////////////// + // See the explanations, within the stdair::BomContentRoot class, for all + // the iterator types specified below + // ///////////////////////////////////////////////////////////////////////// + /** Define the flight-date list iterators. */ + typedef BomIterator_T<Inventory, + InventoryStructureList_T::const_iterator> iterator; + typedef BomIterator_T<Inventory, + InventoryStructureList_T::const_reverse_iterator> reverse_iterator; + // ///////////////////////////////////////////////////////////////////////// + + public: + // /////////// Iteration methods ////////// + /** Initialise the internal iterator on flight date: + return the iterator at the begining of the list. */ + iterator begin () const; + + /** Initialise the internal iterator on flight date: + return the iterator at the end of the list. */ + iterator end () const; + + /** Initialise the internal reverse iterator on flight date: + return the reverse iterator at the rbegining of the list. */ + reverse_iterator rbegin () const; + + /** Initialise the internal reverse iterator on flight date: + return the reverse iterator at the end of the list. */ + reverse_iterator rend () const; + + public: + /** Default constructors. */ + InventoryList_T (); + InventoryList_T (const InventoryList_T&); + InventoryList_T (const BomStructureRoot_T&); + + /** Destructor. */ + virtual ~InventoryList_T(); + + private: + // Attributes + /** Reference structure. */ + const BomStructureRoot_T& _bomStructureRoot; + }; + } #endif // __STDAIR_BOM_INVENTORYLIST_HPP + Copied: trunk/stdair/stdair/bom/InventoryMap.cpp (from rev 40, trunk/stdair/stdair/bom/FlightDateMap.cpp) =================================================================== --- trunk/stdair/stdair/bom/InventoryMap.cpp (rev 0) +++ trunk/stdair/stdair/bom/InventoryMap.cpp 2009-10-12 08:57:42 UTC (rev 41) @@ -0,0 +1,51 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +// STDAIR +#include <stdair/bom/BomStructureRoot.hpp> +#include <stdair/bom/BomContentRoot.hpp> +#include <stdair/bom/Inventory.hpp> +#include <stdair/bom/InventoryMap.hpp> + +namespace stdair { + + // //////////////////////////////////////////////////////////////////// + InventoryMap_T:: + InventoryMap_T (const BomStructureRoot_T& iBomStructureRoot) + : _bomStructureRoot (iBomStructureRoot) { + } + + // //////////////////////////////////////////////////////////////////// + InventoryMap_T:: + InventoryMap_T (const InventoryMap_T& iINVMap) + : _bomStructureRoot (iINVMap._bomStructureRoot) { + } + + // //////////////////////////////////////////////////////////////////// + InventoryMap_T::~InventoryMap_T () { + } + + // ////////////////////////////////////////////////////////////////////// + InventoryMap_T::iterator InventoryMap_T::begin () const { + return _bomStructureRoot.inventoryMapBegin (); + } + + // ////////////////////////////////////////////////////////////////////// + InventoryMap_T::iterator InventoryMap_T::end () const { + return _bomStructureRoot.inventoryMapEnd (); + } + + // ////////////////////////////////////////////////////////////////////// + InventoryMap_T::reverse_iterator InventoryMap_T::rbegin () const { + return _bomStructureRoot.inventoryMapRBegin (); + } + + // ////////////////////////////////////////////////////////////////////// + InventoryMap_T::reverse_iterator InventoryMap_T::rend () const { + return _bomStructureRoot.inventoryMapREnd (); + } + +} + Copied: trunk/stdair/stdair/bom/InventoryMap.hpp (from rev 40, trunk/stdair/stdair/bom/FlightDateMap.hpp) =================================================================== --- trunk/stdair/stdair/bom/InventoryMap.hpp (rev 0) +++ trunk/stdair/stdair/bom/InventoryMap.hpp 2009-10-12 08:57:42 UTC (rev 41) @@ -0,0 +1,66 @@ +#ifndef __STDAIR_BOM_INVENTORYMAP_HPP +#define __STDAIR_BOM_INVENTORYMAP_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STDAIR +#include <stdair/bom/BomRootTypes.hpp> +#include <stdair/bom/InventoryTypes.hpp> + +namespace stdair { + +// Forward declarations + template <typename BOM_CONTENT, typename ITERATOR> struct BomIterator_T; + + /** Structure which handles the iterators for a flight-date map. */ + struct InventoryMap_T { + + public: + // ///////////////////////////////////////////////////////////////////////// + // See the explanations, within the stdair::BomContentRoot class, for all + // the iterator types specified below + // ///////////////////////////////////////////////////////////////////////// + /** Define the flight-date map iterators. */ + typedef BomIterator_T<Inventory, + InventoryStructureMap_T::const_iterator> iterator; + typedef BomIterator_T<Inventory, + InventoryStructureMap_T::const_reverse_iterator> reverse_iterator; + // ///////////////////////////////////////////////////////////////////////// + + public: + // /////////// Iteration methods ////////// + /** Initialise the internal iterator on flight date: + return the iterator at the begining of the map. */ + iterator begin () const; + + /** Initialise the internal iterator on flight date: + return the iterator at the end of the map. */ + iterator end () const; + + /** Initialise the internal reverse iterator on flight date: + return the reverse iterator at the rbegining of the map. */ + reverse_iterator rbegin () const; + + /** Initialise the internal reverse iterator on flight date: + return the reverse iterator at the end of the map. */ + reverse_iterator rend () const; + + public: + /** Default constructors. */ + InventoryMap_T (); + InventoryMap_T (const InventoryMap_T&); + InventoryMap_T (const BomStructureRoot_T&); + + /** Destructor. */ + virtual ~InventoryMap_T(); + + private: + // Attributes + /** Reference structure. */ + const BomStructureRoot_T& _bomStructureRoot; + }; + +} +#endif // __STDAIR_BOM_INVENTORYMAP_HPP + Modified: trunk/stdair/stdair/bom/sources.mk =================================================================== --- trunk/stdair/stdair/bom/sources.mk 2009-10-09 14:15:42 UTC (rev 40) +++ trunk/stdair/stdair/bom/sources.mk 2009-10-12 08:57:42 UTC (rev 41) @@ -11,6 +11,8 @@ $(top_srcdir)/stdair/bom/BomStructureDummy.hpp \ $(top_srcdir)/stdair/bom/Inventory.hpp \ $(top_srcdir)/stdair/bom/InventoryTypes.hpp \ + $(top_srcdir)/stdair/bom/InventoryList.hpp \ + $(top_srcdir)/stdair/bom/InventoryMap.hpp \ $(top_srcdir)/stdair/bom/InventoryStructure.hpp \ $(top_srcdir)/stdair/bom/FlightDate.hpp \ $(top_srcdir)/stdair/bom/FlightDateTypes.hpp \ @@ -35,6 +37,8 @@ $(top_srcdir)/stdair/bom/BomIterator.hpp bom_cc_sources = \ $(top_srcdir)/stdair/bom/Inventory.cpp \ + $(top_srcdir)/stdair/bom/InventoryList.cpp \ + $(top_srcdir)/stdair/bom/InventoryMap.cpp \ $(top_srcdir)/stdair/bom/FlightDate.cpp \ $(top_srcdir)/stdair/bom/FlightDateList.cpp \ $(top_srcdir)/stdair/bom/FlightDateMap.cpp \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |