tdaq-develop-2025-02-12
ProgressBar.h
1 #ifndef _ots_Utilities_ProgressBar_h_
2 #define _ots_Utilities_ProgressBar_h_
3 
4 #include "otsdaq/Macros/CoutMacros.h"
5 #include "otsdaq/MessageFacility/MessageFacility.h"
6 
7 #include <mutex>
8 #include <string>
9 
10 namespace ots
11 {
80 {
81  public:
82  ProgressBar();
83 
90 #define resetProgressBar(x) reset(__FILE__, std::to_string(__LINE__), x)
92  void reset(std::string file, std::string lineNumber, int id = 0);
98  void step();
99  void complete();
100 
102  bool isComplete();
103  int read();
104  std::string readPercentageString();
106 
107  private:
108  const std::string cProgressBarFilePath_;
109  const std::string cProgressBarFileExtension_;
110  std::string totalStepsFileName_;
111  int stepCount_;
112  int stepsToComplete_;
113  bool started_;
114  std::mutex theMutex_;
115 };
116 
117 } // namespace ots
118 
119 #endif
std::string readPercentageString()
return percentage complete as std::string
Definition: ProgressBar.cc:136
bool isComplete()
get functions
Definition: ProgressBar.cc:89
void step()
thread safe
Definition: ProgressBar.cc:75
void reset(std::string file, std::string lineNumber, int id=0)
will call this reset:
Definition: ProgressBar.cc:41
int read()
if stepsToComplete==0, then define any progress as 50%, thread safe
Definition: ProgressBar.cc:121
void complete()
declare complete, thread safe
Definition: ProgressBar.cc:96