GEDLIB  1.0
progress_bar.hpp
Go to the documentation of this file.
1 /***************************************************************************
2 * *
3 * Copyright (C) 2018 by David B. Blumenthal *
4 * *
5 * This file is part of GEDLIB. *
6 * *
7 * GEDLIB is free software: you can redistribute it and/or modify it *
8 * under the terms of the GNU Lesser General Public License as published *
9 * by the Free Software Foundation, either version 3 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * GEDLIB is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU Lesser General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU Lesser General Public *
18 * License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>. *
19 * *
20 ***************************************************************************/
21 
27 #ifndef SRC_ENV_PROGRESS_BAR_HPP_
28 #define SRC_ENV_PROGRESS_BAR_HPP_
29 
30 #include <iostream>
31 #include <iomanip>
32 #include <chrono>
33 
34 namespace ged {
35 
39 class ProgressBar {
40 
41 public:
42 
43  friend std::ostream & operator<<(std::ostream &, const ProgressBar &);
44 
49  ProgressBar(std::size_t num_tasks);
50 
54  void increment();
55 
59  void reset();
60 
61 private:
62 
63  std::size_t num_solved_tasks_;
64 
65  const std::size_t num_tasks_;
66 
67  const std::chrono::high_resolution_clock::time_point start_time_;
68 };
69 
77 std::ostream &
78 operator<<(std::ostream & os, const ProgressBar & progress_bar);
79 
80 }
81 
82 #include "progress_bar.ipp"
83 
84 #endif /* SRC_ENV_PROGRESS_BAR_HPP_ */
ProgressBar(std::size_t num_tasks)
Constructs a progress bar for given number of tasks.
ged::ProgressBar class definition.
A progress bar class.
Global namespace for GEDLIB.
void increment()
Increments the number of solved tasks.
void reset()
Sets the number of solved tasks to 0.