VRS
A file format for sensor data.
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
vrs::ProgressLogger Class Reference

ProgressLogger class to be notified of some process' progress. More...

#include <ProgressLogger.h>

Inheritance diagram for vrs::ProgressLogger:
vrs::SilentLogger

Public Member Functions

 ProgressLogger (bool detailedProgress=false, double updateDelay=kDefaultUpdateDelay)
 
virtual void setStepCount (int stepCount)
 
virtual void setDetailedProgress (bool detailedProgress)
 
bool getDetailedProgress () const
 
virtual bool logNewStep (const string &stepName, size_t progress=0, size_t maxProgress=100)
 
bool logProgress (const string &stepName, size_t progress=0, size_t maxProgress=100)
 
bool logProgress (const string &stepName, int64_t progress, int64_t maxProgress)
 
virtual bool logStatus (const string &stepName, int status=0)
 
virtual bool logDuration (const string &operationName, double duration, int precision=1)
 

Static Public Attributes

static constexpr double kDefaultUpdateDelay = 2
 

Protected Member Functions

virtual bool logProgress (const string &stepName, size_t progress, size_t maxProgress, bool newStep)
 
virtual void logMessage (const string &message)
 
virtual void logErrorMessage (const string &message)
 
virtual void updateStep (size_t progress=0, size_t maxProgress=100)
 
virtual void updateNextProgressTime ()
 Callback to schedule the time of the next text update.
 
virtual bool shouldKeepGoing ()
 

Protected Attributes

bool detailedProgress_
 
double updateDelay_
 
int stepNumber_
 
int stepCount_
 
double nextProgressTime_
 

Detailed Description

ProgressLogger class to be notified of some process' progress.

Helper class to implement status logging when opening a VRS file By default, logs to use XR_LOGI and XR_LOGE, but can be easily overwritten to log anywhere. By default, this class never requests to stop the operation, but that can be overridden.

Constructor & Destructor Documentation

◆ ProgressLogger()

vrs::ProgressLogger::ProgressLogger ( bool  detailedProgress = false,
double  updateDelay = kDefaultUpdateDelay 
)
explicit

By default, only logs every 2 seconds, and after 2 seconds, so opening from a file will be silent, unless a slow re-indexing operation is required.

Parameters
detailedProgresspass true to log every new step, regardless of timing.
updateDelaytime in seconds between updates.

Member Function Documentation

◆ getDetailedProgress()

bool vrs::ProgressLogger::getDetailedProgress ( ) const
inline

Get if progress details logging is enabled.

Returns
True if progress details logging is enabled.

◆ logDuration()

bool vrs::ProgressLogger::logDuration ( const string &  operationName,
double  duration,
int  precision = 1 
)
virtual

Log that an operation was performed in a specific duration.

Parameters
operationNametext describing the operation.
durationnumber of seconds the operation lasted.
precisionprecision to use when printing the duration.
Returns
True if the operation should continue, false if it should be cancelled.

Reimplemented in vrs::SilentLogger.

◆ logErrorMessage()

void vrs::ProgressLogger::logErrorMessage ( const string &  message)
protectedvirtual

Log an error message. This is called when some text needs to actually be logged after all the filtering logic has been applied.

Parameters
messagethe error text message to log.

◆ logMessage()

void vrs::ProgressLogger::logMessage ( const string &  message)
protectedvirtual

Log an actual message. This is called when some text needs to actually be logged after all the filtering logic has been applied.

Parameters
messagethe text message to log.

◆ logNewStep()

bool vrs::ProgressLogger::logNewStep ( const string &  stepName,
size_t  progress = 0,
size_t  maxProgress = 100 
)
virtual

Start logging a new step.

Parameters
stepNamethe name of the step.
progressthe current progress in the step.
maxProgressthe max value of the progress counter in the step.
Returns
True if the operation should continue, false if it should be cancelled.

◆ logProgress() [1/3]

bool vrs::ProgressLogger::logProgress ( const string &  stepName,
int64_t  progress,
int64_t  maxProgress 
)
inline

Convenience method for when a status is signed. Note that values are expected to be positive anyways!

◆ logProgress() [2/3]

bool vrs::ProgressLogger::logProgress ( const string &  stepName,
size_t  progress,
size_t  maxProgress,
bool  newStep 
)
protectedvirtual
Parameters
stepNamethe name of the step.
progressthe current progress in the step.
maxProgressthe max value of the progress counter in the step.
newSteptells if the step is a new step (for internal use).
Returns
True if the operation should continue, false if it should be cancelled.

Reimplemented in vrs::SilentLogger.

◆ logProgress() [3/3]

bool vrs::ProgressLogger::logProgress ( const string &  stepName,
size_t  progress = 0,
size_t  maxProgress = 100 
)
inline

Log progress of a step that has an internal progress counter. logNewStep() should always be called first.

Parameters
stepNamethe name of the step.
progressthe current progress in the step.
maxProgressthe max value of the progress counter in the step.
Returns
True if the operation should continue, false if it should be cancelled.

◆ logStatus()

bool vrs::ProgressLogger::logStatus ( const string &  stepName,
int  status = 0 
)
virtual

Log that a step is completed, with a specific status.

Parameters
stepNamethe name of the step.
status0 on success, otherwise, the step is considered failed.
Returns
True if the operation should continue, false if it should be cancelled.

Reimplemented in vrs::SilentLogger.

◆ setDetailedProgress()

void vrs::ProgressLogger::setDetailedProgress ( bool  detailedProgress)
virtual

Force logging at every step.

Parameters
detailedProgresstrue if logging should be done of every new step.

◆ setStepCount()

void vrs::ProgressLogger::setStepCount ( int  stepCount)
virtual

Set the number of steps anticipated, if expecting more than one step. The step counter is incremented each time a new step is logged.

Parameters
stepCounttotal number of steps anticipated.

◆ shouldKeepGoing()

bool vrs::ProgressLogger::shouldKeepGoing ( )
protectedvirtual

Callback to tell if the operation should stop or keep going. Override this method to check if the operation should be cancelled, and probably cache the result.

Returns
True if the operation should continue, false if it should be cancelled.

◆ updateStep()

void vrs::ProgressLogger::updateStep ( size_t  progress = 0,
size_t  maxProgress = 100 
)
protectedvirtual

Callback to update the current step's progress, for instance, when displaying a progress bar.

Parameters
progressthe current progress in the step.
maxProgressthe max value of the progress counter in the step.

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