BioDynaMo  v1.05.119-a4ff3934
progress_bar.h
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------
2 //
3 // Copyright (C) 2021 CERN & University of Surrey for the benefit of the
4 // BioDynaMo collaboration. All Rights Reserved.
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 //
9 // See the LICENSE file distributed with this work for details.
10 // See the NOTICE file distributed with this work for additional information
11 // regarding copyright ownership.
12 //
13 // -----------------------------------------------------------------------------
14 
15 #ifndef PROGRESS_BAR_H_
16 #define PROGRESS_BAR_H_
17 
18 #include <cstdint>
19 #include <iostream>
20 #include <string>
21 #include "core/real_t.h"
22 
23 namespace bdm {
24 
40 class ProgressBar {
41  private:
43  std::string time_unit_ = "s";
45  uint64_t total_steps_ = 0;
47  uint64_t executed_steps_ = 0;
49  int64_t start_time_ = 0;
52  size_t n_terminal_chars_ = 0;
57  bool first_iter_ = true;
60  bool write_to_file_ = false;
61 
62  public:
63  ProgressBar();
64  explicit ProgressBar(int total_steps);
65 
67  void Step(uint64_t steps = 1);
68 
70  void PrintProgressBar(std::ostream& out = std::cout);
71 
74  void SetTimeUnit(const std::string& time_unit);
75 };
76 
77 } // namespace bdm
78 
79 #endif // PROGRESS_BAR_H_
bdm::ProgressBar::SetTimeUnit
void SetTimeUnit(const std::string &time_unit)
Definition: progress_bar.cc:123
bdm::ProgressBar::start_time_
int64_t start_time_
Timestamp when to when the progress bar was initialized.
Definition: progress_bar.h:49
bdm
Definition: agent.cc:39
bdm::ProgressBar::time_unit_
std::string time_unit_
Time unit string for elapsed and remaining time.
Definition: progress_bar.h:43
bdm::ProgressBar::total_steps_
uint64_t total_steps_
Total number of steps to be executed.
Definition: progress_bar.h:45
bdm::ProgressBar::time_conversion_factor_
real_t time_conversion_factor_
Variable for conversion of time units (e.g. 1000 for ms to s).
Definition: progress_bar.h:54
bdm::real_t
double real_t
Definition: real_t.h:21
bdm::ProgressBar::PrintProgressBar
void PrintProgressBar(std::ostream &out=std::cout)
Prints the progress bar.
Definition: progress_bar.cc:43
bdm::ProgressBar::first_iter_
bool first_iter_
Definition: progress_bar.h:57
bdm::ProgressBar::Step
void Step(uint64_t steps=1)
Inceases the counter executed_steps_ by steps.
Definition: progress_bar.cc:41
bdm::ProgressBar::write_to_file_
bool write_to_file_
Definition: progress_bar.h:60
bdm::ProgressBar::ProgressBar
ProgressBar()
Definition: progress_bar.cc:36
real_t.h
bdm::ProgressBar::executed_steps_
uint64_t executed_steps_
Number of steps that have already been executed.
Definition: progress_bar.h:47
bdm::ProgressBar
This class implements a progress bar that can be used to track the progress of a simulation.
Definition: progress_bar.h:40
bdm::ProgressBar::n_terminal_chars_
size_t n_terminal_chars_
Definition: progress_bar.h:52