|
From: <qua...@us...> - 2009-10-02 09:34:36
|
Revision: 10
http://stdair.svn.sourceforge.net/stdair/?rev=10&view=rev
Author: quannaus
Date: 2009-10-02 09:34:26 +0000 (Fri, 02 Oct 2009)
Log Message:
-----------
Added the non-const iterators and the functions for these iterators in Inventory and BomChildrenHolderImp.
Modified Paths:
--------------
trunk/stdair/stdair/bom/BomChildrenHolderImp.hpp
trunk/stdair/stdair/bom/BomIterator.hpp
trunk/stdair/stdair/bom/Inventory.hpp
Modified: trunk/stdair/stdair/bom/BomChildrenHolderImp.hpp
===================================================================
--- trunk/stdair/stdair/bom/BomChildrenHolderImp.hpp 2009-10-02 08:32:09 UTC (rev 9)
+++ trunk/stdair/stdair/bom/BomChildrenHolderImp.hpp 2009-10-02 09:34:26 UTC (rev 10)
@@ -34,7 +34,19 @@
typedef BomConstIterator_T<BOM_CONTENT_CHILD,
typename BomChildrenOrderedList_T::const_iterator> ListConstIterator_T;
typedef BomConstIterator_T<BOM_CONTENT_CHILD,
+ typename BomChildrenOrderedList_T::const_reverse_iterator> ListConstReverseIterator_T;
+ typedef BomIterator_T<BOM_CONTENT_CHILD,
+ typename BomChildrenOrderedList_T::iterator> ListIterator_T;
+ typedef BomIterator_T<BOM_CONTENT_CHILD,
+ typename BomChildrenOrderedList_T::_reverse_iterator> ListReverseIterator_T;
+ typedef BomConstIterator_T<BOM_CONTENT_CHILD,
typename BomChildrenList_T::const_iterator> MapConstIterator_T;
+ typedef BomConstIterator_T<BOM_CONTENT_CHILD,
+ typename BomChildrenList_T::const_reverse_iterator> MapConstReverseIterator_T;
+ typedef BomIterator_T<BOM_CONTENT_CHILD,
+ typename BomChildrenList_T::iterator> MapIterator_T;
+ typedef BomIterator_T<BOM_CONTENT_CHILD,
+ typename BomChildrenList_T::_reverse_iterator> MapReverseIterator_T;
public:
// /////////// Display support methods /////////
@@ -83,8 +95,44 @@
return the iterator past the end of the list. */
ListConstIterator_T listConstIteratorEnd () const {
return _bomChildrenOrderedList.end();
- }
+ }
+ /** Initialise the internal const reverse iterators on bom objects:
+ return the reverse iterator at the rbegining of the list. */
+ ListConstReverseIterator_T listConstIteratorRBegin () const {
+ return _bomChildrenOrderedList.rbegin();
+ }
+
+ /** Initialise the internal const reverse iterators on bom objects:
+ return the reverse iterator past the rend of the list. */
+ ListConstReverseIterator_T listConstIteratorREnd () const {
+ return _bomChildrenOrderedList.rend();
+ }
+
+ /** Initialise the internal iterators on bom objects:
+ return the iterator at the begining of the list. */
+ ListIterator_T listIteratorBegin () const {
+ return _bomChildrenOrderedList.begin();
+ }
+
+ /** Initialise the internal iterators on bom objects:
+ return the iterator past the end of the list. */
+ ListIterator_T listIteratorEnd () const {
+ return _bomChildrenOrderedList.end();
+ }
+
+ /** Initialise the internal reverse iterators on bom objects:
+ return the reverse iterator at the rbegining of the list. */
+ ListReverseIterator_T listIteratorRBegin () const {
+ return _bomChildrenOrderedList.rbegin();
+ }
+
+ /** Initialise the internal reverse iterators on bom objects:
+ return the reverse iterator past the rend of the list. */
+ ListReverseIterator_T listIteratorREnd () const {
+ return _bomChildrenOrderedList.rend();
+ }
+
/** Initialise the internal const iterators on bom objects:
return the iterator at the begining of the map. */
MapConstIterator_T mapConstIteratorBegin () const {
@@ -95,8 +143,44 @@
return the iterator past the end of the map. */
MapConstIterator_T mapConstIteratorEnd () const {
return _bomChildrenList.end();
- }
+ }
+ /** Initialise the internal const reverse iterators on bom objects:
+ return the reverse iterator at the rbegining of the map. */
+ MapConstReverseIterator_T mapConstIteratorRBegin () const {
+ return _bomChildrenList.rbegin();
+ }
+
+ /** Initialise the internal const reverse iterators on bom objects:
+ return the reverse iterator past the rend of the map. */
+ MapConstReverseIterator_T mapConstIteratorREnd () const {
+ return _bomChildrenList.rend();
+ }
+
+ /** Initialise the internal iterators on bom objects:
+ return the iterator at the begining of the map. */
+ MapIterator_T mapIteratorBegin () const {
+ return _bomChildrenList.begin();
+ }
+
+ /** Initialise the internal iterators on bom objects:
+ return the iterator past the end of the map. */
+ MapIterator_T mapIteratorEnd () const {
+ return _bomChildrenList.end();
+ }
+
+ /** Initialise the internal reverse iterators on bom objects:
+ return the reverse iterator at the rbegining of the map. */
+ MapReverseIterator_T mapIteratorRBegin () const {
+ return _bomChildrenList.rbegin();
+ }
+
+ /** Initialise the internal reverse iterators on bom objects:
+ return the reverse iterator past the rend of the map. */
+ MapReverseIterator_T mapIteratorREnd () const {
+ return _bomChildrenList.rend();
+ }
+
private:
/** Constructors are private so as to force the usage of the Factory
layer. */
Modified: trunk/stdair/stdair/bom/BomIterator.hpp
===================================================================
--- trunk/stdair/stdair/bom/BomIterator.hpp 2009-10-02 08:32:09 UTC (rev 9)
+++ trunk/stdair/stdair/bom/BomIterator.hpp 2009-10-02 09:34:26 UTC (rev 10)
@@ -22,8 +22,6 @@
struct BomIteratorAbstract {
protected:
- /** Constructors are private so as to force the usage of the Factory
- layer. */
/** Normal constructor. */
BomIteratorAbstract (ITERATOR iIterator)
: _itBomStructureObject (iIterator) { }
@@ -113,8 +111,6 @@
typedef typename ITERATOR::difference_type difference_type;
public:
- /** Constructors are private so as to force the usage of the Factory
- layer. */
/** Normal constructor. */
BomConstIterator_T (ITERATOR iIterator)
: Parent_T (iIterator) { }
@@ -199,5 +195,111 @@
(n+r.Parent_T::_itBomStructureObject);
}
+ /** Template class aimed at iterating a list or a map of children BOM
+ structure of a dedicated type using non-const iterators.
+ <br> This class aimed at implementing the specific operators for
+ non-const iterators.
+ */
+ template <typename BOM_CONTENT, typename ITERATOR>
+ struct BomIterator_T : public BomIteratorAbstract<ITERATOR> {
+
+ public:
+ // Definition allowing to retrieve the parent type.
+ typedef BomIteratorAbstract<ITERATOR> Parent_T;
+
+ // Definition allowing to retrieve the corresponding bom structure.
+ typedef typename BOM_CONTENT::BomStructure_T BomStructure_T;
+
+ // Define the pair of string and pointer of BOM_CONTENT.
+ typedef typename std::pair<std::string, BOM_CONTENT*> value_type;
+
+ // Definition allowing the retrieve the difference type of the ITERATOR.
+ typedef typename ITERATOR::difference_type difference_type;
+
+ public:
+ /** Normal constructor. */
+ BomIterator_T (ITERATOR iIterator)
+ : Parent_T (iIterator) { }
+
+ /** Default constructor. */
+ BomIterator_T () { }
+
+ /** Default copy constructor. */
+ BomIterator_T (const BomIterator_T& iBomIterator)
+ : Parent_T (iBomIterator._itBomStructureObject) { }
+
+ /** Destructor. */
+ ~BomIterator_T() { }
+
+ public:
+ // ////////////// Additive Operators ///////////////
+ BomIterator_T operator+ (const difference_type iIndex) {
+ return BomIterator_T(Parent_T::_itBomStructureObject + iIndex);
+ }
+ BomIterator_T& operator+= (const difference_type iIndex) {
+ Parent_T::_itBomStructureObject += iIndex;
+ return *this;
+ }
+ BomIterator_T operator- (const difference_type iIndex) {
+ return BomIterator_T(Parent_T::_itBomStructureObject - iIndex);
+ }
+ BomIterator_T& operator-= (const difference_type iIndex) {
+ Parent_T::_itBomStructureObject -= iIndex;
+ return *this;
+ }
+
+ // ////////////// Dereferencing Operators //////////////
+ /** Dereferencing operator for iterators on a list. */
+ BOM_CONTENT& operator* () {
+ BomStructure_T* lBomStruct_ptr = *Parent_T::_itBomStructureObject;
+ assert (lBomStruct_ptr != NULL);
+ BOM_CONTENT* lBomContent_ptr =
+ BomStructure::getBomContentPtr<BOM_CONTENT> (*lBomStruct_ptr);
+ assert (lBomContent_ptr != NULL);
+ return *lBomContent_ptr;
+ }
+
+ /** Dereferencing operator for iterators on a map. */
+ value_type* operator-> () {
+ const MapKey_T& lKey = Parent_T::_itBomStructureObject->first;
+ BomStructure_T* lBomStruct_ptr = Parent_T::_itBomStructureObject->second;
+ assert (lBomStruct_ptr != NULL);
+ BOM_CONTENT* lBomContent_ptr =
+ BomStructure::getBomContentPtr<BOM_CONTENT> (*lBomStruct_ptr);
+ assert (lBomContent_ptr != NULL);
+
+ // See the comment below, at the definition of the _intermediateValue
+ // attribute
+ _intermediateValue.first = lKey;
+ _intermediateValue.second = lBomContent_ptr;
+
+ return &_intermediateValue;
+ }
+
+ protected:
+ /** Helper attribute.
+ <br>It is necessary to define that value at the attribute
+ level, because the operator->() method needs to return a
+ pointer on it. If that value be temporary, i.e., created at
+ the fly when the operator->() method returns, we would return
+ a pointer on a temporary value, which is not good. */
+ value_type _intermediateValue;
+
+ };
+
+ /**
+ Operators for BomIterator_T that need to be implemented outside
+ of BomIterator_T scope.
+ */
+ template<typename BOM_CONTENT, typename ITERATOR>
+ inline BomIterator_T<BOM_CONTENT, ITERATOR>
+ operator+(const typename ITERATOR::difference_type n,
+ const BomIterator_T<BOM_CONTENT, ITERATOR>& r) {
+ // Definition allowing to retrieve the Parent_T of BomIterator_T.
+ typedef typename BomIterator_T<BOM_CONTENT,ITERATOR>::Parent_T Parent_T;
+ return BomIterator_T<BOM_CONTENT, ITERATOR>
+ (n+r.Parent_T::_itBomStructureObject);
+ }
+
}
#endif // __STDAIR_BOM_BOMITERATOR_T_HPP
Modified: trunk/stdair/stdair/bom/Inventory.hpp
===================================================================
--- trunk/stdair/stdair/bom/Inventory.hpp 2009-10-02 08:32:09 UTC (rev 9)
+++ trunk/stdair/stdair/bom/Inventory.hpp 2009-10-02 09:34:26 UTC (rev 10)
@@ -56,11 +56,17 @@
/** Define the children bom holder type. */
typedef BomChildrenHolderImp<ContentChild_T> ChildrenBomHolder_T;
- /** Define the iterator of the flight-date list. */
+ /** Define the iterators of the flight-date list. */
typedef typename ChildrenBomHolder_T::ListConstIterator_T FlightDateListConstIterator_T;
+ typedef typename ChildrenBomHolder_T::ListConstReverseIterator_T FlightDateListConstReverseIterator_T;
+ typedef typename ChildrenBomHolder_T::ListIterator_T FlightDateListIterator_T;
+ typedef typename ChildrenBomHolder_T::ListReverseIterator_T FlightDateListReverseIterator_T;
- /** Define the iterator of the flight-date map. */
+ /** Define the iterators of the flight-date map. */
typedef typename ChildrenBomHolder_T::MapConstIterator_T FlightDateMapConstIterator_T;
+ typedef typename ChildrenBomHolder_T::MapConstReverseIterator_T FlightDateMapConstReverseIterator_T;
+ typedef typename ChildrenBomHolder_T::MapIterator_T FlightDateMapIterator_T;
+ typedef typename ChildrenBomHolder_T::MapReverseIterator_T FlightDateMapReverseIterator_T;
public:
// /////////// Getters /////////////
@@ -158,7 +164,49 @@
assert (_childrenList != NULL);
return _childrenList->listConstIteratorEnd ();
}
+
+ /** Initialise the internal const reverse iterator on flight date:
+ return the const reverse iterator at the rbegining of the list. */
+ FlightDateListConstReverseIterator_T flightDateListConstIteratorRBegin () const {
+ assert (_childrenList != NULL);
+ return _childrenList->listConstIteratorRBegin ();
+ }
+
+ /** Initialise the internal const reverse iterator on flight date:
+ return the const reverse iterator at the rend of the list. */
+ FlightDateListConstReverseIterator_T flightDateListConstIteratorREnd () const {
+ assert (_childrenList != NULL);
+ return _childrenList->listConstIteratorREnd ();
+ }
+ /** Initialise the internal iterator on flight date:
+ return the iterator at the begining of the list. */
+ FlightDateListIterator_T flightDateListIteratorBegin () const {
+ assert (_childrenList != NULL);
+ return _childrenList->listIteratorBegin ();
+ }
+
+ /** Initialise the internal iterator on flight date:
+ return the iterator at the end of the list. */
+ FlightDateListIterator_T flightDateListIteratorEnd () const {
+ assert (_childrenList != NULL);
+ return _childrenList->listIteratorEnd ();
+ }
+
+ /** Initialise the internal reverse iterator on flight date:
+ return the reverse iterator at the rbegining of the list. */
+ FlightDateListReverseIterator_T flightDateListIteratorRBegin () const {
+ assert (_childrenList != NULL);
+ return _childrenList->listIteratorRBegin ();
+ }
+
+ /** Initialise the internal reverse iterator on flight date:
+ return the reverse iterator at the rend of the list. */
+ FlightDateListReverseIterator_T flightDateListIteratorREnd () const {
+ assert (_childrenList != NULL);
+ return _childrenList->listIteratorREnd ();
+ }
+
/** Initialise the internal const iteratorson flight date:
return the const iterator at the begining of the map. */
FlightDateMapConstIterator_T flightDateMapConstIteratorBegin () const {
@@ -171,8 +219,50 @@
FlightDateMapConstIterator_T flightDateMapConstIteratorEnd () const {
assert (_childrenList != NULL);
return _childrenList->mapConstIteratorEnd ();
- }
+ }
+
+ /** Initialise the internal const reverse iterator on flight date:
+ return the const reverse iterator at the rbegining of the map. */
+ FlightDateMapConstReverseIterator_T flightDateMapConstIteratorRBegin () const {
+ assert (_childrenList != NULL);
+ return _childrenList->mapConstIteratorRBegin ();
+ }
+ /** Initialise the internal const reverse iterator on flight date:
+ return the const reverse iterator at the rend of the map. */
+ FlightDateMapConstReverseIterator_T flightDateMapConstIteratorREnd () const {
+ assert (_childrenList != NULL);
+ return _childrenList->mapConstIteratorREnd ();
+ }
+
+ /** Initialise the internal iterator on flight date:
+ return the iterator at the begining of the map. */
+ FlightDateMapIterator_T flightDateMapIteratorBegin () const {
+ assert (_childrenList != NULL);
+ return _childrenList->mapIteratorBegin ();
+ }
+
+ /** Initialise the internal iterator on flight date:
+ return the iterator at the end of the map. */
+ FlightDateMapIterator_T flightDateMapIteratorEnd () const {
+ assert (_childrenList != NULL);
+ return _childrenList->mapIteratorEnd ();
+ }
+
+ /** Initialise the internal reverse iterator on flight date:
+ return the reverse iterator at the rbegining of the map. */
+ FlightDateMapReverseIterator_T flightDateMapIteratorRBegin () const {
+ assert (_childrenList != NULL);
+ return _childrenList->mapIteratorRBegin ();
+ }
+
+ /** Initialise the internal reverse iterator on flight date:
+ return the reverse iterator at the rend of the map. */
+ FlightDateMapReverseIterator_T flightDateMapIteratorREnd () const {
+ assert (_childrenList != NULL);
+ return _childrenList->mapIteratorREnd ();
+ }
+
private:
/** Constructors are private so as to force the usage of the Factory
layer. */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|