Skip to content

Commit

Permalink
Release v4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
arobenko committed Apr 19, 2023
2 parents ea4f23e + a470b8c commit 5fd32f0
Show file tree
Hide file tree
Showing 16 changed files with 119 additions and 120 deletions.
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ configuration:
- Release

environment:
COMMS_BRANCH: master
COMMS_BRANCH: v5.2
matrix:
- CPP_STD: 11
- CPP_STD: 14
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/actions_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Github Actions Build
on: [push]

env:
COMMS_BRANCH: master
COMMS_BRANCH: v5.2

jobs:
build_gcc_old_ubuntu_20_04:
Expand Down
4 changes: 1 addition & 3 deletions demo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ endif ()

find_package (Doxygen)
if (DOXYGEN_FOUND)
set (doc_output_dir "${CMAKE_INSTALL_PREFIX}/${DOC_INSTALL_DIR}/cc_demo")
make_directory (${doc_output_dir})

set (doc_output_dir "${DOC_INSTALL_DIR}/cc_demo")
set (match_str "OUTPUT_DIRECTORY[^\n]*")
set (replacement_str "OUTPUT_DIRECTORY = ${doc_output_dir}")
set (output_file "${CMAKE_CURRENT_BINARY_DIR}/doxygen.conf")
Expand Down
2 changes: 1 addition & 1 deletion demo/doxygen/doxygen.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2528,7 +2528,7 @@ MSCFILE_DIRS =
# contain dia files that are included in the documentation (see the \diafile
# command).

DIAFILE_DIRS = doxygen/dia
DIAFILE_DIRS =

# When using plantuml, the PLANTUML_JAR_PATH tag should be used to specify the
# path where java can find the plantuml.jar file. If left blank, it is assumed
Expand Down
2 changes: 1 addition & 1 deletion doxygen/page_fields_properties.dox
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@
/// {
/// typedef ListsFields::field2 Field2;
/// static const auto ElemCount =
/// Field2::ParsedOptions::SequenceFixedSize;
/// Field2::fixedSize();
///
/// cc::property::field::ForField<ListsFields::field2> props;
/// props.name("field2");
Expand Down
63 changes: 55 additions & 8 deletions lib/include/cc_tools_qt/ProtocolBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ class ProtocolBase : public Protocol
/// @brief Type of "Extra Info Message"
using ExtraInfoMsg = ExtraInfoMessage<ProtocolMessage>;

/// @brief Type of message factory
using MsgFactory = typename TProtStack::MsgFactory;

static_assert(
!std::is_void<AllMessages>::value,
"AllMessages must be a normal type");
Expand Down Expand Up @@ -481,19 +484,21 @@ class ProtocolBase : public Protocol
template <typename TMsgsTuple>
MessagesList createAllMessagesInTuple()
{
MessagesList allMsgs;
comms::util::tupleForEachType<TMsgsTuple>(AllMsgsCreateHelper(allMsgs));
for (auto& msgPtr : allMsgs) {
setNameToMessageProperties(*msgPtr);
setForceExtraInfoExistenceToMessageProperties(*msgPtr);
updateMessage(*msgPtr);
}
return allMsgs;
using Tag =
typename std::conditional<
std::is_void<MsgFactory>::value,
NoMsgFactoryTag,
HasMsgFactoryTag
>::type;

return createAllMessagesInTupleInternal<TMsgsTuple>(Tag());
}

private:
struct NumericIdTag {};
struct OtherIdTag {};
struct HasMsgFactoryTag{};
struct NoMsgFactoryTag{};

typedef typename std::conditional<
(std::is_enum<MsgIdType>::value || std::is_integral<MsgIdType>::value),
Expand Down Expand Up @@ -587,6 +592,48 @@ class ProtocolBase : public Protocol
return result;
}

template <typename TMsgsTuple>
MessagesList createAllMessagesInTupleInternal(NoMsgFactoryTag)
{
MessagesList allMsgs;
comms::util::tupleForEachType<TMsgsTuple>(AllMsgsCreateHelper(allMsgs));
for (auto& msgPtr : allMsgs) {
setNameToMessageProperties(*msgPtr);
setForceExtraInfoExistenceToMessageProperties(*msgPtr);
updateMessage(*msgPtr);
}
return allMsgs;
}

template <typename TMsgsTuple>
MessagesList createAllMessagesInTupleInternal(HasMsgFactoryTag)
{
static_assert(std::tuple_size<TMsgsTuple>::value > 0U, "At least one message is expected to be defined");
using FirstType = typename std::tuple_element<0, TMsgsTuple>::type;
using LastType = typename std::tuple_element<std::tuple_size<TMsgsTuple>::value - 1U, TMsgsTuple>::type;
auto firstId = static_cast<std::uintmax_t>(FirstType::doGetId());
auto lastId = static_cast<std::uintmax_t>(LastType::doGetId());

MessagesList allMsgs;
MsgFactory factory;
for (std::uintmax_t id = firstId; id <= lastId; ++id) {
auto count = factory.msgCount(static_cast<MsgIdType>(id));
for (auto idx = 0U; idx < count; ++idx) {
auto msgPtr = factory.createMsg(static_cast<MsgIdType>(id), idx);
if (msgPtr) {
allMsgs.push_back(std::move(msgPtr));
}
}
}

for (auto& msgPtr : allMsgs) {
setNameToMessageProperties(*msgPtr);
setForceExtraInfoExistenceToMessageProperties(*msgPtr);
updateMessage(*msgPtr);
}
return allMsgs;
}

ProtocolStack m_protStack;
std::vector<std::uint8_t> m_data;
std::vector<std::uint8_t> m_garbage;
Expand Down
2 changes: 1 addition & 1 deletion lib/include/cc_tools_qt/ProtocolMessageBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class ProtocolMessageBase : public TMsgBase
static_assert(comms::isMessageBase<TMsgBase>(), "TMsgBase is expected to be proper message");

using Tag = typename std::conditional<
TMsgBase::ImplOptions::HasName,
TMsgBase::hasCustomName(),
HasNameTag,
NoNameTag
>::type;
Expand Down
15 changes: 7 additions & 8 deletions lib/include/cc_tools_qt/field_wrapper/ArrayListRawDataWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,14 @@ class ArrayListRawDataWrapperT : public FieldWrapperT<ArrayListRawDataWrapper, T
struct FixedSizeTag {};
struct NoLimitsTag {};

typedef typename Field::ParsedOptions FieldOptions;
typedef typename std::conditional<
FieldOptions::HasSequenceSizeFieldPrefix,
Field::hasSizeFieldPrefix(),
SizeFieldExistsTag,
typename std::conditional<
FieldOptions::HasSequenceSerLengthFieldPrefix,
Field::hasSerLengthFieldPrefix(),
SerLengthFieldExistsTag,
typename std::conditional<
FieldOptions::HasSequenceFixedSize,
Field::hasFixedSize(),
FixedSizeTag,
NoLimitsTag
>::type
Expand All @@ -202,19 +201,19 @@ class ArrayListRawDataWrapperT : public FieldWrapperT<ArrayListRawDataWrapper, T

static int maxSizeInternal(SizeFieldExistsTag)
{
typedef typename FieldOptions::SequenceSizeFieldPrefix PrefixField;
typedef typename Field::SizeFieldPrefix PrefixField;
return maxSizeByPrefix<PrefixField>();
}

static int maxSizeInternal(SerLengthFieldExistsTag)
{
typedef typename FieldOptions::SequenceSerLengthFieldPrefix PrefixField;
typedef typename Field::SerLengthFieldPrefix PrefixField;
return maxSizeByPrefix<PrefixField>();
}

static int maxSizeInternal(FixedSizeTag)
{
return static_cast<int>(FieldOptions::SequenceFixedSize);
return static_cast<int>(Field::fixedSize());
}

int maxSizeInternal(NoLimitsTag) const
Expand All @@ -238,7 +237,7 @@ class ArrayListRawDataWrapperT : public FieldWrapperT<ArrayListRawDataWrapper, T

static int minSizeInternal(FixedSizeTag)
{
return static_cast<int>(FieldOptions::SequenceFixedSize);
return static_cast<int>(Field::fixedSize());
}

int minSizeInternal(NoLimitsTag) const
Expand Down
20 changes: 10 additions & 10 deletions lib/include/cc_tools_qt/field_wrapper/ArrayListWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,14 @@ class ArrayListWrapperT : public FieldWrapperT<ArrayListWrapper, TField>

