Skip to content

Commit

Permalink
Using comms::option::def::HasName option for all the fields in the pr…
Browse files Browse the repository at this point in the history
…otocol plugins.
  • Loading branch information
arobenko committed Nov 23, 2024
1 parent 5a7905c commit 2d58b0e
Show file tree
Hide file tree
Showing 18 changed files with 238 additions and 116 deletions.
3 changes: 2 additions & 1 deletion demo/protocol/include/demo/DemoMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ class VersionField : public
comms::Field<ProtocolEndian>,
std::uint8_t,
comms::option::DefaultNumValue<1>,
comms::option::ValidNumValueRange<0, 1>
comms::option::ValidNumValueRange<0, 1>,
comms::option::def::HasName
>
{
public:
Expand Down
37 changes: 23 additions & 14 deletions demo/protocol/include/demo/Frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ class SyncField : public
comms::field::IntValue<
FieldBase,
std::uint16_t,
comms::option::DefaultNumValue<0xabcd>,
comms::option::ValidNumValueRange<0xabcd, 0xabcd>
comms::option::def::DefaultNumValue<0xabcd>,
comms::option::def::ValidNumValueRange<0xabcd, 0xabcd>,
comms::option::def::HasName
>
{
public:
Expand All @@ -58,7 +59,8 @@ class SyncField : public
class ChecksumField : public
comms::field::IntValue<
FieldBase,
std::uint16_t
std::uint16_t,
comms::option::def::HasName
>
{
public:
Expand All @@ -79,7 +81,8 @@ class LengthField : public
FieldBase,
std::uint16_t,
comms::option::def::NumValueSerOffset<sizeof(std::uint16_t)>,
comms::option::def::DisplayOffset<sizeof(std::uint16_t)>
comms::option::def::DisplayOffset<sizeof(std::uint16_t)>,
comms::option::def::HasName
>
{
public:
Expand All @@ -99,14 +102,16 @@ class MsgIdField : public
comms::field::EnumValue<
FieldBase,
MsgId,
comms::option::ValidNumValueRange<0, MsgId_NumOfValues - 1>
comms::option::def::ValidNumValueRange<0, MsgId_NumOfValues - 1>,
comms::option::def::HasName
>
{
using Base =
comms::field::EnumValue<
FieldBase,
MsgId,
comms::option::ValidNumValueRange<0, MsgId_NumOfValues - 1>
comms::option::def::ValidNumValueRange<0, MsgId_NumOfValues - 1>,
comms::option::def::HasName
>;
public:
using ValueType = typename Base::ValueType;
Expand Down Expand Up @@ -165,7 +170,13 @@ class MsgIdField : public

/// @brief Field representing full message payload.
template <typename... TOptions>
class DataField : public comms::protocol::MsgDataLayer<TOptions...>::Field
class DataField : public
comms::field::ArrayList<
FieldBase,
std::uint8_t,
TOptions...,
comms::option::def::HasName
>
{
public:
static const char* name()
Expand All @@ -179,8 +190,7 @@ class DataField : public comms::protocol::MsgDataLayer<TOptions...>::Field
template <
typename TMsgBase,
typename TMessages,
typename TMsgAllocOptions = comms::option::EmptyOption,
typename TDataFieldStorageOptions = comms::option::EmptyOption >
typename TMsgAllocOptions = comms::option::EmptyOption>
using StackBase =
comms::protocol::SyncPrefixLayer<
SyncField,
Expand All @@ -197,7 +207,7 @@ using StackBase =
VersionField,
DemoMessage<>::TransportFieldIdx_version,
comms::protocol::MsgDataLayer<
TDataFieldStorageOptions
comms::option::def::FieldType<DataField<>>
>
>,
TMsgAllocOptions
Expand Down Expand Up @@ -236,11 +246,10 @@ using StackBase =
template <
typename TMsgBase,
typename TMessages = demo::AllMessages<TMsgBase, demo::DefaultOptions>,
typename TMsgAllocOptions = comms::option::EmptyOption,
typename TDataFieldStorageOptions = comms::option::EmptyOption >
class Frame : public StackBase<TMsgBase, TMessages, TMsgAllocOptions, TDataFieldStorageOptions>
typename TMsgAllocOptions = comms::option::EmptyOption>
class Frame : public StackBase<TMsgBase, TMessages, TMsgAllocOptions>
{
using Base = StackBase<TMsgBase, TMessages, TMsgAllocOptions, TDataFieldStorageOptions>;
using Base = StackBase<TMsgBase, TMessages, TMsgAllocOptions>;
public:
COMMS_PROTOCOL_LAYERS_ACCESS(payload, version, id, size, checksum, sync);
};
Expand Down
33 changes: 20 additions & 13 deletions demo/protocol/include/demo/message/Bitfields.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ struct BitfieldsFields
comms::field::BitmaskValue<
demo::FieldBase,
typename TOpt::message::BitfieldsFields::field1_bitmask,
comms::option::FixedLength<1>,
comms::option::FixedBitLength<4>,
comms::option::BitmaskReservedBits<0xf8, 0>
comms::option::def::FixedLength<1>,
comms::option::def::FixedBitLength<4>,
comms::option::def::BitmaskReservedBits<0xf8, 0>,
comms::option::def::HasName
>
{
/// @brief Provide names for internal bits.
Expand Down Expand Up @@ -95,17 +96,19 @@ struct BitfieldsFields
demo::FieldBase,
Field1Enum,
typename TOpt::message::BitfieldsFields::field1_enum,
comms::option::ValidNumValueRange<static_cast<int>(0), static_cast<int>(Field1Enum::NumOfValues) - 1>,
comms::option::FixedBitLength<2>
comms::option::def::ValidNumValueRange<static_cast<int>(0), static_cast<int>(Field1Enum::NumOfValues) - 1>,
comms::option::def::FixedBitLength<2>,
comms::option::def::HasName
>
{
using Base =
comms::field::EnumValue<
demo::FieldBase,
Field1Enum,
typename TOpt::message::BitfieldsFields::field1_enum,
comms::option::ValidNumValueRange<static_cast<int>(0), static_cast<int>(Field1Enum::NumOfValues) - 1>,
comms::option::FixedBitLength<2>
comms::option::def::ValidNumValueRange<static_cast<int>(0), static_cast<int>(Field1Enum::NumOfValues) - 1>,
comms::option::def::FixedBitLength<2>,
comms::option::def::HasName
>;
public:
using ValueType = typename Base::ValueType;
Expand Down Expand Up @@ -162,8 +165,9 @@ struct BitfieldsFields
demo::FieldBase,
std::uint8_t,
typename TOpt::message::BitfieldsFields::field1_int1,
comms::option::FixedBitLength<6>,
comms::option::ValidNumValueRange<0, 0x3f>
comms::option::def::FixedBitLength<6>,
comms::option::def::ValidNumValueRange<0, 0x3f>,
comms::option::def::HasName
>
{
public:
Expand All @@ -184,8 +188,9 @@ struct BitfieldsFields
demo::FieldBase,
std::uint8_t,
typename TOpt::message::BitfieldsFields::field1_int2,
comms::option::FixedBitLength<4>,
comms::option::ValidNumValueRange<0, 0xf>
comms::option::def::FixedBitLength<4>,
comms::option::def::ValidNumValueRange<0, 0xf>,
comms::option::def::HasName
>
{
public:
Expand All @@ -210,7 +215,8 @@ struct BitfieldsFields
field1_enum,
field1_int1,
field1_int2
>
>,
comms::option::def::HasName
>
{
using Base =
Expand All @@ -221,7 +227,8 @@ struct BitfieldsFields
field1_enum,
field1_int1,
field1_int2
>
>,
comms::option::def::HasName
>;
public:
/// @brief Allow access to internal fields.
Expand Down
10 changes: 6 additions & 4 deletions demo/protocol/include/demo/message/BitmaskValues.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ struct BitmaskValuesFields
comms::field::BitmaskValue<
demo::FieldBase,
typename TOpt::message::BitmaskValuesFields::field1,
comms::option::FixedLength<1>,
comms::option::BitmaskReservedBits<0xe0, 0>
comms::option::def::FixedLength<1>,
comms::option::def::BitmaskReservedBits<0xe0, 0>,
comms::option::def::HasName
>
{
public:
Expand Down Expand Up @@ -89,8 +90,9 @@ struct BitmaskValuesFields
comms::field::BitmaskValue<
demo::FieldBase,
typename TOpt::message::BitmaskValuesFields::field2,
comms::option::FixedLength<2>,
comms::option::BitmaskReservedBits<0xfcf6, 0>
comms::option::def::FixedLength<2>,
comms::option::def::BitmaskReservedBits<0xfcf6, 0>,
comms::option::def::HasName
>
{
public:
Expand Down
24 changes: 16 additions & 8 deletions demo/protocol/include/demo/message/Bundles.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ struct BundlesFields
comms::field::IntValue<
demo::FieldBase,
std::uint8_t,
typename TOpt::message::BundlesFields::field1_mem1
typename TOpt::message::BundlesFields::field1_mem1,
comms::option::def::HasName
>
{
public:
Expand All @@ -64,7 +65,8 @@ struct BundlesFields
comms::field::String<
demo::FieldBase,
typename TOpt::message::BundlesFields::field1_mem2,
comms::option::def::SequenceFixedSize<8>
comms::option::def::SequenceFixedSize<8>,
comms::option::def::HasName
>
{
public:
Expand All @@ -83,7 +85,8 @@ struct BundlesFields
field1_mem2
>,
comms::option::def::RemLengthMemberField<0>,
typename TOpt::message::BundlesFields::field1
typename TOpt::message::BundlesFields::field1,
comms::option::def::HasName
>
{
using Base =
Expand All @@ -94,7 +97,8 @@ struct BundlesFields
field1_mem2
>,
comms::option::def::RemLengthMemberField<0>,
typename TOpt::message::BundlesFields::field1
typename TOpt::message::BundlesFields::field1,
comms::option::def::HasName
>;

public:
Expand All @@ -112,7 +116,8 @@ struct BundlesFields
comms::field::IntValue<
demo::FieldBase,
std::uint8_t,
typename TOpt::message::BundlesFields::field2_mem1
typename TOpt::message::BundlesFields::field2_mem1,
comms::option::def::HasName
>
{
public:
Expand All @@ -133,7 +138,8 @@ struct BundlesFields
demo::FieldBase,
std::uint8_t,
typename TOpt::message::BundlesFields::field2_mem2,
comms::option::def::SequenceFixedSize<8>
comms::option::def::SequenceFixedSize<8>,
comms::option::def::HasName
>
{
public:
Expand All @@ -152,7 +158,8 @@ struct BundlesFields
field2_mem2
>,
comms::option::def::RemLengthMemberField<0>,
typename TOpt::message::BundlesFields::field2
typename TOpt::message::BundlesFields::field2,
comms::option::def::HasName
>
{
using Base =
Expand All @@ -163,7 +170,8 @@ struct BundlesFields
field2_mem2
>,
comms::option::def::RemLengthMemberField<0>,
typename TOpt::message::BundlesFields::field2
typename TOpt::message::BundlesFields::field2,
comms::option::def::HasName
>;

public:
Expand Down
24 changes: 16 additions & 8 deletions demo/protocol/include/demo/message/EnumValues.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,17 @@ struct EnumValuesFields
demo::FieldBase,
ValuesField1,
typename TOpt::message::EnumValuesFields::field1,
comms::option::ValidNumValueRange<static_cast<int>(0), static_cast<int>(ValuesField1::NumOfValues) - 1>
comms::option::ValidNumValueRange<static_cast<int>(0), static_cast<int>(ValuesField1::NumOfValues) - 1>,
comms::option::def::HasName
>
{
using Base =
comms::field::EnumValue<
demo::FieldBase,
ValuesField1,
typename TOpt::message::EnumValuesFields::field1,
comms::option::ValidNumValueRange<static_cast<int>(0), static_cast<int>(ValuesField1::NumOfValues) - 1>
comms::option::ValidNumValueRange<static_cast<int>(0), static_cast<int>(ValuesField1::NumOfValues) - 1>,
comms::option::def::HasName
>;
public:
using ValueType = typename Base::ValueType;
Expand Down Expand Up @@ -130,15 +132,17 @@ struct EnumValuesFields
demo::FieldBase,
ValuesField2,
typename TOpt::message::EnumValuesFields::field2,
comms::option::DefaultNumValue<static_cast<int>(ValuesField2::Value1)>
comms::option::DefaultNumValue<static_cast<int>(ValuesField2::Value1)>,
comms::option::def::HasName
>
{
using Base =
comms::field::EnumValue<
demo::FieldBase,
ValuesField2,
typename TOpt::message::EnumValuesFields::field2,
comms::option::DefaultNumValue<static_cast<int>(ValuesField2::Value1)>
comms::option::DefaultNumValue<static_cast<int>(ValuesField2::Value1)>,
comms::option::def::HasName
>;

public:
Expand Down Expand Up @@ -229,7 +233,8 @@ struct EnumValuesFields
ValuesField3,
typename TOpt::message::EnumValuesFields::field3,
comms::option::VarLength<1, 2>,
comms::option::DefaultNumValue<static_cast<int>(ValuesField3::Value1)>
comms::option::DefaultNumValue<static_cast<int>(ValuesField3::Value1)>,
comms::option::def::HasName
>
{
using Base =
Expand All @@ -238,7 +243,8 @@ struct EnumValuesFields
ValuesField3,
typename TOpt::message::EnumValuesFields::field3,
comms::option::VarLength<1, 2>,
comms::option::DefaultNumValue<static_cast<int>(ValuesField3::Value1)>
comms::option::DefaultNumValue<static_cast<int>(ValuesField3::Value1)>,
comms::option::def::HasName
>;

public:
Expand Down Expand Up @@ -327,7 +333,8 @@ struct EnumValuesFields
typename TOpt::message::EnumValuesFields::field4,
comms::option::ValidBigUnsignedNumValue<static_cast<std::uintmax_t>(ValuesField4::Value1)>,
comms::option::ValidBigUnsignedNumValue<static_cast<std::uintmax_t>(ValuesField4::Value2)>,
comms::option::ValidBigUnsignedNumValue<static_cast<std::uintmax_t>(ValuesField4::Value3)>
comms::option::ValidBigUnsignedNumValue<static_cast<std::uintmax_t>(ValuesField4::Value3)>,
comms::option::def::HasName
>
{
using Base =
Expand All @@ -337,7 +344,8 @@ struct EnumValuesFields
typename TOpt::message::EnumValuesFields::field4,
comms::option::ValidBigUnsignedNumValue<static_cast<std::uintmax_t>(ValuesField4::Value1)>,
comms::option::ValidBigUnsignedNumValue<static_cast<std::uintmax_t>(ValuesField4::Value2)>,
comms::option::ValidBigUnsignedNumValue<static_cast<std::uintmax_t>(ValuesField4::Value3)>
comms::option::ValidBigUnsignedNumValue<static_cast<std::uintmax_t>(ValuesField4::Value3)>,
comms::option::def::HasName
>;
public:
using ValueType = typename Base::ValueType;
Expand Down
Loading

0 comments on commit 2d58b0e

Please sign in to comment.