State Machine  0.4.0
This repository contains packages for creating and running general purpose state machines.
state_machine::Progress Class Reference

#include <Progress.hpp>

Public Member Functions

 Progress ()=default
 
 Progress (std::string unit, double goal, double done=0.0)
 
 Progress (const Progress &other)
 
void setUnit (const std::string &unit)
 
std::string getUnit () const
 
void setGoal (const double goal)
 
double getGoal () const
 
void setDone (const double done)
 
double getDone () const
 
void reset ()
 

Protected Attributes

std::mutex mutex_
 
std::string unit_
 
double goal_ = 0.0
 
double done_ = 0.0
 

Detailed Description

Class for storing the progress of a state. A progress has a unit, a goal value and a done value. The done value should always lie within zero and the goal value. Special cases:

  • Unit is empty, goal value is 1.0: Percentage.
  • Goal value is 0.0: Endless state / unknown progress.

Constructor & Destructor Documentation

◆ Progress() [1/3]

state_machine::Progress::Progress ( )
default

Default constructor.

◆ Progress() [2/3]

state_machine::Progress::Progress ( std::string  unit,
double  goal,
double  done = 0.0 
)

Advanced constructor.

Parameters
unitUnit.
goalGoal value.
doneDone value.

◆ Progress() [3/3]

state_machine::Progress::Progress ( const Progress other)

Copy constructor.

Member Function Documentation

◆ getDone()

double state_machine::Progress::getDone ( ) const

Get the done value.

Returns
Done value.

◆ getGoal()

double state_machine::Progress::getGoal ( ) const

Get the goal value.

Returns
Goal value.

◆ getUnit()

std::string state_machine::Progress::getUnit ( ) const

Get the unit.

Returns
Unit.

◆ reset()

void state_machine::Progress::reset ( )

Reset the progress, setting done to 0.

◆ setDone()

void state_machine::Progress::setDone ( const double  done)

Set the done value.

Parameters
doneDone value.

◆ setGoal()

void state_machine::Progress::setGoal ( const double  goal)

Set the goal value.

Parameters
goalGoal value.

◆ setUnit()

void state_machine::Progress::setUnit ( const std::string &  unit)

Set the unit.

Parameters
unitUnit.

Member Data Documentation

◆ done_

double state_machine::Progress::done_ = 0.0
protected

Members set during execution.

◆ goal_

double state_machine::Progress::goal_ = 0.0
protected

◆ mutex_

std::mutex state_machine::Progress::mutex_
mutableprotected

General members.

◆ unit_

std::string state_machine::Progress::unit_
protected

Members set during setup.


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