virtual bool hasFixedSizeImpl() const override
{
return Field::ParsedOptions::HasSequenceFixedSize;
return Field::hasFixedSize();
}

virtual void adjustFixedSizeImpl() override
{
using Tag =
typename std::conditional<
Field::ParsedOptions::HasSequenceFixedSize,
Field::hasFixedSize(),
HasFixedSizeTag,
HasVarSizeTag
>::type;
Expand Down Expand Up @@ -238,10 +238,10 @@ class ArrayListWrapperT : public FieldWrapperT<ArrayListWrapper, TField>
{
using Tag =
typename std::conditional<
Field::ParsedOptions::HasSequenceSizeFieldPrefix,
Field::hasSizeFieldPrefix(),
ElemCountFieldTag,
typename std::conditional<
Field::ParsedOptions::HasSequenceSerLengthFieldPrefix,
Field::hasSerLengthFieldPrefix(),
SerLengthFieldTag,
NoPrefixFieldTag
>::type
Expand All @@ -266,18 +266,18 @@ class ArrayListWrapperT : public FieldWrapperT<ArrayListWrapper, TField>

PrefixFieldInfo getPrefixFieldInfoInternal(ElemCountFieldTag) const
{
using SizeField = typename Field::ParsedOptions::SequenceSizeFieldPrefix;
using SizeField = typename Field::SizeFieldPrefix;
SizeField sizeField;
sizeField.setValue(Base::field().value().size());
return std::make_pair(static_cast<int>(sizeField.getValue()), getPrefixFieldSerialised(sizeField));
}

PrefixFieldInfo getPrefixFieldInfoInternal(SerLengthFieldTag) const
{
using LengthField = typename Field::ParsedOptions::SequenceSerLengthFieldPrefix;
using LengthField = typename Field::SerLengthFieldPrefix;
using Tag =
typename std::conditional<
LengthField::ParsedOptions::HasVarLengthLimits,
LengthField::hasVarLength(),
SerLengthFieldVarTag,
SerLengthFieldFixedTag
>::type;
Expand All @@ -287,15 +287,15 @@ class ArrayListWrapperT : public FieldWrapperT<ArrayListWrapper, TField>

PrefixFieldInfo getPrefixFieldInfoInternal(SerLengthFieldFixedTag) const
{
using LengthField = typename Field::ParsedOptions::SequenceSerLengthFieldPrefix;
using LengthField = typename Field::SerLengthFieldPrefix;
LengthField lenField;
lenField.setValue(Base::field().length() - LengthField::maxLength());
return std::make_pair(static_cast<int>(lenField.getValue()), getPrefixFieldSerialised(lenField));
}

PrefixFieldInfo getPrefixFieldInfoInternal(SerLengthFieldVarTag) const
{
using LengthField = typename Field::ParsedOptions::SequenceSerLengthFieldPrefix;
using LengthField = typename Field::SerLengthFieldPrefix;

auto fullLen = Base::field().length();
LengthField lenFieldTmp;
Expand Down Expand Up @@ -334,7 +334,7 @@ class ArrayListWrapperT : public FieldWrapperT<ArrayListWrapper, TField>

void adjustFixedSizeInternal(HasFixedSizeTag)
{
Base::field().value().resize(Field::ParsedOptions::SequenceFixedSize);
Base::field().value().resize(Field::fixedSize());
}


Expand Down
44 changes: 32 additions & 12 deletions lib/include/cc_tools_qt/field_wrapper/FieldWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@ class FieldWrapperT : public TBase
return false;
}

if ((!Field::ParsedOptions::HasSequenceSizeFieldPrefix) &&
(!Field::ParsedOptions::HasSequenceSerLengthFieldPrefix) &&
(!Field::ParsedOptions::HasSequenceTrailingFieldSuffix) &&
(!Field::ParsedOptions::HasSequenceTerminationFieldSuffix)){
if ((!CollectionPrefixDetect<Field, IsCollection>::HasSizeFieldPrefix) &&
(!CollectionPrefixDetect<Field, IsCollection>::HasSerLengthFieldPrefix) &&
(!CollectionPrefixDetect<Field, IsCollection>::HasTrailingFieldSuffix) &&
(!CollectionPrefixDetect<Field, IsCollection>::HasTerminationFieldSuffix)) {
auto iter = &value[0];
auto es = m_field.read(iter, value.size());
return es == comms::ErrorStatus::Success;
Expand Down Expand Up @@ -199,33 +199,53 @@ class FieldWrapperT : public TBase
}

private:
template <typename T, bool TIsCollection>
struct CollectionPrefixDetect
{
static const bool HasSizeFieldPrefix = false;
static const bool HasSerLengthFieldPrefix = false;
static const bool HasTrailingFieldSuffix = false;
static const bool HasTerminationFieldSuffix = false;
};

template <typename T>
struct CollectionPrefixDetect<T, true>
{
static const bool HasSizeFieldPrefix = Field::hasSizeFieldPrefix();
static const bool HasSerLengthFieldPrefix = Field::hasSerLengthFieldPrefix();
static const bool HasTrailingFieldSuffix = TField::hasTrailingFieldSuffix();
static const bool HasTerminationFieldSuffix = Field::hasTerminationFieldSuffix();
};

static constexpr bool IsCollection = comms::field::isString<Field>() || comms::field::isArrayList<Field>();

typedef typename std::conditional<
Field::ParsedOptions::HasSequenceSizeFieldPrefix,
CollectionPrefixDetect<Field, IsCollection>::HasSizeFieldPrefix,
HasPrefixSuffixTag,
NoPrefixSuffixTag
>::type SerialisedSizePrefixTag;

typedef typename std::conditional<
Field::ParsedOptions::HasSequenceSerLengthFieldPrefix,
CollectionPrefixDetect<Field, IsCollection>::HasSerLengthFieldPrefix,
HasPrefixSuffixTag,
NoPrefixSuffixTag
>::type SerialisedLengthPrefixTag;

typedef typename std::conditional<
Field::ParsedOptions::HasSequenceTrailingFieldSuffix,
CollectionPrefixDetect<Field, IsCollection>::HasTrailingFieldSuffix,
HasPrefixSuffixTag,
NoPrefixSuffixTag
>::type SerialisedTrailSuffixTag;

typedef typename std::conditional<
Field::ParsedOptions::HasSequenceTerminationFieldSuffix,
CollectionPrefixDetect<Field, IsCollection>::HasTerminationFieldSuffix,
HasPrefixSuffixTag,
NoPrefixSuffixTag
>::type SerialisedTermSuffixTag;

bool writeSerialisedSize(SerialisedSeq& seq, std::size_t sizeVal, HasPrefixSuffixTag)
{
typedef typename Field::ParsedOptions::SequenceSizeFieldPrefix SizePrefixField;
typedef typename Field::SizeFieldPrefix SizePrefixField;

SizePrefixField sizePrefixField;
sizePrefixField.setValue(sizeVal);
Expand All @@ -243,7 +263,7 @@ class FieldWrapperT : public TBase

bool writeSerialisedLength(SerialisedSeq& seq, std::size_t sizeVal, HasPrefixSuffixTag)
{
typedef typename Field::ParsedOptions::SequenceSerLengthFieldPrefix LengthPrefixField;
typedef typename Field::SerLengthFieldPrefix LengthPrefixField;

LengthPrefixField lengthPrefixField;
lengthPrefixField.setValue(sizeVal);
Expand All @@ -261,7 +281,7 @@ class FieldWrapperT : public TBase

bool writeTrailSuffix(SerialisedSeq& seq, HasPrefixSuffixTag)
{
typedef typename Field::ParsedOptions::SequenceTrailingFieldSuffix TrailingSuffixField;
typedef typename Field::TrailingFieldSuffix TrailingSuffixField;
TrailingSuffixField trailingSuffixField;
auto writeIter = std::back_inserter(seq);
auto es = trailingSuffixField.write(writeIter, seq.max_size() - seq.size());
Expand All @@ -276,7 +296,7 @@ class FieldWrapperT : public TBase

bool writeTermSuffix(SerialisedSeq& seq, HasPrefixSuffixTag)
{
typedef typename Field::ParsedOptions::SequenceTerminationFieldSuffix TermSuffixField;
typedef typename Field::TerminationFieldSuffix TermSuffixField;
TermSuffixField termSuffixField;
auto writeIter = std::back_inserter(seq);
auto es = termSuffixField.write(writeIter, seq.max_size() - seq.size());
Expand Down
Loading

0 comments on commit 5fd32f0

Please sign in to comment.