RMOL Logo Get Revenue Management Optimisation Library at SourceForge.net. Fast, secure and Free Open Source software downloads

PartialSumHolderHolder.cpp

Go to the documentation of this file.
00001 // //////////////////////////////////////////////////////////////////////
00002 // Import section
00003 // //////////////////////////////////////////////////////////////////////
00004 // C
00005 #include <assert.h>
00006 // STL
00007 #include <istream>
00008 #include <ostream>
00009 // RMOL
00010 #include <rmol/bom/PartialSumHolder.hpp>
00011 #include <rmol/bom/PartialSumHolderHolder.hpp>
00012 
00013 namespace RMOL {
00014 
00015   // //////////////////////////////////////////////////////////////////////
00016   PartialSumHolderHolder::PartialSumHolderHolder () {
00017   }
00018 
00019   // //////////////////////////////////////////////////////////////////////
00020   PartialSumHolderHolder::~PartialSumHolderHolder() {
00021     _partialSumHolderList.clear ();
00022   }
00023 
00024   // //////////////////////////////////////////////////////////////////////
00025   const std::string PartialSumHolderHolder::describeShortKey() const {
00026     std::ostringstream oStr;
00027     return oStr.str();
00028   }
00029   
00030   // //////////////////////////////////////////////////////////////////////
00031   const std::string PartialSumHolderHolder::describeKey() const {
00032     return describeShortKey();
00033   }
00034 
00035   // //////////////////////////////////////////////////////////////////////
00036   std::string PartialSumHolderHolder::toString() const {
00037     std::ostringstream oStr;
00038     return oStr.str();
00039   }   
00040 
00041   // //////////////////////////////////////////////////////////////////////
00042   void PartialSumHolderHolder::toStream (std::ostream& ioOut) const {
00043     ioOut << toString();
00044   }
00045   
00046   // //////////////////////////////////////////////////////////////////////
00047   void PartialSumHolderHolder::fromStream (std::istream& ioIn) {
00048   }
00049   
00050   // //////////////////////////////////////////////////////////////////////
00051   const std::string PartialSumHolderHolder::shortDisplay() const {
00052     std::ostringstream oStr;
00053     oStr << describeKey();
00054     return oStr.str();
00055   }
00056   
00057   // //////////////////////////////////////////////////////////////////////
00058   const std::string PartialSumHolderHolder::display() const {
00059     std::ostringstream oStr;
00060     oStr << shortDisplay();
00061 
00062     PartialSumHolderList_T::const_iterator itPartialSumHolder = 
00063       _partialSumHolderList.begin();
00064     for (short j = 1; itPartialSumHolder != _partialSumHolderList.end(); 
00065          itPartialSumHolder++, j++) {
00066       const PartialSumHolder* currentPartialSumHolder_ptr = *itPartialSumHolder;
00067       assert (currentPartialSumHolder_ptr != NULL);
00068       
00069       oStr << j << "; " << currentPartialSumHolder_ptr->display();
00070     }
00071     return oStr.str();
00072   }
00073 
00074   // //////////////////////////////////////////////////////////////////////
00075   const short PartialSumHolderHolder::getSize () const {
00076     return _partialSumHolderList.size();
00077   }
00078 
00079   // //////////////////////////////////////////////////////////////////////
00080   PartialSumHolder& PartialSumHolderHolder::
00081   getPreviousPartialSumHolder () const {
00082     PartialSumHolder* resultPartialSumHolder_ptr=  *_itPreviousPartialSumHolder;
00083     assert (resultPartialSumHolder_ptr != NULL);
00084     return (*resultPartialSumHolder_ptr);
00085   }
00086 
00087   // //////////////////////////////////////////////////////////////////////
00088   PartialSumHolder& PartialSumHolderHolder::
00089   getCurrentPartialSumHolder () const {
00090     PartialSumHolder* resultPartialSumHolder_ptr = *_itCurrentPartialSumHolder;
00091     assert (resultPartialSumHolder_ptr != NULL);
00092     return (*resultPartialSumHolder_ptr);
00093   }
00094 
00095   // //////////////////////////////////////////////////////////////////////
00096   bool PartialSumHolderHolder::hasNotReachedEnd () const {
00097     bool result = (_itCurrentPartialSumHolder != _partialSumHolderList.end());
00098     return result;
00099   }
00100 
00101   // //////////////////////////////////////////////////////////////////////
00102   void PartialSumHolderHolder::
00103   addPartialSumHolder (PartialSumHolder& ioPartialSumHolder) {
00104     _partialSumHolderList.push_back (&ioPartialSumHolder);
00105   }
00106 
00107   // //////////////////////////////////////////////////////////////////////
00108   void PartialSumHolderHolder::begin () {
00109     _itCurrentPartialSumHolder = _partialSumHolderList.begin();
00110     _itPreviousPartialSumHolder = _partialSumHolderList.begin();
00111   }
00112 
00113   // //////////////////////////////////////////////////////////////////////
00114   void PartialSumHolderHolder::iterate () {
00115     if (_itCurrentPartialSumHolder != _partialSumHolderList.begin()) {
00116       _itPreviousPartialSumHolder++;
00117 
00118     } else {
00119       assert (_itPreviousPartialSumHolder == _partialSumHolderList.begin());
00120     }
00121 
00122     if (_itCurrentPartialSumHolder != _partialSumHolderList.end()) {
00123       _itCurrentPartialSumHolder++;
00124     }
00125   }
00126 
00127 }
SourceForge Logo

Generated on Sat Jun 6 13:49:02 2009 for RMOL by Doxygen 1.5.7.1