Progress.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <ctime>
4 #include <string>
5 
6 namespace ana
7 {
8  /// A simple ascii-art progress bar
9  class Progress
10  {
11  public:
12  /// Create and draw the progress bar
13  Progress(const std::string& title);
14  ~Progress();
15  /// Update the progress fraction between zero and one
16  void SetProgress(double frac);
17  /// Call this when action is completed
18  void Done();
19  protected:
20  std::string FormatTime(double sec) const;
21 
22  bool fDone; ///< Has \ref Done been called?
23  int fIFrac; ///< What character are we on? Prevents unnecessary redraws
24 
25  time_t fStart;
26  time_t fPrevCall;
27 
28  // Only one bar may be live at a time. Prevents overdrawing
29  bool fLive; ///< Is this bar live (drawable?)
30  static bool fAnyLive; ///< Are any bars live?
31  };
32 }
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
bool fDone
Has Done been called?
Definition: Progress.h:22
time_t fStart
Definition: Progress.h:25
static bool fAnyLive
Are any bars live?
Definition: Progress.h:30
Progress(const std::string &title)
Create and draw the progress bar.
Definition: Progress.cxx:18
double frac(double x)
Fractional part.
int fIFrac
What character are we on? Prevents unnecessary redraws.
Definition: Progress.h:23
time_t fPrevCall
Definition: Progress.h:26
void SetProgress(double frac)
Update the progress fraction between zero and one.
Definition: Progress.cxx:41
A simple ascii-art progress bar.
Definition: Progress.h:9
bool fLive
Is this bar live (drawable?)
Definition: Progress.h:29
std::string FormatTime(double sec) const
Definition: Progress.cxx:102
void Done()
Call this when action is completed.
Definition: Progress.cxx:90
enum BeamMode string