LCOV - code coverage report
Current view: top level - include/crpropa - ProgressBar.h (source / functions) Coverage Total Hit
Test: coverage.info.cleaned Lines: 100.0 % 1 1
Test Date: 2026-06-18 09:49:19 Functions: - 0 0

            Line data    Source code
       1              : #ifndef CRPROPA_PROGRESSBAR_H
       2              : #define CRPROPA_PROGRESSBAR_H
       3              : 
       4              : #include <string>
       5              : #include <ctime>
       6              : 
       7              : namespace crpropa {
       8              : 
       9              : /**
      10              :  * \addtogroup Core
      11              :  * @{
      12              :  */
      13              : 
      14              : /** 
      15              :  @class ProgressBar
      16              :  @brief Track the evolution of the simulations with a progress bar
      17              :  */
      18            5 : class ProgressBar {
      19              : private:
      20              :         unsigned long _steps;
      21              :         unsigned long _currentCount;
      22              :         unsigned long _maxbarLength;
      23              :         unsigned long _nextStep;
      24              :         unsigned long _updateSteps;
      25              :         time_t _startTime;
      26              :         std::string stringTmpl;
      27              :         std::string arrow;
      28              : 
      29              : public:
      30              :         /** Constructor to initialize a progress bar
      31              :          @param steps           number of steps
      32              :          @param updateSteps     progress bar will be updated at the steps given by this parameter
      33              :          */
      34              :         ProgressBar(unsigned long steps = 0, unsigned long updateSteps = 100);
      35              :         void start(const std::string &title);
      36              : 
      37              :         /** Update the progressbar
      38              :          This should be called steps times in a loop.
      39              :         */
      40              :         void update(); 
      41              : 
      42              :         /** Sets the position of the progress bar to a given value
      43              :          @param position        current position of the progress bar
      44              :          */
      45              :         void setPosition(unsigned long position);
      46              : 
      47              :         /** Mark the progress bar with an error
      48              :          */
      49              :         void setError();
      50              : };
      51              : /** @}*/
      52              : 
      53              : } // namespace crpropa
      54              : 
      55              : #endif // CRPROPA_PROGRESSBAR_H
        

Generated by: LCOV version 2.0-1