AwesomeStudioPedal
A programmable, multi-profile foot controller for DAWs, score readers, and studio automation
Loading...
Searching...
No Matches
DelayedAction Class Reference

Wraps an action and defers its execution by a configurable delay. More...

#include <delayed_action.h>

Inheritance diagram for DelayedAction:
Action

Public Member Functions

 DelayedAction (std::unique_ptr< Action > action, uint32_t delayMs)
 Constructs a DelayedAction that wraps an action with a time delay.
 
void execute () override
 Executes the delayed action.
 
uint32_t getDelay () const override
 
bool isSendAction () const override
 
bool isInProgress () const override
 Returns true if the action is currently in progress (e.g.
 
Action::Type getType () const override
 
bool update (uint32_t currentTime) const
 Polls whether the delay has elapsed.
 
bool isStarted () const
 
const ActiongetInnerAction () const
 
void getJsonProperties (JsonObject &json) const override
 Serializes the delayed action to JSON.
 
- Public Member Functions inherited from Action
void setName (const std::string &n)
 
const std::string & getName () const
 
bool hasName () const
 
virtual ~Action ()=default
 

Static Public Member Functions

static const char * getTypeName (Action::Type type)
 Converts an Action::Type enum to its string representation.
 

Additional Inherited Members

- Public Types inherited from Action
enum class  Type : uint8_t {
  Unknown , SendString , SendChar , SendKey ,
  SendMediaKey , SerialOutput , Delayed
}
 

Detailed Description

Wraps an action and defers its execution by a configurable delay.

The first call to execute() starts the timer. Subsequent calls before the delay has elapsed are ignored. Once the delay elapses the inner action is executed and the timer resets, allowing the action to be triggered again.

Definition at line 15 of file delayed_action.h.

Constructor & Destructor Documentation

◆ DelayedAction()

DelayedAction::DelayedAction ( std::unique_ptr< Action action,
uint32_t  delayMs 
)

Constructs a DelayedAction that wraps an action with a time delay.

Parameters
actionThe action to be executed after the delay
delayMsThe delay duration in milliseconds

Definition at line 15 of file delayed_action.cpp.

Member Function Documentation

◆ execute()

void DelayedAction::execute ( )
overridevirtual

Executes the delayed action.

If not already started, begins the delay timer. If the delay has elapsed, executes the inner action and resets the timer. Calls before the delay elapses are ignored (debounce behavior).

Implements Action.

Definition at line 27 of file delayed_action.cpp.

◆ getDelay()

uint32_t DelayedAction::getDelay ( ) const
inlineoverridevirtual

Reimplemented from Action.

Definition at line 22 of file delayed_action.h.

◆ getInnerAction()

const Action * DelayedAction::getInnerAction ( ) const
inline

Definition at line 36 of file delayed_action.h.

◆ getJsonProperties()

void DelayedAction::getJsonProperties ( JsonObject &  json) const
overridevirtual

Serializes the delayed action to JSON.

Parameters
jsonThe JSON object to populate with action properties

Reimplemented from Action.

Definition at line 61 of file delayed_action.cpp.

◆ getType()

Action::Type DelayedAction::getType ( ) const
inlineoverridevirtual

Reimplemented from Action.

Definition at line 25 of file delayed_action.h.

◆ getTypeName()

const char * DelayedAction::getTypeName ( Action::Type  type)
static

Converts an Action::Type enum to its string representation.

Parameters
typeThe action type enum value
Returns
String representation of the action type

Definition at line 75 of file delayed_action.cpp.

◆ isInProgress()

bool DelayedAction::isInProgress ( ) const
inlineoverridevirtual

Returns true if the action is currently in progress (e.g.

a running delay)

Reimplemented from Action.

Definition at line 24 of file delayed_action.h.

◆ isSendAction()

bool DelayedAction::isSendAction ( ) const
inlineoverridevirtual

Reimplemented from Action.

Definition at line 23 of file delayed_action.h.

◆ isStarted()

bool DelayedAction::isStarted ( ) const
inline

Definition at line 35 of file delayed_action.h.

◆ update()

bool DelayedAction::update ( uint32_t  currentTime) const

Polls whether the delay has elapsed.

Updates the delay timer and checks if ready to execute.

Parameters
currentTimeCurrent time in milliseconds (e.g. millis())
Returns
true if the delay has elapsed and the inner action should fire

Definition at line 47 of file delayed_action.cpp.


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