moddef-cpp
Idiomatic C++ runtime for ModDef
Loading...
Searching...
No Matches
moddef::CommandExecutor Class Reference

One armed command run. More...

#include <command.hpp>

Public Member Functions

CommandStatus tick (std::uint32_t now_ms) noexcept
 Advance the run; now_ms is any monotonic millisecond clock.
 
Error error () const noexcept
 The failure cause after CommandStatus::Error (Error::Ok otherwise).
 
Result< Valueresult (std::string_view field) const
 Numeric result by CommandResult.field, after Done.
 
Result< std::span< const std::uint8_t > > result_data (std::string_view field) const
 String/bytes result: a view into the caller's data sink.
 
 CommandExecutor (CommandExecutor &&) noexcept=default
 
CommandExecutoroperator= (CommandExecutor &&) noexcept=default
 
 CommandExecutor (const CommandExecutor &)=delete
 
CommandExecutoroperator= (const CommandExecutor &)=delete
 

Static Public Member Functions

static Result< CommandExecutorbegin (Device &dev, std::string_view command_id, const md_cmd_params_t *params, std::span< std::uint8_t > sink={})
 Locate command_id in the device profile, validate required params, and arm the run.
 

Detailed Description

One armed command run.

Movable; non-copyable. The Device, param storage, and data sink must outlive the executor.

Constructor & Destructor Documentation

◆ CommandExecutor() [1/2]

moddef::CommandExecutor::CommandExecutor ( CommandExecutor &&  )
defaultnoexcept

◆ CommandExecutor() [2/2]

moddef::CommandExecutor::CommandExecutor ( const CommandExecutor )
delete

Member Function Documentation

◆ begin()

static Result< CommandExecutor > moddef::CommandExecutor::begin ( Device dev,
std::string_view  command_id,
const md_cmd_params_t *  params,
std::span< std::uint8_t >  sink = {} 
)
inlinestatic

Locate command_id in the device profile, validate required params, and arm the run.

sink receives string/bytes read-step payloads (pass an empty span when the command reads none).

◆ tick()

CommandStatus moddef::CommandExecutor::tick ( std::uint32_t  now_ms)
inlinenoexcept

Advance the run; now_ms is any monotonic millisecond clock.

◆ error()

Error moddef::CommandExecutor::error ( ) const
inlinenoexcept

The failure cause after CommandStatus::Error (Error::Ok otherwise).

◆ result()

Result< Value > moddef::CommandExecutor::result ( std::string_view  field) const
inline

Numeric result by CommandResult.field, after Done.

◆ result_data()

Result< std::span< const std::uint8_t > > moddef::CommandExecutor::result_data ( std::string_view  field) const
inline

String/bytes result: a view into the caller's data sink.

◆ operator=() [1/2]

CommandExecutor & moddef::CommandExecutor::operator= ( CommandExecutor &&  )
defaultnoexcept

◆ operator=() [2/2]

CommandExecutor & moddef::CommandExecutor::operator= ( const CommandExecutor )
delete

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