riCOM_cpp
This repository contains the C++ implementation of the riCOM (Real Time Centre Of Mass) algorithm for 4D Scanning electron microscopy.
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
ProgressMonitor Class Reference

#include <ProgressMonitor.h>

Public Member Functions

ProgressMonitoroperator++ ()
 
ProgressMonitoroperator+= (int step)
 
void reset_flags ()
 
 ProgressMonitor (size_t fr_total, bool b_bar=true, float report_interval=250.0, std::ostream &out=std::cerr)
 

Public Attributes

std::atomic< size_t > fr_count
 
std::atomic< size_t > fr_count_i
 
float fr_freq
 
std::atomic< bool > report_set
 
std::atomic< bool > report_set_public
 
bool first_frame
 
size_t fr_total
 

Static Public Attributes

static const int DEFAULT_WIDTH
 

Detailed Description

Definition at line 34 of file ProgressMonitor.h.

Constructor & Destructor Documentation

◆ ProgressMonitor()

ProgressMonitor::ProgressMonitor ( size_t  fr_total,
bool  b_bar = true,
float  report_interval = 250.0,
std::ostream &  out = std::cerr 
)
explicit

Definition at line 16 of file ProgressMonitor.cpp.

16  : fr_count(0), fr_count_i(0), fr_freq(0),
17  report_set(false), report_set_public(false),
18  first_frame(true), fr(0), fr_avg(0), fr_count_a(0),
19  time_stamp(chc::high_resolution_clock::now()), unit("kHz"),
20  unit_bar("#"), unit_space("-")
21 {
22  this->fr_total = fr_total;
23  this->b_bar = b_bar;
24  this->out = &out;
25  this->report_interval = report_interval;
26 }
std::atomic< bool > report_set
std::atomic< size_t > fr_count_i
std::atomic< size_t > fr_count
std::atomic< bool > report_set_public

Member Function Documentation

◆ operator++()

ProgressMonitor & ProgressMonitor::operator++ ( )

Definition at line 44 of file ProgressMonitor.cpp.

45 {
46  fr_count_i++;
47  fr_count++;
48  auto mil_secs = chc::duration_cast<float_ms>(chc::high_resolution_clock::now() - time_stamp).count();
49  if (mil_secs > report_interval || fr_count >= fr_total)
50  {
51  fr = fr_count_i / mil_secs;
52  fr_avg += fr;
53  fr_count_a++;
54  fr_freq = fr_avg / fr_count_a;
55  Report(fr_count, fr_avg / fr_count_a);
56  report_set = true;
57  report_set_public = true;
58  }
59  return *this;
60 }

◆ operator+=()

ProgressMonitor & ProgressMonitor::operator+= ( int  step)

Definition at line 62 of file ProgressMonitor.cpp.

63 {
64  fr_count_i += step;
65  fr_count += step;
66  auto mil_secs = chc::duration_cast<float_ms>(chc::high_resolution_clock::now() - time_stamp).count();
67  if (mil_secs > report_interval || fr_count >= fr_total)
68  {
69  fr = fr_count_i / mil_secs;
70  fr_avg += fr;
71  fr_count_a++;
72  fr_freq = fr_avg / fr_count_a;
73  Report(fr_count, fr_avg / fr_count_a);
74  report_set = true;
75  report_set_public = true;
76  }
77  return *this;
78 }

◆ reset_flags()

void ProgressMonitor::reset_flags ( )

Definition at line 81 of file ProgressMonitor.cpp.

82 {
83  fr_count_i = 0;
84  report_set = false;
85  time_stamp = chc::high_resolution_clock::now();
86 }

Member Data Documentation

◆ DEFAULT_WIDTH

const int ProgressMonitor::DEFAULT_WIDTH
static

Definition at line 38 of file ProgressMonitor.h.

◆ first_frame

bool ProgressMonitor::first_frame

Definition at line 45 of file ProgressMonitor.h.

◆ fr_count

std::atomic<size_t> ProgressMonitor::fr_count

Definition at line 40 of file ProgressMonitor.h.

◆ fr_count_i

std::atomic<size_t> ProgressMonitor::fr_count_i

Definition at line 41 of file ProgressMonitor.h.

◆ fr_freq

float ProgressMonitor::fr_freq

Definition at line 42 of file ProgressMonitor.h.

◆ fr_total

size_t ProgressMonitor::fr_total

Definition at line 46 of file ProgressMonitor.h.

◆ report_set

std::atomic<bool> ProgressMonitor::report_set

Definition at line 43 of file ProgressMonitor.h.

◆ report_set_public

std::atomic<bool> ProgressMonitor::report_set_public

Definition at line 44 of file ProgressMonitor.h.


The documentation for this class was generated from the following files: