emlabcpp
modern opinionated embedded C++ library
emlabcpp::protocol::command_group< Endianess, Cmds > Struct Template Reference

Command group should be used as a collection of commands that are selected based on the ID, during the deserialization first command that matches is selected. More...

#include <command_group.h>

+ Inheritance diagram for emlabcpp::protocol::command_group< Endianess, Cmds >:
+ Collaboration diagram for emlabcpp::protocol::command_group< Endianess, Cmds >:

Public Types

using cmds_type = std::tuple< Cmds... >
 
template<auto ID>
using cmd_type = std::tuple_element_t< id_index< ID >, cmds_type >
 
template<auto ID>
using cmd_value_type = typename cmd_type< ID >::value_type
 
template<typename... SubCmds>
using with_commands = command_group< Endianess, Cmds..., SubCmds... >
 
using def_type = endianess_wrapper< Endianess, group< typename Cmds::def_type... > >
 
using traits = proto_traits< def_type >
 
using value_type = typename traits::value_type
 
using message_type = message< max_size >
 

Public Member Functions

template<auto id, typename... Args>
 requires ((id==Cmds::id)||...) const expr static value_type make_val(Args const &... args)
 Creates value of the command group, that is variant with value of the command 'id' that will receive the appropiate 'args'. More...
 

Static Public Attributes

template<auto ID>
static constexpr std::size_t id_index = get_id_index( ID )
 
static constexpr std::size_t max_size = proto_traits< def_type >::max_size
 

Detailed Description

template<std::endian Endianess, typename... Cmds>
struct emlabcpp::protocol::command_group< Endianess, Cmds >

Command group should be used as a collection of commands that are selected based on the ID, during the deserialization first command that matches is selected.

The command_group acts as def_type that is handled by the protocol library. The internal definition produced is just std::variant of tuples that form the commands itself. Note that group without commands is not usable by the protocol library as that case is specialized and doesn ot contain any protocol definitions. This is required implementation detail.

Member Typedef Documentation

◆ cmd_type

template<std::endian Endianess, typename... Cmds>
template<auto ID>
using emlabcpp::protocol::command_group< Endianess, Cmds >::cmd_type = std::tuple_element_t< id_index< ID >, cmds_type >

◆ cmd_value_type

template<std::endian Endianess, typename... Cmds>
template<auto ID>
using emlabcpp::protocol::command_group< Endianess, Cmds >::cmd_value_type = typename cmd_type< ID >::value_type

◆ cmds_type

template<std::endian Endianess, typename... Cmds>
using emlabcpp::protocol::command_group< Endianess, Cmds >::cmds_type = std::tuple< Cmds... >

◆ def_type

template<std::endian Endianess, typename... Cmds>
using emlabcpp::protocol::command_group< Endianess, Cmds >::def_type = endianess_wrapper< Endianess, group< typename Cmds::def_type... > >

◆ message_type

template<std::endian Endianess, typename... Cmds>
using emlabcpp::protocol::command_group< Endianess, Cmds >::message_type = message< max_size >

◆ traits

template<std::endian Endianess, typename... Cmds>
using emlabcpp::protocol::command_group< Endianess, Cmds >::traits = proto_traits< def_type >

◆ value_type

template<std::endian Endianess, typename... Cmds>
using emlabcpp::protocol::command_group< Endianess, Cmds >::value_type = typename traits::value_type

◆ with_commands

template<std::endian Endianess, typename... Cmds>
template<typename... SubCmds>
using emlabcpp::protocol::command_group< Endianess, Cmds >::with_commands = command_group< Endianess, Cmds..., SubCmds... >

Member Function Documentation

◆ requires()

template<std::endian Endianess, typename... Cmds>
template<auto id, typename... Args>
emlabcpp::protocol::command_group< Endianess, Cmds >::requires ( (id==Cmds::id)||  ...) const &
inline

Creates value of the command group, that is variant with value of the command 'id' that will receive the appropiate 'args'.

References emlabcpp::args, EMLABCPP_ASSERT, emlabcpp::for_each_index(), and emlabcpp::res.

Member Data Documentation

◆ id_index

template<std::endian Endianess, typename... Cmds>
template<auto ID>
constexpr std::size_t emlabcpp::protocol::command_group< Endianess, Cmds >::id_index = get_id_index( ID )
staticconstexpr

◆ max_size

template<std::endian Endianess, typename... Cmds>
constexpr std::size_t emlabcpp::protocol::command_group< Endianess, Cmds >::max_size = proto_traits< def_type >::max_size
staticconstexpr

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