$treeview $search $mathjax
00001 #ifndef __STDAIR_BAS_PROGRESSSTATUS_HPP 00002 #define __STDAIR_BAS_PROGRESSSTATUS_HPP 00003 00004 // ////////////////////////////////////////////////////////////////////// 00005 // Import section 00006 // ////////////////////////////////////////////////////////////////////// 00007 // STL 00008 #include <string> 00009 // Boost Progress 00010 #include <boost/progress.hpp> 00011 // StdAir 00012 #include <stdair/basic/BasConst_Event.hpp> 00013 #include <stdair/stdair_basic_types.hpp> 00014 #include <stdair/basic/StructAbstract.hpp> 00015 #include <stdair/service/Logger.hpp> 00016 00017 namespace stdair { 00018 00027 struct ProgressStatus : public StructAbstract { 00028 public: 00029 // //////////////// Getters ///////////////// 00031 const Count_T& count() const { 00032 return _currentNb; 00033 } 00034 00036 const Count_T& getCurrentNb() const { 00037 return _currentNb; 00038 } 00039 00041 const Count_T& getExpectedNb() const { 00042 return _expectedNb; 00043 } 00044 00046 const Count_T& getActualNb() const { 00047 return _actualNb; 00048 } 00049 00051 const ProgressPercentage_T progress() const { 00052 if (_actualNb == 0) { 00053 return 0; 00054 } 00055 Percentage_T lPercentage = 00056 (static_cast<Percentage_T> (_currentNb) 00057 / static_cast<Percentage_T> (_actualNb)); 00058 lPercentage *= MAXIMUM_PROGRESS_STATUS; 00059 return lPercentage; 00060 } 00061 00062 00063 // //////////////// Setters ///////////////// 00065 void setCurrentNb (const Count_T& iCurrentNb) { 00066 _currentNb = iCurrentNb; 00067 } 00068 00070 void setExpectedNb (const Count_T& iExpectedNb) { 00071 _expectedNb = iExpectedNb; 00072 } 00073 00075 void setActualNb (const Count_T& iActualNb) { 00076 _actualNb = iActualNb; 00077 } 00078 00080 void reset(); 00081 00083 Count_T operator+= (Count_T iIncrement) { 00084 _currentNb += iIncrement; 00085 return _currentNb; 00086 } 00087 00089 Count_T operator++() { 00090 ++_currentNb; 00091 return _currentNb; 00092 } 00093 00094 00095 public: 00096 // //////////////// Display Support Methods ///////////////// 00098 const std::string describe() const; 00099 00101 const std::string toString() const; 00102 00103 00104 public: 00112 ProgressStatus (const Count_T& iCurrentNb, const Count_T& iExpectedNb, 00113 const Count_T& iActualNb); 00114 00123 ProgressStatus (const Count_T& iExpectedNb, const Count_T& iActualNb); 00124 00133 ProgressStatus (const Count_T& iActualNb); 00134 00140 ProgressStatus(); 00141 00145 ProgressStatus (const ProgressStatus&); 00146 00147 private: 00148 // //////////////// Attributes ///////////////// 00150 Count_T _currentNb; 00151 00153 Count_T _expectedNb; 00154 00156 Count_T _actualNb; 00157 }; 00158 00159 } 00160 #endif // __STDAIR_BAS_PROGRESSSTATUS_HPP