Skip to content

Commit

Permalink
Some extra fields hierarchy simplification.
Browse files Browse the repository at this point in the history
  • Loading branch information
arobenko committed Oct 27, 2024
1 parent f594b37 commit c44014b
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 357 deletions.
2 changes: 1 addition & 1 deletion demo/cc_plugin/message/Lists.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ QVariantMap createField5Properties()
cc::property::field::ForField<ProtMsg::Field_field5::ValueType::value_type>()
.add(cc::property::field::IntValue().serialisedHidden().asMap())
.add(cc::property::field::IntValue().serialisedHidden().asMap())
.add(cc::property::field::String().serialisedHidden().asMap())
.add(cc::property::field::IntValue().serialisedHidden().asMap())
.serialisedHidden()
.asMap())
// .serialisedHidden()
Expand Down
8 changes: 4 additions & 4 deletions demo/cc_plugin/message/Variants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ using ProtMsg = demo::cc_plugin::message::Variants::ProtMsg;
QVariantMap createProps_id()
{
auto props =
cc::property::field::EnumValue()
cc::property::field::Common()
.readOnly();
return props.asMap();
}

QVariantMap createProps_length()
{
auto props =
cc::property::field::EnumValue()
cc::property::field::Common()
.readOnly();
return props.asMap();
}
Expand Down Expand Up @@ -82,7 +82,7 @@ QVariantMap createProps_field1_var3()
auto props =
cc::property::field::ForField<Field>()
.add(createProps_id())
.add(cc::property::field::String().asMap());
.add(cc::property::field::Common().asMap());
assert(props.members().size() == Field::FieldIdx_numOfValues);
return props.asMap();
}
Expand Down Expand Up @@ -132,7 +132,7 @@ QVariantMap createProps_field2_var3()
cc::property::field::ForField<Field>()
.add(createProps_id())
.add(createProps_length())
.add(cc::property::field::String().asMap());
.add(cc::property::field::Common().asMap());
assert(props.members().size() == Field::FieldIdx_numOfValues);
return props.asMap();
}
Expand Down
3 changes: 1 addition & 2 deletions lib/include/cc_tools_qt/ToolsExtraInfoMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ class ToolsExtraInfoMessage : public
static QVariantList createFieldsProperties()
{
QVariantList props;
props.append(
property::field::String().serialisedHidden().asMap());
props.append(property::field::Common().serialisedHidden().asMap());
return props;
}
};
Expand Down
11 changes: 9 additions & 2 deletions lib/include/cc_tools_qt/ToolsField.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ class ToolsFieldHandler;
class CC_API ToolsField
{
public:
using SerialisedSeq = std::vector<std::uint8_t>;

using Ptr = std::unique_ptr<ToolsField>;
using SerialisedSeq = std::vector<std::uint8_t>;
using Members = std::vector<Ptr>;

ToolsField();
virtual ~ToolsField() noexcept;
Expand Down Expand Up @@ -68,6 +68,10 @@ class CC_API ToolsField

void reset();

Members& getMembers();
const Members& getMembers() const;
void setMembers(Members&& members);

protected:
virtual const char* nameImpl() const = 0;
virtual std::size_t lengthImpl() const = 0;
Expand All @@ -78,6 +82,9 @@ class CC_API ToolsField
virtual Ptr upCloneImpl() = 0;
virtual bool canWriteImpl() const = 0;
virtual void resetImpl() = 0;

private:
Members m_members;
};

using ToolsFieldPtr = ToolsField::Ptr;
Expand Down
12 changes: 1 addition & 11 deletions lib/include/cc_tools_qt/field/ToolsArrayListField.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ class CC_API ToolsArrayListField : public ToolsField
{
public:

typedef std::vector<ToolsFieldPtr> Members;
typedef std::unique_ptr<ToolsArrayListField> ActPtr;
using ActPtr = std::unique_ptr<ToolsArrayListField>;

ToolsArrayListField();
ToolsArrayListField(const ToolsArrayListField&) = delete;
Expand All @@ -53,12 +52,6 @@ class CC_API ToolsArrayListField : public ToolsField

void adjustFixedSize();

Members& getMembers();

const Members& getMembers() const;

void setMembers(Members&& members);

ActPtr clone();

void refreshMembers();
Expand All @@ -78,9 +71,6 @@ class CC_API ToolsArrayListField : public ToolsField
virtual PrefixFieldInfo getPrefixFieldInfoImpl() const = 0;

void dispatchImpl(ToolsFieldHandler& handler);

private:
Members m_members;
};

