Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion progress_tracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void ProgressTrackerImpl::update() {

void ProgressTrackerImpl::updateTimeWidth() {
int number_width = 3; // 0.0
for (auto t = 10; t <= (timeTotal().count() + 500) * 0.001; t *= 10) {
for (auto t = 10; t <= (timeTotal().count() + 500) / 1000; t *= 10) {
++number_width;
}
if (number_width > time_width) {
Expand Down
13 changes: 9 additions & 4 deletions progress_tracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ using std::chrono::milliseconds;
*/
class ProgressTracker {
public:
virtual unsigned int operator++() = 0; //!< next tick in progress
virtual float progress() const = 0; //!< current progress as number between 0 and 1
virtual void display() = 0; //!< update the visual representation of progress
virtual void done() = 0; //!< update the visual representation of progress when finished
virtual unsigned int operator++() = 0; //!< next tick in progress (++tracker)
virtual unsigned int operator++(int) = 0; //!< next tick in progress (tracker++)
virtual float progress() const = 0; //!< current progress as number between 0 and 1
virtual void display() = 0; //!< update the visual representation of progress
virtual void done() = 0; //!< update the visual representation of progress when finished
virtual ~ProgressTracker() = default;
};

Expand All @@ -40,6 +41,8 @@ class ProgressTrackerImpl : public ProgressTracker {

unsigned int inline operator++() { return ++ticks; };

unsigned int inline operator++(int) { return ticks++; };

float inline progress() const { return float(ticks) / float(total_ticks); };

virtual void display() = 0;
Expand Down Expand Up @@ -108,6 +111,8 @@ class ProgressTrackerDecorator : public ProgressTracker {

unsigned int operator++() { return progress_tracker->operator++(); }

unsigned int operator++(int) { return progress_tracker->operator++(0); }

float progress() const { return progress_tracker->progress(); };

void display() { progress_tracker->display(); };
Expand Down
4 changes: 3 additions & 1 deletion progress_tracker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class ProgressTrackerImpl {

auto inline operator++() -> decltype(ticks) { return ++ticks; };

auto inline operator++(int) -> decltype(ticks) { return ticks++; };

float inline progress() const { return float(ticks) / float(total_ticks); };

virtual void display() = 0;
Expand All @@ -47,7 +49,7 @@ class ProgressTrackerImpl {
*/
void updateTimeWidth() {
int number_width = 3; // 0.0
for (auto t = 10; t <= (timeTotal().count() + 500) * 0.001; t *= 10) {
for (auto t = 10; t <= (timeTotal().count() + 500) / 1000; t *= 10) {
++number_width;
}
if (number_width > time_width) {
Expand Down