casacore
Loading...
Searching...
No Matches
ProgressMeter.h
Go to the documentation of this file.
1//# ProgressMeter.h: Visual indication of a tasks progress.
2//# Copyright (C) 1997,2000
3//# Associated Universities, Inc. Washington DC, USA.
4//#
5//# This library is free software; you can redistribute it and/or modify it
6//# under the terms of the GNU Library General Public License as published by
7//# the Free Software Foundation; either version 2 of the License, or (at your
8//# option) any later version.
9//#
10//# This library is distributed in the hope that it will be useful, but WITHOUT
11//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13//# License for more details.
14//#
15//# You should have received a copy of the GNU Library General Public License
16//# along with this library; if not, write to the Free Software Foundation,
17//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18//#
19//# Correspondence concerning AIPS++ should be addressed as follows:
20//# Internet email: casa-feedback@nrao.edu.
21//# Postal address: AIPS++ Project Office
22//# National Radio Astronomy Observatory
23//# 520 Edgemont Road
24//# Charlottesville, VA 22903-2475 USA
25
26#ifndef CASA_PROGRESSMETER_H
27#define CASA_PROGRESSMETER_H
28
29//# Includes
30#include <casacore/casa/aips.h>
31#include <time.h>
32
33namespace casacore { //# NAMESPACE CASACORE - BEGIN
34
35//# Forward Declarations
36class String;
37
38// <summary>
39// Visual indication of a tasks progress.
40// </summary>
41
42// <use visibility=export>
43
44// <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
45// </reviewed>
46
47// <synopsis>
48// This class is used to provide a visual indication to the user of the progress
49// of his task. If the process is not connected to the DO system, calls to the
50// progress meter are NO-OP's, so you can safely use this class in general
51// library code and it won't cause problems for processes which are not
52// attached to the distributed object system. It also won't cause any extra
53// stuff to be linked in to your executable in this case.
54//
55// The progress meter will usually be removed from the screen once the maximum
56// value is set, so you should not reuse the ProgressMeter after that has
57// happened. It is harmless, but it will not result in any visual feedback for
58// the user.
59//
60// While the "min" is usually less than "max", if in fact it is greater than
61// "max" the progress meter will count down correctly.
62// </synopsis>
63//
64// <example>
65// <srcblock>
66// void calculate(uInt n) {
67// Int skip = n / 200;
68// ProgressMeter meter(0, n, "Title", "Subtitle", "", "", True, skip);
69// for (uInt i=0; i<n; i++) {
70// ... calculate ...
71// meter.update(i);
72// }
73// }
74// </srcblock>
75// </example>
76//
77// <motivation>
78// Give the user visual indication of a long-running tasks progress.
79// </motivation>
80//
81// <todo asof="1997/03/03">
82// <li> When the upper bound isn't known, it might be useful to have a busy
83// bar that just moves back and forth to show that activity is happening.
84// <li> We should probably have some way to suppress progress bars for tasks
85// that are only going to take a few seconds.
86// </todo>
87
89{
90public:
91 // Makes a null progress meter, i.e. no updates to the screen are
92 // generated.
94
95 // Create a progress meter with the given min and max values and labels.
96 // if <src>estimateTime</src> is <src>True</src>, an estimate of the
97 // time remaining will be made for the user. This estimate assumes that
98 // the remaining portion will compute at the same rate as the portion
99 // completed so far, so the time should not be estimated for processes
100 // which are non-linear.
101 //
102 // Any labels which are set to the empty string will have sensible defaults
103 // supplied. In particular, <src>minlabel</src> and <src>maxlabel</src>
104 // will be set to the display the minimum and maximum values.
105 //
106 // Normally the progress bar will be updated with every call to
107 // <src>update()</src>. If however you will be sending many events
108 // then you might want to update the GUI every <src>updateEvery</src>'th
109 // event for efficiency. Generally there's no point updating more than
110 // a couple of hundred times since the eye can't distinguish differences
111 // in the progress bar position at that level. If updateEvery is <=0, it
112 // is set to 1 for you.
114 const String &title, const String &subtitle,
115 const String &minlabel, const String &maxlabel,
116 Bool estimateTime = True, Int updateEvery=1);
117
119 // The destruction of the meter will cause an update to be sent with the
120 // maximum value. This will usually cause the GUI window to be removed
121 // from the screen. Thus the progress meter should generally live as long
122 // as the calculation it is tracking.
124
127 void busy();
128 void done();
129
130 // Display the min and max values of the progress meter.
131 // <group>
132 Double min() const;
133 Double max() const;
134 // </group>
135
136 friend class ObjectController;
137 static const char* PROGRESSFILE;
138private:
142 // Time the progress meter began
143 time_t startTime;
145
146 // These are set by ObjectController for executables that have the tasking
147 // system in them, otherwise they are null and this class just does no-ops.
149 const String &, const String &,
150 const String &, const String &,
151 Bool);
152 static void (*update_function_p)(Int, Double);
153 static void (*show_function_p)(Int, Double);
154 static void (*busy_function_p)(Int);
155 static void (*done_function_p)(Int);
156
157 // Undefined and inaccessible
160};
161
162
163} //# NAMESPACE CASACORE - END
164
165#endif
166
167
ProgressMeter()
Makes a null progress meter, i.e.
friend class ObjectController
ProgressMeter(Double min, Double max, const String &title)
static Int(* creation_function_p)(Double, Double, const String &, const String &, const String &, const String &, Bool)
These are set by ObjectController for executables that have the tasking system in them,...
ProgressMeter(const ProgressMeter &)
Undefined and inaccessible.
ProgressMeter(Double min, Double max, const String &title, const String &subtitle, const String &minlabel, const String &maxlabel, Bool estimateTime=True, Int updateEvery=1)
Create a progress meter with the given min and max values and labels.
static void(* done_function_p)(Int)
Double min() const
Display the min and max values of the progress meter.
void update(Double value, Bool force=False)
static void(* show_function_p)(Int, Double)
ProgressMeter & operator=(const ProgressMeter &)
~ProgressMeter()
The destruction of the meter will cause an update to be sent with the maximum value.
static void(* update_function_p)(Int, Double)
void _update(Double value, Bool force=False)
time_t startTime
Time the progress meter began.
static const char * PROGRESSFILE
static void(* busy_function_p)(Int)
String: the storage and methods of handling collections of characters.
Definition String.h:223
this file contains all the compiler specific defines
Definition mainpage.dox:28
const Bool False
Definition aipstype.h:42
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
const Bool True
Definition aipstype.h:41
double Double
Definition aipstype.h:53