Illustrated C/C++ source sheets, symbol index, API relationship graph, compiler console and debug trace

LIVE AI / FLEXIBLE SENSING / FLIGHT CONTEXT

Sensoraia API

Live AI and sensing, connected to the flight.
See, listen, inspect and return supported results while airborne.

Loading...
Searching...
No Matches
pangea_survey::MapProgress Class Reference

Thread-safe progress reporter for staged map work. More...

#include <map_progress.h>

Public Member Functions

 MapProgress (std::string label="Map progress")
 Start reporting progress under a human-readable label.
 ~MapProgress ()
 Signal the reporter to emit its final status, then join it.
void stage (const std::string &name, double first, double last, double estimateSeconds=0)
 Begin a monotonic percentage range for one named stage.
void update (double fraction, const std::string &detail={})
 Advance the current stage without allowing its fraction to regress.
void detail (const std::string &text)
 Replace the operator-facing detail without changing progress.
void finish ()
 Mark the entire operation complete and permit 100 percent output.

Static Public Member Functions

static void selfTest ()
 Exercise stage progress, monotonic updates, and completion behavior.

Private Types

using Clock = std::chrono::steady_clock

Private Member Functions

void stageTiming (Clock::time_point now, const char *status)
 Emit at most one elapsed-time record for the active timed stage.
double percentage (Clock::time_point now) const
 Estimate overall progress from reported work and stage time.
std::string line (Clock::time_point now) const
 Format a consistent progress snapshot under the state mutex.
void report ()
 Run the progress reporter until teardown.

Static Private Member Functions

static std::string duration (Clock::duration value)
 Format an elapsed duration at whole-second precision.

Private Attributes

std::string label_
std::string stage_ = "Preparing"
std::string detail_
Clock::time_point started_ = Clock::now()
Clock::time_point stageStarted_ = started_
double first_ = 0
double last_ = 0
double fraction_ = 0
double estimateSeconds_ = 0
bool complete_ = false
bool closing_ = false
bool changed_ = true
bool timedStage_ = false
std::mutex mutex_
std::condition_variable wake_
std::thread reporter_

Detailed Description

Thread-safe progress reporter for staged map work.

A reporter thread emits a heartbeat even when a computation has no fine-grained updates. Destruction joins that thread and reports interruption unless finish was called.

Definition at line 49 of file map_progress.h.

Member Typedef Documentation

◆ Clock

using pangea_survey::MapProgress::Clock = std::chrono::steady_clock
private

Definition at line 50 of file map_progress.h.

Constructor & Destructor Documentation

◆ MapProgress()

pangea_survey::MapProgress::MapProgress ( std::string label = "Map progress")
inlineexplicit

Start reporting progress under a human-readable label.

Parameters
[in]labelPrefix shown on each progress line.

Definition at line 131 of file map_progress.h.

◆ ~MapProgress()

pangea_survey::MapProgress::~MapProgress ( )
inline

Signal the reporter to emit its final status, then join it.

Drop the state mutex before joining so the reporter can exit.

Definition at line 135 of file map_progress.h.

Member Function Documentation

◆ detail()

void pangea_survey::MapProgress::detail ( const std::string & text)
inline

Replace the operator-facing detail without changing progress.

Definition at line 181 of file map_progress.h.

◆ duration()

std::string pangea_survey::MapProgress::duration ( Clock::duration value)
inlinestaticprivate

Format an elapsed duration at whole-second precision.

Parameters
valueNonnegative interval.
Returns
Hours, minutes and seconds without wrapping hours at a day.

Definition at line 89 of file map_progress.h.

◆ finish()

void pangea_survey::MapProgress::finish ( )
inline

Mark the entire operation complete and permit 100 percent output.

Definition at line 186 of file map_progress.h.

◆ line()

std::string pangea_survey::MapProgress::line ( Clock::time_point now) const
inlineprivate

Format a consistent progress snapshot under the state mutex.

Parameters
nowMonotonic time shared by all elapsed fields on the line.
Returns
Complete line including its newline.

Distinguish an interrupted shutdown from completed publication.

Definition at line 100 of file map_progress.h.

◆ percentage()

double pangea_survey::MapProgress::percentage ( Clock::time_point now) const
inlineprivate

Estimate overall progress from reported work and stage time.

