CommRaT 2.0.0
C++20 Real-Time Messaging Framework
Loading...
Searching...
No Matches
commrat::CommandDispatcher< ModuleType, CommandTypes > Class Template Reference

Command dispatcher mixin. More...

#include <commrat/module/lifecycle/command_dispatcher.hpp>

Inheritance diagram for commrat::CommandDispatcher< ModuleType, CommandTypes >:
commrat::Module< UserRegistry, OutputSpec_, InputSpec_, CommandTypes... >

Protected Member Functions

void command_loop ()
 Command loop - receives and dispatches user commands.
 
template<typename CmdT >
void handle_user_command (const CmdT &cmd)
 Dispatch user command to on_command handler.
 
template<typename CmdT >
void on_command (const CmdT &cmd)
 Handle a specific command type (override in derived class)
 

Detailed Description

template<typename ModuleType, typename... CommandTypes>
class commrat::CommandDispatcher< ModuleType, CommandTypes >

Command dispatcher mixin.

Provides command_loop() and handle_user_command() for modules that accept user commands via the CMD mailbox.

Template Parameters
ModuleTypeThe derived Module class (CRTP)
CommandTypesVariadic pack of command payload types

Definition at line 26 of file command_dispatcher.hpp.

Member Function Documentation

◆ command_loop()

template<typename ModuleType , typename... CommandTypes>
void commrat::CommandDispatcher< ModuleType, CommandTypes >::command_loop ( )
inlineprotected

Command loop - receives and dispatches user commands.

Runs in a dedicated thread, blocking on CMD mailbox receives. Routes commands to on_command() handlers based on payload type.

Definition at line 34 of file command_dispatcher.hpp.

◆ handle_user_command()

template<typename ModuleType , typename... CommandTypes>
template<typename CmdT >
void commrat::CommandDispatcher< ModuleType, CommandTypes >::handle_user_command ( const CmdT &  cmd)
inlineprotected

Dispatch user command to on_command handler.

Template Parameters
CmdTCommand payload type
Parameters
cmdCommand payload

Definition at line 66 of file command_dispatcher.hpp.

◆ on_command()

template<typename ModuleType , typename... CommandTypes>
template<typename CmdT >
void commrat::CommandDispatcher< ModuleType, CommandTypes >::on_command ( const CmdT &  cmd)
inlineprotected

Handle a specific command type (override in derived class)

Default implementation does nothing. Derived classes should provide overloads for each command type they support:

void on_command(const ResetCmd& cmd) override { ... } void on_command(const CalibrateCmd& cmd) override { ... }

Template Parameters
CmdTCommand payload type
Parameters
cmdCommand payload

Definition at line 89 of file command_dispatcher.hpp.


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