Libmagicxx v10.0.3
A modern C++23 wrapper for libmagic — the library that powers the Unix file command.
Loading...
Searching...
No Matches
Recognition::Utility::AdvanceTracker Class Reference

RAII helper that advances a ProgressTracker on destruction. More...

#include <progress_tracker.hpp>

Public Member Functions

 AdvanceTracker (SharedProgressTrackerT shared_progress_tracker, std::uint64_t step_count=1u) noexcept
 Construct with a shared progress tracker and step count.
 ~AdvanceTracker ()
 Destructor that advances the tracker.

Private Attributes

SharedProgressTrackerT m_shared_progress_tracker
std::uint64_t m_step_count

Detailed Description

RAII helper that advances a ProgressTracker on destruction.

This class ensures that a progress tracker is advanced by a specified number of steps when the scope exits, providing exception-safe progress updates.

Usage Example

void ProcessFile(SharedProgressTrackerT tracker, const std::filesystem::path& file) {
AdvanceTracker guard(tracker); // Will advance by 1 on exit
// Process the file...
// Even if an exception is thrown, progress is updated
} // tracker->Advance(1) called automatically
AdvanceTracker(SharedProgressTrackerT shared_progress_tracker, std::uint64_t step_count=1u) noexcept
Construct with a shared progress tracker and step count.
Definition progress_tracker.hpp:546
std::shared_ptr< ProgressTracker > SharedProgressTrackerT
Shared pointer type for ProgressTracker.
Definition progress_tracker.hpp:405
See also
ProgressTracker::Advance()
Since
10.0.0

Constructor & Destructor Documentation

◆ AdvanceTracker()

Recognition::Utility::AdvanceTracker::AdvanceTracker ( SharedProgressTrackerT shared_progress_tracker,
std::uint64_t step_count = 1u )
inlineexplicitnoexcept

Construct with a shared progress tracker and step count.

Parameters
[in]shared_progress_trackerTracker to advance on destruction. May be null (no-op in that case).
[in]step_countNumber of steps to advance (default: 1).
Since
10.0.0

◆ ~AdvanceTracker()

Recognition::Utility::AdvanceTracker::~AdvanceTracker ( )
inline

Destructor that advances the tracker.

If the tracker is not null, calls Advance() with the step count.

Since
10.0.0

Member Data Documentation

◆ m_shared_progress_tracker

SharedProgressTrackerT Recognition::Utility::AdvanceTracker::m_shared_progress_tracker
private

Tracker to advance on destruction.

◆ m_step_count

std::uint64_t Recognition::Utility::AdvanceTracker::m_step_count
private

Steps to advance.


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