using ToolsArrayListFieldPtr = ToolsArrayListField::ActPtr;
Expand Down
8 changes: 0 additions & 8 deletions lib/include/cc_tools_qt/field/ToolsBitfieldField.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ class CC_API ToolsBitfieldField : public cc_tools_qt::ToolsField
{
using Base = cc_tools_qt::ToolsField;
public:
using Members = std::vector<ToolsFieldPtr>;

using ActPtr = std::unique_ptr<ToolsBitfieldField>;

ToolsBitfieldField();
Expand All @@ -42,12 +40,6 @@ class CC_API ToolsBitfieldField : public cc_tools_qt::ToolsField

virtual ~ToolsBitfieldField() noexcept;

Members& getMembers();

const Members& getMembers() const;

void setMembers(Members&& members);

ActPtr clone();

protected:
Expand Down
10 changes: 0 additions & 10 deletions lib/include/cc_tools_qt/field/ToolsBundleField.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class CC_API ToolsBundleField : public ToolsField
{
using Base = ToolsField;
public:
using Members = std::vector<ToolsFieldPtr>;
using ActPtr = std::unique_ptr<ToolsBundleField>;

ToolsBundleField();
Expand All @@ -42,21 +41,12 @@ class CC_API ToolsBundleField : public ToolsField

virtual ~ToolsBundleField() noexcept;

Members& getMembers();

const Members& getMembers() const;

void setMembers(Members&& members);

ActPtr clone();

protected:
virtual ActPtr cloneImpl() = 0;

void dispatchImpl(ToolsFieldHandler& handler);

private:
Members m_members;
};

using ToolsBundleFieldPtr = ToolsBundleField::ActPtr;
Expand Down
161 changes: 6 additions & 155 deletions lib/include/cc_tools_qt/property/field.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ class CC_API Common
/// @brief Read the properties values from the provided map
void getFrom(const QVariantMap& props);

QVariantMap asMap() const;

protected:

/// @brief set element value to the map
Expand Down Expand Up @@ -242,81 +244,6 @@ class CC_API IntValue : public CommonBase<IntValue>
long long m_displayOffset = 0;
};

/// @brief Class to contain all the properties relevant to
/// @b comms::field::EnumValue fields.
/// @headerfile cc_tools_qt/property/field.h
class CC_API EnumValue : public CommonBase<EnumValue>
{
using Base = CommonBase<EnumValue>;
public:

/// @brief Default constructor
EnumValue();

/// @brief Copy constructor
EnumValue(const EnumValue&);

/// @brief Move constructor
EnumValue(EnumValue&&);

/// @brief Construct from QVariantMap
EnumValue(const QVariantMap& props);

/// @brief Construct from QVariant containing QVariantMap
EnumValue(const QVariant& props);

/// @brief Destructor
~EnumValue() noexcept;

/// @brief Copy assignement
EnumValue& operator=(const EnumValue&);

/// @brief Move assignment
EnumValue& operator=(EnumValue&&);

/// @brief Retrieve all properties as map.
QVariantMap asMap() const;
};

/// @brief Class to contain all the properties relevant to
/// @b comms::field::BitmaskValue fields.
/// @headerfile cc_tools_qt/property/field.h
class CC_API BitmaskValue : public CommonBase<BitmaskValue>
{
using Base = CommonBase<BitmaskValue>;
public:

/// @brief List of bits descriptions.
using BitsList = QVariantList;

/// @brief Default constructor
BitmaskValue();

/// @brief Copy constructor
BitmaskValue(const BitmaskValue&);

/// @brief Move constructor
BitmaskValue(BitmaskValue&&);

/// @brief Construct from QVariantMap
BitmaskValue(const QVariantMap& props);

/// @brief Construct from QVariant containing QVariantMap
BitmaskValue(const QVariant& props);

/// @brief Destructor
~BitmaskValue() noexcept;

/// @brief Copy assignment
BitmaskValue& operator=(const BitmaskValue&);

/// @brief Move assignment
BitmaskValue& operator=(BitmaskValue&&);

/// @brief Retrieve all properties as map.
QVariantMap asMap() const;
};

