ModErn Text Analysis
META Enumerates Textual Applications
progress.h
Go to the documentation of this file.
1 
10 #ifndef META_UTIL_PROGRESS_H_
11 #define META_UTIL_PROGRESS_H_
12 
13 #include <chrono>
14 #include <string>
15 
16 namespace meta
17 {
18 namespace printing
19 {
20 
27 class progress
28 {
29  public:
42  progress(const std::string& prefix, uint64_t length,
43  int interval = 500, uint64_t min_iters = 10);
44 
50  void print_endline(bool endline);
51 
56  ~progress();
57 
62  void operator()(uint64_t iter);
63 
67  void end();
68 
72  void clear() const;
73 
74  private:
76  std::string prefix_;
78  std::chrono::steady_clock::time_point start_;
80  std::chrono::steady_clock::time_point last_update_;
82  uint64_t last_iter_;
84  uint64_t length_;
86  int interval_;
91  uint64_t min_iters_;
93  uint64_t str_len_;
95  bool finished_;
97  bool endline_;
98 };
99 }
100 }
101 #endif
void operator()(uint64_t iter)
Updates the progress indicator.
Definition: progress.cpp:59
progress(const std::string &prefix, uint64_t length, int interval=500, uint64_t min_iters=10)
Constructs a progress reporter with the given prefix and iteration length.
Definition: progress.cpp:38
bool finished_
Whether or not we have finished the job.
Definition: progress.h:95
uint64_t length_
The total number of iterations.
Definition: progress.h:84
std::chrono::steady_clock::time_point last_update_
The time of the last update.
Definition: progress.h:80
uint64_t length(const std::string &str)
Definition: utf.cpp:136
std::string prefix_
The prefix for the progress report message.
Definition: progress.h:76
uint64_t last_iter_
The last iteration number.
Definition: progress.h:82
int interval_
The length of time, in milliseconds, to wait between updates.
Definition: progress.h:86
~progress()
Destroys this progress reporter.
Definition: progress.cpp:120
void clear() const
Clears the last line the progress bar wrote.
Definition: progress.cpp:115
The ModErn Text Analysis toolkit is a suite of natural language processing, classification, information retreival, data mining, and other applications of text processing.
Definition: analyzer.h:24
std::chrono::steady_clock::time_point start_
The start time of the job.
Definition: progress.h:78
void end()
Marks the progress indicator as having finished.
Definition: progress.cpp:106
bool endline_
Whether or not we should print an endline when done.
Definition: progress.h:97
void print_endline(bool endline)
Sets whether or not an endline should be printed at completion.
Definition: progress.cpp:54
uint64_t str_len_
The length of the last progress output message.
Definition: progress.h:93
uint64_t min_iters_
The minimum number of iterations that must pass before progress reporting will be considered...
Definition: progress.h:91
Simple class for reporting progress of lengthy operations.
Definition: progress.h:27