tjfeedback.h
1 /***************************************************************************
2  tjfeedback.h - description
3  -------------------
4  begin : Fri Jun 6 2003
5  copyright : (C) 2000-2015 by Thies Jochimsen
6  email : thies@jochimsen.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 
19 #ifndef TJFEEDBACK_H
20 #define TJFEEDBACK_H
21 
22 #include <tjutils/tjutils.h>
23 #include <tjutils/tjthread.h>
24 
25 
37 
38  public:
39 
40  virtual ~ProgressDisplayDriver() {}
41 
46  virtual void init(unsigned int nsteps, const char* txt) = 0;
47 
52  virtual void increase(const char* subj) = 0;
53 
58  virtual bool refresh() = 0;
59 
60 };
61 
63 
64 
71 
72  public:
73 
78  ProgressMeter(ProgressDisplayDriver& disp) : display(&disp) {}
79 
84  ProgressMeter& new_task(unsigned int total_steps, const char* txt = 0);
85 
91  bool increase_counter(const char* subj = 0);
92 
97  bool refresh_display();
98 
99 
100  private:
101 
102  // disable copy construction and copying
103  ProgressMeter(const ProgressMeter&) {}
104  ProgressMeter& operator = (const ProgressMeter&) {return *this;}
105 
106  ProgressDisplayDriver* display;
107  Mutex mutex;
108 
109 
110 };
111 
112 
114 
115 #ifndef NO_CMDLINE
116 
117 class ProgressDisplayConsole : public virtual ProgressDisplayDriver {
118 
119  public:
120  ProgressDisplayConsole() : counter(0), nsteps_cache(0), done(false) {}
121 
122  // Implementing virtual functions of ProgressDisplayDriver
123  void init(unsigned int nsteps, const char* txt);
124  void increase(const char*);
125  bool refresh() {return false;}
126 
127  private:
128  unsigned int counter, nsteps_cache, old_perc;
129  bool done;
130 };
131 
132 #endif
133 
136 #endif
virtual void init(unsigned int nsteps, const char *txt)=0
Definition: tjthread.h:46
virtual bool refresh()=0
ProgressMeter(ProgressDisplayDriver &disp)
Definition: tjfeedback.h:78
virtual void increase(const char *subj)=0