MyraMath
TextProgressMeter.h
Go to the documentation of this file.
1 // ========================================================================= //
2 // This file is part of MyraMath, copyright (c) 2014-2019 by Ryan A Chilton //
3 // and distributed by MyraCore, LLC. See LICENSE.txt for license terms. //
4 // ========================================================================= //
5 
6 #ifndef MYRAMATH_JOBGRAPH_TEXTPROGRESSMETER_H
7 #define MYRAMATH_JOBGRAPH_TEXTPROGRESSMETER_H
8 
14 #include <myramath/utility/detail/LIBPUBLIC.h>
15 #include <myramath/utility/Timer.h>
16 
18 
19 namespace myra {
20 
21 // Displays a text ProgressMeter on console output.
23  {
24  public:
25 
26  // Default constructor.
28 
29  // Virtual destructor, so subtypes can release resources.
30  virtual ~TextProgressMeter();
31 
32  protected:
33 
34  // Called when a lengthy calculation is started.
35  virtual void begin(const std::string& name, uint64_t total);
36 
37  // Called repeatedly between begin() and end(), to regularly increment progress.
38  virtual void increment(uint64_t delta);
39 
40  // Called when a lengthy calculation is finished.
41  virtual void end();
42 
43  // Returns false, a TextProgressMeter will never kill a JobGraph.
44  virtual bool kill();
45 
46  // Virtual copy constructor.
47  virtual ProgressMeterBase* clone() const;
48 
49  private:
50 
51  // Draws a bar graph on the console, like [----- ] (%d seconds)
52  void draw() const;
53 
54  // Set by begin()
55  bool started;
56 
57  // Current and total work.
58  uint64_t w_current;
59  uint64_t w_total;
60 
61  // Current and total characters.
62  int c_current;
63  int c_total;
64 
65  // Measures time since start, in milliseconds.
66  Timer timer;
67  int t_current;
68 
69  };
70 
72 LIBPUBLIC ProgressMeter make_TextProgressMeter();
73 
74 } // namespace
75 
76 #endif
Simplistic timing class, might dispatch to platform specific timers depending upon environment...
Definition: syntax.dox:1
Interface for measuring progress via callbacks. Wraps an underlying polymorphic ProgressMeterBase.
Definition: ProgressMeter.h:55
Measures elapsed time.
Definition: Timer.h:19
Base/contract class for all other ProgressMeter&#39;s.
Definition: ProgressMeter.h:25
Definition: TextProgressMeter.h:22
Interface type for progress measurement and control within JobGraph&#39;s.