Parameters
nowCurrent monotonic time.
Returns
Estimated percentage; 100 is reserved for explicit completion.

The time estimate approaches the stage endpoint without claiming all its work is done. Prefer measured progress when greater.

Definition at line 81 of file map_progress.h.

◆ report()

void pangea_survey::MapProgress::report ( )
inlineprivate

Run the progress reporter until teardown.

Wake on changes or every five seconds so a long stage remains observable. Emit a last snapshot even when stopped early.

Definition at line 113 of file map_progress.h.

◆ selfTest()

void pangea_survey::MapProgress::selfTest ( )
inlinestatic

Exercise stage progress, monotonic updates, and completion behavior.

Exceptions
std::runtime_errorIf a progress invariant fails.

Sample estimated progress at fixed synthetic offsets instead of waiting for a long stage in real time.

Definition at line 198 of file map_progress.h.

◆ stage()

void pangea_survey::MapProgress::stage ( const std::string & name,
double first,
double last,
double estimateSeconds = 0 )
inline

Begin a monotonic percentage range for one named stage.

Parameters
[in]nameStage label.
[in]firstFirst percentage assigned to the stage.
[in]lastUpper percentage bound, at most 99.9 until finish.
[in]estimateSecondsOptional duration used only for a bounded estimate.
Exceptions
std::runtime_errorIf bounds are invalid or progress would move backward.

Definition at line 152 of file map_progress.h.

◆ stageTiming()

void pangea_survey::MapProgress::stageTiming ( Clock::time_point now,
const char * status )
inlineprivate

Emit at most one elapsed-time record for the active timed stage.

Parameters
nowCurrent monotonic time.
statusTerminal stage label.

Disarm reporting after emission so teardown cannot repeat it.

Definition at line 64 of file map_progress.h.

◆ update()

void pangea_survey::MapProgress::update ( double fraction,
const std::string & detail = {} )
inline

Advance the current stage without allowing its fraction to regress.

Parameters
[in]fractionStage completion estimate in the closed interval [0, 1].
[in]detailOptional current item or count shown to the operator.
Exceptions
std::runtime_errorIf fraction is nonfinite or outside [0, 1].

Definition at line 173 of file map_progress.h.

Field Documentation

◆ changed_

bool pangea_survey::MapProgress::changed_ = true
private

Definition at line 54 of file map_progress.h.

◆ closing_

bool pangea_survey::MapProgress::closing_ = false
private

Definition at line 54 of file map_progress.h.

◆ complete_

bool pangea_survey::MapProgress::complete_ = false
private

Definition at line 54 of file map_progress.h.

◆ detail_

std::string pangea_survey::MapProgress::detail_
private

Definition at line 51 of file map_progress.h.

◆ estimateSeconds_

double pangea_survey::MapProgress::estimateSeconds_ = 0
private

Definition at line 53 of file map_progress.h.

◆ first_

double pangea_survey::MapProgress::first_ = 0
private

Definition at line 53 of file map_progress.h.

◆ fraction_

double pangea_survey::MapProgress::fraction_ = 0
private

Definition at line 53 of file map_progress.h.

◆ label_

std::string pangea_survey::MapProgress::label_
private

Definition at line 51 of file map_progress.h.

◆ last_

double pangea_survey::MapProgress::last_ = 0
private

Definition at line 53 of file map_progress.h.

◆ mutex_

std::mutex pangea_survey::MapProgress::mutex_
private

Definition at line 56 of file map_progress.h.

◆ reporter_

std::thread pangea_survey::MapProgress::reporter_
private

Definition at line 58 of file map_progress.h.

◆ stage_

std::string pangea_survey::MapProgress::stage_ = "Preparing"
private

Definition at line 51 of file map_progress.h.

◆ stageStarted_

Clock::time_point pangea_survey::MapProgress::stageStarted_ = started_
private

Definition at line 52 of file map_progress.h.

◆ started_

Clock::time_point pangea_survey::MapProgress::started_ = Clock::now()
private

Definition at line 52 of file map_progress.h.

◆ timedStage_

bool pangea_survey::MapProgress::timedStage_ = false
private

Definition at line 55 of file map_progress.h.

◆ wake_

std::condition_variable pangea_survey::MapProgress::wake_
private

Definition at line 57 of file map_progress.h.


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