From: <qua...@us...> - 2010-07-12 13:57:52
|
Revision: 215 http://stdair.svn.sourceforge.net/stdair/?rev=215&view=rev Author: quannaus Date: 2010-07-12 13:57:46 +0000 (Mon, 12 Jul 2010) Log Message: ----------- [dev] Removed the _intermediateValue in BomIterator which may core and replace it with a boost shared pointer. Modified Paths: -------------- trunk/stdair/stdair/batches/stdair.cpp trunk/stdair/stdair/bom/BomIterator.hpp Modified: trunk/stdair/stdair/batches/stdair.cpp =================================================================== --- trunk/stdair/stdair/batches/stdair.cpp 2010-07-12 08:34:56 UTC (rev 214) +++ trunk/stdair/stdair/batches/stdair.cpp 2010-07-12 13:57:46 UTC (rev 215) @@ -204,14 +204,14 @@ itInv != lInventoryList.end(); ++itInv) { const stdair::Inventory& lCurrentInventory = *itInv; STDAIR_LOG_DEBUG ("Inventory: " << lCurrentInventory.toString()); - - const stdair::FlightDateList_T& lFlightDateList = - lCurrentInventory.getFlightDateList (); - for (stdair::FlightDateList_T::iterator itFlightDate = - lFlightDateList.begin(); - itFlightDate != lFlightDateList.end(); ++itFlightDate) { - const stdair::FlightDate& lCurrentFlightDate = *itFlightDate; - STDAIR_LOG_DEBUG ("FlightDate: " << lCurrentFlightDate.describeKey()); + + const stdair::FlightDateMap_T& lFlightDateMap = + lCurrentInventory.getFlightDateMap (); + for (stdair::FlightDateMap_T::iterator itFlightDate = + lFlightDateMap.begin(); + itFlightDate != lFlightDateMap.end(); ++itFlightDate) { + const stdair::FlightDate* lCurrentFlightDate = itFlightDate->second; + STDAIR_LOG_DEBUG ("FlightDate: " << lCurrentFlightDate->describeKey()); } } Modified: trunk/stdair/stdair/bom/BomIterator.hpp =================================================================== --- trunk/stdair/stdair/bom/BomIterator.hpp 2010-07-12 08:34:56 UTC (rev 214) +++ trunk/stdair/stdair/bom/BomIterator.hpp 2010-07-12 13:57:46 UTC (rev 215) @@ -8,6 +8,9 @@ #include <cassert> #include <vector> #include <map> +// BOOST +#include <boost/shared_ptr.hpp> +#include <boost/make_shared.hpp> namespace stdair { @@ -25,6 +28,7 @@ // Define the pair of string and pointer of CONTENT. typedef typename std::pair<std::string, CONTENT*> value_type; + typedef boost::shared_ptr<value_type> value_type_shared_ptr; // Definition allowing the retrieve the ITERATOR type. typedef ITERATOR iterator_type; @@ -111,7 +115,7 @@ } /** Dereferencing operator for iterators on a map. */ - value_type* operator-> () { + value_type_shared_ptr operator-> () { const MapKey_T& lKey = _itStructureObject->first; const Structure_T* lBomStruct_ptr = _itStructureObject->second; @@ -119,28 +123,14 @@ CONTENT* lBomContent_ptr = BomStructure::getContentPtr<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; + return boost::make_shared<value_type> (lKey, lBomContent_ptr); } private: ///////////// Attributes ////////////// /** Iterator for the current BOM structure on the non-ordered list. */ iterator_type _itStructureObject; - - /** 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; - }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |