BELFEM 0.9.0
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
cl_Progressbar.hpp
Go to the documentation of this file.
1/*
2 * BELFEM -- The Berkeley Lab Finite Element Framework
3 * Copyright (c) 2026, The Regents of the University of California,
4 * through Lawrence Berkeley National Laboratory (subject to receipt of any required
5 * approvals from the U.S. Dept. of Energy). All rights reserved.
6 *
7 * Developers: Christian Messe, Gregory Giard
8 *
9 * See the top-level LICENSE file for the complete license and disclaimer.
10 */
11
12
13#ifndef BELFEM_CL_PROGRESSBAR_HPP
14#define BELFEM_CL_PROGRESSBAR_HPP
15
16#include "typedefs.hpp"
17
18namespace belfem
19{
27 {
28 // width of the bar in characters
29 const index_t mWidth = 65 ;
30
31 // number of steps the caller will report
32 const index_t mNumSteps;
33
34 FILE * mFile;
35
36 // actual progress as part of mNumSteps
37 uint mProgress = 0;
38
39 // bar width already drawn, in characters. the bar only redraws when
40 // this grows, so the number of frames is bounded by mWidth
41 uint mStep = 0;
42
43 // true once the cursor has been handed back to the terminal
44 bool mCursorRestored = false;
45
46//------------------------------------------------------------------------------
47 public:
48//------------------------------------------------------------------------------
49
50
51 Progressbar( const uint aNumSteps=100, FILE * aFile = stdout );
52
53//------------------------------------------------------------------------------
54
56
57//------------------------------------------------------------------------------
58
59 void
60 reset();
61
62//------------------------------------------------------------------------------
63
68 void
69 step( const uint & aProgress );
70
71//------------------------------------------------------------------------------
72
76 void
77 step();
78
79//------------------------------------------------------------------------------
80
81 void
82 finish();
83
84//------------------------------------------------------------------------------
85 private:
86//------------------------------------------------------------------------------
87
91 void
92 draw( const uint aStep, const uint aProgress );
93
94//------------------------------------------------------------------------------
95
100 void
101 flush();
102
103//------------------------------------------------------------------------------
104
108 void
109 show_cursor();
110
111//------------------------------------------------------------------------------
112 };
113}
114#endif //BELFEM_CL_PROGRESSBAR_HPP
void reset()
Definition cl_Progressbar.cpp:39
Progressbar(const uint aNumSteps=100, FILE *aFile=stdout)
Definition cl_Progressbar.cpp:21
void finish()
Definition cl_Progressbar.cpp:90
void step(const uint &aProgress)
prescribe a step
Definition cl_Progressbar.cpp:58
USER GUIDES:
Definition cl_Capacitor.cpp:16
unsigned int uint
Definition typedefs.hpp:30
uint32_t index_t
Definition typedefs.hpp:52