Radix Relay
Hybrid mesh communications with Signal Protocol encryption
Loading...
Searching...
No Matches
radix_relay::core::event_handler< CommandHandler, CommandParser > Struct Template Reference

Dispatches parsed command events to the command handler. More...

#include <event_handler.hpp>

Classes

struct  out_queues_t
 

Public Types

using in_queue_t = async::async_queue< events::raw_command >
 

Public Member Functions

 event_handler (std::shared_ptr< CommandHandler > command_handler, std::shared_ptr< CommandParser > parser, const out_queues_t &)
 Constructs an event handler with command handler and parser.
 
auto handle (const events::raw_command &event) const -> void
 Parses and handles a raw command string.
 

Detailed Description

template<typename CommandHandler, typename CommandParser>
struct radix_relay::core::event_handler< CommandHandler, CommandParser >

Dispatches parsed command events to the command handler.

Template Parameters
CommandHandlerCallable type that handles typed command events via operator()
CommandParserParser type with command_variant_t type trait and parse() method

Uses Chain of Responsibility (parser) + Visitor (command_handler) pattern:

  • Parser converts raw string to strongly-typed command variant
  • std::visit dispatches the variant to command_handler

Definition at line 20 of file event_handler.hpp.

Member Typedef Documentation

◆ in_queue_t

template<typename CommandHandler , typename CommandParser >
using radix_relay::core::event_handler< CommandHandler, CommandParser >::in_queue_t = async::async_queue<events::raw_command>

Definition at line 22 of file event_handler.hpp.

Constructor & Destructor Documentation

◆ event_handler()

template<typename CommandHandler , typename CommandParser >
radix_relay::core::event_handler< CommandHandler, CommandParser >::event_handler ( std::shared_ptr< CommandHandler >  command_handler,
std::shared_ptr< CommandParser >  parser,
const out_queues_t  
)
inlineexplicit

Constructs an event handler with command handler and parser.

Parameters
command_handlerCommand handler that handles typed commands (shared ownership)
parserCommand parser for converting strings to typed events
queuesOutput queues (stored for type compatibility, handler uses its own references)

Definition at line 39 of file event_handler.hpp.

Member Function Documentation

◆ handle()

template<typename CommandHandler , typename CommandParser >
auto radix_relay::core::event_handler< CommandHandler, CommandParser >::handle ( const events::raw_command event) const -> void
inline

Parses and handles a raw command string.

Parses input to typed command and dispatches via std::visit.

Parameters
eventRaw command event containing unparsed user input

Definition at line 52 of file event_handler.hpp.


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