/// @brief Class to contain all the properties relevant to
/// @b comms::field::Bitfield fields.
/// @headerfile cc_tools_qt/property/field.h
Expand Down Expand Up @@ -421,41 +348,6 @@ class CC_API Bundle : public CommonBase<Bundle>
MembersList m_members;
};

/// @brief Class to contain all the properties relevant to
/// @b comms::field::String fields.
/// @headerfile cc_tools_qt/property/field.h
class CC_API String : public CommonBase<String>
{
typedef CommonBase<String> Base;
public:
/// @brief Default constructor
String();

/// @brief Copy constructor
String(const String&);

/// @brief Move constructor
String(String&&);

/// @brief Construct from QVariantMap
String(const QVariantMap& props);

/// @brief Construct from QVariant containing QVariantMap
String(const QVariant& props);

/// @brief Destructor
~String() noexcept;

/// @brief Copy assignment
String& operator=(const String&);

/// @brief Move assignement
String& operator=(String&&);

/// @brief Retrieve all properties as map.
QVariantMap asMap() const;
};

/// @brief Class to contain all the properties relevant to
/// @b comms::field::ArrayList fields.
/// @headerfile cc_tools_qt/property/field.h
Expand Down Expand Up @@ -590,47 +482,6 @@ class CC_API Optional : public CommonBase<Optional>
bool m_uncheckable = false;
};

/// @brief Class to contain all the properties relevant to
/// @b comms::field::FloatValue fields.
/// @headerfile cc_tools_qt/property/field.h
class CC_API FloatValue : public CommonBase<FloatValue>
{
typedef CommonBase<FloatValue> Base;
public:
/// @brief The special value is described as string containing name and
/// the actual numeric value.
using SpecialType = QPair<QString, double>;

/// @brief List of special values
using SpecialsList = QList<SpecialType>;

/// @brief Default constructor
FloatValue();

/// @brief Copy constructor
FloatValue(const FloatValue&);

/// @brief Move constructor
FloatValue(FloatValue&&);

/// @brief Construct from QVariantMap
FloatValue(const QVariantMap& props);

/// @brief Construct from QVariant containing QVariantMap
FloatValue(const QVariant& props);

/// @brief Destructor
~FloatValue() noexcept;

/// @brief Copy assignment
FloatValue& operator=(const FloatValue&);

/// @brief Move assignment
FloatValue& operator=(FloatValue&&);

/// @brief Retrieve all properties as map.
QVariantMap asMap() const;
};

/// @brief Class to contain all the properties relevant to
/// @b comms::field::Variant fields.
Expand Down Expand Up @@ -706,13 +557,13 @@ struct ForTag<comms::field::tag::Int>
template <>
struct ForTag<comms::field::tag::Enum>
{
typedef cc_tools_qt::property::field::EnumValue Type;
using Type = cc_tools_qt::property::field::Common;
};

template <>
struct ForTag<comms::field::tag::Bitmask>
{
typedef cc_tools_qt::property::field::BitmaskValue Type;
using Type = cc_tools_qt::property::field::Common;
};

template <>
Expand All @@ -730,7 +581,7 @@ struct ForTag<comms::field::tag::Bundle>
template <>
struct ForTag<comms::field::tag::String>
{
typedef cc_tools_qt::property::field::String Type;
using Type = cc_tools_qt::property::field::Common;
};

template <>
Expand All @@ -754,7 +605,7 @@ struct ForTag<comms::field::tag::Optional>
template <>
struct ForTag<comms::field::tag::Float>
{
typedef cc_tools_qt::property::field::FloatValue Type;
using Type = cc_tools_qt::property::field::Common;
};

template <>
Expand Down
Loading

0 comments on commit c44014b

Please sign in to comment.