$treeview $search $mathjax
StdAir Logo  1.00.1
$projectbrief
$projectbrief
$searchbox

stdair/basic/ProgressStatus.cpp

Go to the documentation of this file.
00001 // //////////////////////////////////////////////////////////////////////
00002 // Import section
00003 // //////////////////////////////////////////////////////////////////////
00004 // STL
00005 #include <cassert>
00006 #include <sstream>
00007 // StdAir
00008 #include <stdair/stdair_exceptions.hpp>
00009 #include <stdair/basic/BasConst_Event.hpp>
00010 #include <stdair/basic/ProgressStatus.hpp>
00011 
00012 namespace stdair {
00013   
00014   // //////////////////////////////////////////////////////////////////////
00015   ProgressStatus::ProgressStatus (const Count_T& iCurrentNb,
00016                                   const Count_T& iExpectedNb,
00017                                   const Count_T& iActualNb)
00018     : _currentNb (iCurrentNb),
00019       _expectedNb (iExpectedNb), _actualNb (iActualNb) {
00020   }
00021   
00022   // //////////////////////////////////////////////////////////////////////
00023   ProgressStatus::ProgressStatus (const Count_T& iExpectedNb,
00024                                   const Count_T& iActualNb)
00025     : _currentNb (DEFAULT_PROGRESS_STATUS),
00026       _expectedNb (iExpectedNb), _actualNb (iActualNb) {
00027   }
00028 
00029   // //////////////////////////////////////////////////////////////////////
00030   ProgressStatus::ProgressStatus (const Count_T& iExpectedNb)
00031     : _currentNb (DEFAULT_PROGRESS_STATUS),
00032       _expectedNb (iExpectedNb), _actualNb (iExpectedNb) {
00033   }
00034 
00035   // //////////////////////////////////////////////////////////////////////
00036   ProgressStatus::ProgressStatus()
00037     : _currentNb (DEFAULT_PROGRESS_STATUS),
00038       _expectedNb (DEFAULT_PROGRESS_STATUS),
00039       _actualNb (DEFAULT_PROGRESS_STATUS) {
00040   }
00041 
00042   // //////////////////////////////////////////////////////////////////////
00043   ProgressStatus::ProgressStatus (const ProgressStatus& iProgressStatus)
00044     : _currentNb (iProgressStatus._currentNb),
00045       _expectedNb (iProgressStatus._expectedNb),
00046       _actualNb (iProgressStatus._actualNb) {
00047   }
00048   
00049   // //////////////////////////////////////////////////////////////////////
00050   void ProgressStatus::reset() {
00051     _currentNb = DEFAULT_PROGRESS_STATUS;
00052     _actualNb = DEFAULT_PROGRESS_STATUS;
00053   }
00054 
00055   // //////////////////////////////////////////////////////////////////////
00056   const std::string ProgressStatus::describe() const {
00057     std::ostringstream oStr;
00058     oStr << _currentNb << " / {" << _expectedNb << ", " << _actualNb << "}";
00059     return oStr.str();
00060   } 
00061   
00062   // //////////////////////////////////////////////////////////////////////
00063   const std::string ProgressStatus::toString() const {
00064     std::ostringstream oStr;
00065     oStr << std::setprecision (3) << progress() 
00066          << "%  (" << _currentNb << "/" << _actualNb << ")";
00067     return oStr.str();
00068   }
00069   
00070 }