From bb1be1d91d4edd799e8a5003a58d9ef880a6a4c4 Mon Sep 17 00:00:00 2001 From: Will Sobel Date: Mon, 9 Jun 2025 00:24:33 -0400 Subject: [PATCH 1/9] Checkpoint cleanup of data set implementation --- src/mtconnect/entity/data_set.hpp | 372 +++++++++++++----------------- 1 file changed, 158 insertions(+), 214 deletions(-) diff --git a/src/mtconnect/entity/data_set.hpp b/src/mtconnect/entity/data_set.hpp index abeb5f397..2bcc50e97 100644 --- a/src/mtconnect/entity/data_set.hpp +++ b/src/mtconnect/entity/data_set.hpp @@ -30,128 +30,153 @@ #include "mtconnect/utilities.hpp" namespace mtconnect::entity { - /// @brief Data Set Value type enumeration - enum class TabelCellType : std::uint16_t - { - EMPTY = 0x0, ///< monostate for no value - STRING = 0x02, ///< string value - INTEGER = 0x3, ///< 64 bit integer - DOUBLE = 0x4 ///< double - }; - - /// @brief Table Cell value variant - using TableCellValue = std::variant; - - /// @brief One entry in a data set. Has necessary interface to be work with maps. - struct TableCell - { - /// @brief Create an entry with a key and value - /// @param key the key - /// @param value the value as a string - TableCell(std::string key, std::string &value, bool removed = false) - : m_key(std::move(key)), m_value(std::move(value)), m_removed(removed) - {} - - /// @brief Create an entry for a data set - /// @param key the key - /// @param value the a data set variant - TableCell(std::string key, TableCellValue value, bool removed = false) - : m_key(std::move(key)), m_value(std::move(value)), m_removed(removed) - {} - - /// @brief Create a data set entry with just a key (used for search) - /// @param key - TableCell(std::string key) : m_key(std::move(key)), m_value(std::string("")) {} - TableCell(const TableCell &other) = default; - TableCell() {} - - /// @brief copy another table cell - /// @param other the other cell - TableCell &operator=(const TableCell &other) - { - m_key = other.m_key; - m_value = other.m_value; - m_removed = other.m_removed; - return *this; - } - - /// @brief only compares keys for equality - bool operator==(const TableCell &other) const { return m_key == other.m_key; } - /// @brief only compares keys for less than - bool operator<(const TableCell &other) const { return m_key < other.m_key; } - + namespace data_set { /// @brief helper visitor to compare variant values - struct SameValue + template + struct SameValueVisitor { /// @brief Construct the with a cell value to compare - SameValue(const TableCellValue &o) : m_other(o) {} - + SameValueVisitor(const T &o) : m_other(o) {} + /// @brief Compare the types are the same and the values are the same /// @tparam T the data type /// @param v the other value /// @return `true` if they are the same - template - bool operator()(const T &v) + template + bool operator()(const TV &v) { - return std::holds_alternative(m_other) && std::get(m_other) == v; + return std::holds_alternative(m_other) && std::get(m_other) == v; } - + /// @brief the other value to compare - const TableCellValue &m_other; + const T &m_other; }; - + /// @brief compares two cell values /// @param other the other cell value to compare - bool sameValue(const TableCell &other) const + template + struct SameValue { + bool operator()(const T &v1, const T &v2) + { + return std::visit(SameValueVisitor(v1), v2); + } + }; + + /// @brief One entry in a data set. Has necessary interface to be work with maps. + template> + struct Entry { - auto &ov = other.m_value; - return std::visit(SameValue(ov), m_value); - } - - /// @brief Compares to cells - /// @param other the other cell - bool same(const TableCell &other) const + /// @brief Create an entry with a key and value + /// @param key the key + /// @param value the value as a string + /// @param removed `true` if the key has been removed + Entry(std::string key, std::string &value, bool removed = false) + : m_key(std::move(key)), m_value(std::move(value)), m_removed(removed) + {} + + /// @brief Create an entry for a table with a data set value + /// @param key the key + /// @param value the value as a DataSet + /// @param removed `true` if the key has been removed + Entry(std::string key, Entry &value, bool removed = false) + : m_key(std::move(key)), m_value(std::move(value)), m_removed(removed) + {} + + /// @brief Create an entry for a data set + /// @param key the key + /// @param value the a data set variant + /// @param removed `true` if the key has been removed + Entry(std::string key, T value, bool removed = false) + : m_key(std::move(key)), m_value(std::move(value)), m_removed(removed) + {} + /// @brief Create a data set entry with just a key (used for search) + /// @param key + Entry(std::string key) + : m_key(std::move(key)), m_value(std::string("")), m_removed(false) + {} + Entry(const Entry &other) = default; + Entry() : m_removed(false) {} + + /// @brief copy a data set entry from another + Entry &operator=(const Entry &other) + { + m_key = other.m_key; + m_value = other.m_value; + m_removed = other.m_removed; + return *this; + } + + /// @brief only compares keys for equality + bool operator==(const Entry &other) const { return m_key == other.m_key; } + /// @brief only compares keys for less than + bool operator<(const Entry &other) const { return m_key < other.m_key; } + + bool sameValue(const Entry &other) const + { + const auto &ov = other.m_value; + return SV()(m_value, ov); + } + + /// @brief compare a data entry ewith another + bool same(const Entry &other) const + { + return m_key == other.m_key && m_removed == other.m_removed && sameValue(other); + } + + std::string m_key; + T m_value; + bool m_removed; + }; + + /// @brief A set of data set entries + template + class AGENT_LIB_API Set : public std::set { - return m_key == other.m_key && m_removed == other.m_removed && sameValue(other); - } - - std::string m_key; - TableCellValue m_value; - bool m_removed {false}; - }; - - /// @brief A set of data set entries - class AGENT_LIB_API TableRow : public std::set + public: + using base = std::set; + using base::base; + + /// @brief Get a entry for a key + /// @tparam T the entry type + /// @param key the key + /// @return the typed value of the entry + template + const T &get(const std::string &key) const + { + return std::get(find(ET(key))->m_value); + } + + /// @brief Get a entry for a key if it exists + /// @tparam T the entry type + /// @param key the key + /// @return optional typed value of the entry + template + const std::optional maybeGet(const std::string &key) const + { + auto v = find(ET(key)); + if (v == this->end()) + return std::nullopt; + else + return std::get(v->m_value); + } + }; + } + + /// @brief Data Set Value type enumeration + enum class TabelCellType : std::uint16_t { - public: - using base = std::set; - using base::base; - - /// @brief Get a entry for a key - /// @tparam T the entry type - /// @param key the key - /// @return the typed value of the entry - template - const T &get(const std::string &key) const - { - return std::get(find(TableCell(key))->m_value); - } - - /// @brief Get a entry for a key if it exists - /// @tparam T the entry type - /// @param key the key - /// @return optional typed value of the entry - template - const std::optional maybeGet(const std::string &key) const - { - auto v = find(TableCell(key)); - if (v == end()) - return std::nullopt; - else - return std::get(v->m_value); - } + EMPTY = 0x0, ///< monostate for no value + STRING = 0x02, ///< string value + INTEGER = 0x3, ///< 64 bit integer + DOUBLE = 0x4 ///< double }; + /// @brief Table Cell value variant + using TableCellValue = std::variant; + + using TableCell = data_set::Entry; + using TableRow = data_set::Set; + /// @brief Data Set Value type enumeration enum class DataSetValueType : std::uint16_t { @@ -164,104 +189,11 @@ namespace mtconnect::entity { /// @brief Data set value variant using DataSetValue = std::variant; - - /// @brief One entry in a data set. Has necessary interface to be work with maps. - struct DataSetEntry - { - /// @brief Create an entry with a key and value - /// @param key the key - /// @param value the value as a string - /// @param removed `true` if the key has been removed - DataSetEntry(std::string key, std::string &value, bool removed = false) - : m_key(std::move(key)), m_value(std::move(value)), m_removed(removed) - {} - - /// @brief Create an entry for a table with a data set value - /// @param key the key - /// @param value the value as a DataSet - /// @param removed `true` if the key has been removed - DataSetEntry(std::string key, TableRow &value, bool removed = false) - : m_key(std::move(key)), m_value(std::move(value)), m_removed(removed) - {} - - /// @brief Create an entry for a data set - /// @param key the key - /// @param value the a data set variant - /// @param removed `true` if the key has been removed - DataSetEntry(std::string key, DataSetValue value, bool removed = false) - : m_key(std::move(key)), m_value(std::move(value)), m_removed(removed) - {} - /// @brief Create a data set entry with just a key (used for search) - /// @param key - DataSetEntry(std::string key) - : m_key(std::move(key)), m_value(std::string("")), m_removed(false) - {} - DataSetEntry(const DataSetEntry &other) = default; - DataSetEntry() : m_removed(false) {} - - /// @brief copy a data set entry from another - DataSetEntry &operator=(const DataSetEntry &other) - { - m_key = other.m_key; - m_value = other.m_value; - m_removed = other.m_removed; - return *this; - } - - /// @brief only compares keys for equality - bool operator==(const DataSetEntry &other) const { return m_key == other.m_key; } - /// @brief only compares keys for less than - bool operator<(const DataSetEntry &other) const { return m_key < other.m_key; } - - /// @brief compare a data entry ewith another - bool same(const DataSetEntry &other) const; - - std::string m_key; - DataSetValue m_value; - bool m_removed; - }; - - /// @brief A set of data set entries - class AGENT_LIB_API DataSet : public std::set + + struct DataSetValueSameVisitor : public data_set::SameValueVisitor { - public: - using base = std::set; - using base::base; - - /// @brief Get a entry for a key - /// @tparam T the entry type - /// @param key the key - /// @return the typed value of the entry - template - const T &get(const std::string &key) const - { - return std::get(find(DataSetEntry(key))->m_value); - } - - /// @brief Get a entry for a key if it exists - /// @tparam T the entry type - /// @param key the key - /// @return optional typed value of the entry - template - const std::optional maybeGet(const std::string &key) const - { - auto v = find(DataSetEntry(key)); - if (v == end()) - return std::nullopt; - else - return std::get(v->m_value); - } - - /// @brief Split the data set entries by space delimiters and account for the - /// use of single and double quotes as well as curly braces - bool parse(const std::string &s, bool table); - }; - - /// @brief Equality visitor for a DataSetValue - struct DataSetValueSame - { - DataSetValueSame(const DataSetValue &other) : m_other(other) {} - + using data_set::SameValueVisitor::SameValueVisitor; + /// @brief Compare two table rows and see if the are the same /// @param v The other value /// @return `true ` if they are the same @@ -269,38 +201,50 @@ namespace mtconnect::entity { { if (!std::holds_alternative(m_other)) return false; - + const auto &oset = std::get(m_other); - + if (v.size() != oset.size()) return false; - + for (const auto &e1 : v) { const auto &e2 = oset.find(e1); if (e2 == oset.end() || !e2->sameValue(e1)) return false; } - + return true; } - + /// @brief Compare the types are the same and the values are the same /// @tparam T the data type /// @param v the other value /// @return `true` if they are the same - template - bool operator()(const T &v) + template + bool operator()(const TV &v) { - return std::holds_alternative(m_other) && std::get(m_other) == v; + return std::holds_alternative(m_other) && std::get(m_other) == v; } - const DataSetValue &m_other; //! the other data set value + }; + + struct DataSetEntrySame { + bool operator ()(const DataSetValue &v1, const DataSetValue &v2) const + { + return std::visit(DataSetValueSameVisitor(v1), v2); + } }; - inline bool DataSetEntry::same(const DataSetEntry &other) const + /// @brief One entry in a data set. Has necessary interface to be work with maps. + using DataSetEntry = data_set::Entry; + + /// @brief A set of data set entries + class DataSet : public data_set::Set { - return m_key == other.m_key && m_removed == other.m_removed && - std::visit(DataSetValueSame(other.m_value), m_value); - } + public: + /// @brief Split the data set entries by space delimiters and account for the + /// use of single and double quotes as well as curly braces + bool parse(const std::string &s, bool table); + }; } // namespace mtconnect::entity From 89c009e0fd86315b4a6cafe15e0c1914f69703e1 Mon Sep 17 00:00:00 2001 From: Will Sobel Date: Mon, 9 Jun 2025 10:37:05 -0400 Subject: [PATCH 2/9] Checkpoint with copied visitor --- src/mtconnect/entity/data_set.hpp | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/src/mtconnect/entity/data_set.hpp b/src/mtconnect/entity/data_set.hpp index 2bcc50e97..bdb034b36 100644 --- a/src/mtconnect/entity/data_set.hpp +++ b/src/mtconnect/entity/data_set.hpp @@ -51,19 +51,9 @@ namespace mtconnect::entity { /// @brief the other value to compare const T &m_other; }; - - /// @brief compares two cell values - /// @param other the other cell value to compare - template - struct SameValue { - bool operator()(const T &v1, const T &v2) - { - return std::visit(SameValueVisitor(v1), v2); - } - }; - + /// @brief One entry in a data set. Has necessary interface to be work with maps. - template> + template> struct Entry { /// @brief Create an entry with a key and value @@ -114,7 +104,7 @@ namespace mtconnect::entity { bool sameValue(const Entry &other) const { const auto &ov = other.m_value; - return SV()(m_value, ov); + return std::visit(SV(m_value), ov); } /// @brief compare a data entry ewith another @@ -229,15 +219,8 @@ namespace mtconnect::entity { }; - struct DataSetEntrySame { - bool operator ()(const DataSetValue &v1, const DataSetValue &v2) const - { - return std::visit(DataSetValueSameVisitor(v1), v2); - } - }; - /// @brief One entry in a data set. Has necessary interface to be work with maps. - using DataSetEntry = data_set::Entry; + using DataSetEntry = data_set::Entry; /// @brief A set of data set entries class DataSet : public data_set::Set From f26ea6a4c60169188bd0bbcb1bd24bed00345be1 Mon Sep 17 00:00:00 2001 From: Will Sobel Date: Mon, 9 Jun 2025 12:09:57 -0400 Subject: [PATCH 3/9] Checkpoint with full test suite --- src/mtconnect/entity/data_set.hpp | 109 ++++++++++++++++++------------ 1 file changed, 66 insertions(+), 43 deletions(-) diff --git a/src/mtconnect/entity/data_set.hpp b/src/mtconnect/entity/data_set.hpp index bdb034b36..e8a0ba150 100644 --- a/src/mtconnect/entity/data_set.hpp +++ b/src/mtconnect/entity/data_set.hpp @@ -32,12 +32,13 @@ namespace mtconnect::entity { namespace data_set { /// @brief helper visitor to compare variant values - template + /// @tparam T The type of the underlying data + template struct SameValueVisitor { /// @brief Construct the with a cell value to compare SameValueVisitor(const T &o) : m_other(o) {} - + /// @brief Compare the types are the same and the values are the same /// @tparam T the data type /// @param v the other value @@ -47,46 +48,55 @@ namespace mtconnect::entity { { return std::holds_alternative(m_other) && std::get(m_other) == v; } - + /// @brief the other value to compare const T &m_other; }; - + /// @brief One entry in a data set. Has necessary interface to be work with maps. - template> + /// @tparam T The type of the underlying data + /// @tparam SV The visitor to compare values of the entry + template > struct Entry { /// @brief Create an entry with a key and value /// @param key the key /// @param value the value as a string /// @param removed `true` if the key has been removed - Entry(std::string key, std::string &value, bool removed = false) - : m_key(std::move(key)), m_value(std::move(value)), m_removed(removed) + Entry(const std::string &key, std::string &value, bool removed = false) + : m_key(key), m_value(std::move(value)), m_removed(removed) {} + /// @brief Create an entry with a key and value + /// @param key the key + /// @param value the value as a string + /// @param removed `true` if the key has been removed + Entry(std::string &&key, std::string &value, bool removed = false) + : m_key(std::move(key)), m_value(std::move(value)), m_removed(removed) + {} + + /// @brief Create an entry for a table with a data set value /// @param key the key /// @param value the value as a DataSet /// @param removed `true` if the key has been removed - Entry(std::string key, Entry &value, bool removed = false) - : m_key(std::move(key)), m_value(std::move(value)), m_removed(removed) + Entry(const std::string &key, Entry &value, bool removed = false) + : m_key(key), m_value(std::move(value)), m_removed(removed) {} - + /// @brief Create an entry for a data set /// @param key the key /// @param value the a data set variant /// @param removed `true` if the key has been removed - Entry(std::string key, T value, bool removed = false) - : m_key(std::move(key)), m_value(std::move(value)), m_removed(removed) + Entry(const std::string &key, T value, bool removed = false) + : m_key(key), m_value(std::move(value)), m_removed(removed) {} /// @brief Create a data set entry with just a key (used for search) /// @param key - Entry(std::string key) - : m_key(std::move(key)), m_value(std::string("")), m_removed(false) - {} + Entry(const std::string &key) : m_key(key), m_removed(false) {} Entry(const Entry &other) = default; Entry() : m_removed(false) {} - + /// @brief copy a data set entry from another Entry &operator=(const Entry &other) { @@ -95,37 +105,41 @@ namespace mtconnect::entity { m_removed = other.m_removed; return *this; } - + /// @brief only compares keys for equality bool operator==(const Entry &other) const { return m_key == other.m_key; } /// @brief only compares keys for less than bool operator<(const Entry &other) const { return m_key < other.m_key; } - + + /// @brief Compares the values of the entiry + /// @param other the other value to compare against `m_value` bool sameValue(const Entry &other) const { const auto &ov = other.m_value; return std::visit(SV(m_value), ov); } - + /// @brief compare a data entry ewith another + /// @param other the other entry to compare bool same(const Entry &other) const { return m_key == other.m_key && m_removed == other.m_removed && sameValue(other); } - - std::string m_key; - T m_value; - bool m_removed; + + std::string m_key; ///< The key of the entry + T m_value; ///< The value of the entry + bool m_removed; ///< boolean indicator if this entry is removed. }; - + /// @brief A set of data set entries - template + /// @tparam EV the entry type for the set, must have < operator. + template class AGENT_LIB_API Set : public std::set { public: using base = std::set; using base::base; - + /// @brief Get a entry for a key /// @tparam T the entry type /// @param key the key @@ -133,9 +147,13 @@ namespace mtconnect::entity { template const T &get(const std::string &key) const { - return std::get(find(ET(key))->m_value); + auto v = base::find(ET(key)); + if (v == this->end()) + throw std::logic_error("DataSet get: key not found '" + key + "'"); + else + return std::get(v->m_value); } - + /// @brief Get a entry for a key if it exists /// @tparam T the entry type /// @param key the key @@ -143,15 +161,15 @@ namespace mtconnect::entity { template const std::optional maybeGet(const std::string &key) const { - auto v = find(ET(key)); + auto v = base::find(ET(key)); if (v == this->end()) return std::nullopt; else return std::get(v->m_value); } }; - } - + } // namespace data_set + /// @brief Data Set Value type enumeration enum class TabelCellType : std::uint16_t { @@ -163,7 +181,7 @@ namespace mtconnect::entity { /// @brief Table Cell value variant using TableCellValue = std::variant; - + using TableCell = data_set::Entry; using TableRow = data_set::Set; @@ -179,11 +197,12 @@ namespace mtconnect::entity { /// @brief Data set value variant using DataSetValue = std::variant; - - struct DataSetValueSameVisitor : public data_set::SameValueVisitor + + /// @brief A visitor that handles table values + struct DataSetValueSameVisitor { - using data_set::SameValueVisitor::SameValueVisitor; - + DataSetValueSameVisitor(const DataSetValue &o) : m_other(o) {} + /// @brief Compare two table rows and see if the are the same /// @param v The other value /// @return `true ` if they are the same @@ -191,22 +210,22 @@ namespace mtconnect::entity { { if (!std::holds_alternative(m_other)) return false; - + const auto &oset = std::get(m_other); - + if (v.size() != oset.size()) return false; - + for (const auto &e1 : v) { const auto &e2 = oset.find(e1); if (e2 == oset.end() || !e2->sameValue(e1)) return false; } - + return true; } - + /// @brief Compare the types are the same and the values are the same /// @tparam T the data type /// @param v the other value @@ -217,15 +236,19 @@ namespace mtconnect::entity { return std::holds_alternative(m_other) && std::get(m_other) == v; } + const DataSetValue &m_other; ///< The other value to compare }; - + /// @brief One entry in a data set. Has necessary interface to be work with maps. using DataSetEntry = data_set::Entry; - + /// @brief A set of data set entries class DataSet : public data_set::Set { public: + using base = data_set::Set; + using base::base; + /// @brief Split the data set entries by space delimiters and account for the /// use of single and double quotes as well as curly braces bool parse(const std::string &s, bool table); From a8b641f54f2c7b8b8d3ff052187ba57edc453221 Mon Sep 17 00:00:00 2001 From: Will Sobel Date: Mon, 9 Jun 2025 12:37:57 -0400 Subject: [PATCH 4/9] Use overloaded function for sameness and doced --- src/mtconnect/entity/data_set.hpp | 96 ++++++++++++++++--------------- 1 file changed, 51 insertions(+), 45 deletions(-) diff --git a/src/mtconnect/entity/data_set.hpp b/src/mtconnect/entity/data_set.hpp index e8a0ba150..a57639407 100644 --- a/src/mtconnect/entity/data_set.hpp +++ b/src/mtconnect/entity/data_set.hpp @@ -30,7 +30,25 @@ #include "mtconnect/utilities.hpp" namespace mtconnect::entity { + + /// @brief the namespace to hold the inner abstract templates of the data set namespace data_set { + /// @brief Compares two values where the first is a variant and the second is a variant value + /// using == + /// @tparam T1 The variant type + /// @tparam T2 The value type + /// @param v1 The variant + /// @param v2 The value to match against + /// + /// This method should be overloaded in the data_set namespace to implement types that + /// do not have a simple `==` method. The method first makes sure the types are the same and + /// then compares using `==`. + template + inline bool SameValue(const T1 &v1, const T2 &v2) + { + return std::holds_alternative(v1) && std::get(v1) == v2; + } + /// @brief helper visitor to compare variant values /// @tparam T The type of the underlying data template @@ -46,7 +64,7 @@ namespace mtconnect::entity { template bool operator()(const TV &v) { - return std::holds_alternative(m_other) && std::get(m_other) == v; + return SameValue(m_other, v); } /// @brief the other value to compare @@ -66,16 +84,15 @@ namespace mtconnect::entity { Entry(const std::string &key, std::string &value, bool removed = false) : m_key(key), m_value(std::move(value)), m_removed(removed) {} - + /// @brief Create an entry with a key and value /// @param key the key /// @param value the value as a string /// @param removed `true` if the key has been removed Entry(std::string &&key, std::string &value, bool removed = false) - : m_key(std::move(key)), m_value(std::move(value)), m_removed(removed) + : m_key(std::move(key)), m_value(std::move(value)), m_removed(removed) {} - /// @brief Create an entry for a table with a data set value /// @param key the key /// @param value the value as a DataSet @@ -182,65 +199,54 @@ namespace mtconnect::entity { /// @brief Table Cell value variant using TableCellValue = std::variant; + /// @brief A table cell which is an entry with table cell values using TableCell = data_set::Entry; - using TableRow = data_set::Set; - - /// @brief Data Set Value type enumeration - enum class DataSetValueType : std::uint16_t - { - EMPTY = 0x0, ///< monostate for no value - TABLE_ROW = 0x01, ///< data set member for tables - STRING = 0x02, ///< string value - INTEGER = 0x3, ///< 64 bit integer - DOUBLE = 0x4 ///< double - }; - - /// @brief Data set value variant - using DataSetValue = std::variant; - /// @brief A visitor that handles table values - struct DataSetValueSameVisitor - { - DataSetValueSameVisitor(const DataSetValue &o) : m_other(o) {} + /// @brief A table row as a data set of table cells + using TableRow = data_set::Set; - /// @brief Compare two table rows and see if the are the same - /// @param v The other value - /// @return `true ` if they are the same - bool operator()(const TableRow &v) + namespace data_set { + /// @brief Compare a data set entry against a table row + /// @tparam T1 The type of the other variant + /// @param v1 The value of the other variant + /// @param row The row we're comparing + template + inline bool SameValue(const T1 &v1, const TableRow &row) { - if (!std::holds_alternative(m_other)) + if (!std::holds_alternative(v1)) return false; - const auto &oset = std::get(m_other); + const auto &orow = std::get(v1); - if (v.size() != oset.size()) + if (row.size() != orow.size()) return false; - for (const auto &e1 : v) + for (const auto &c1 : row) { - const auto &e2 = oset.find(e1); - if (e2 == oset.end() || !e2->sameValue(e1)) + const auto &c2 = orow.find(c1); + if (c2 == orow.end() || !c2->sameValue(c1)) return false; } return true; } + } // namespace data_set - /// @brief Compare the types are the same and the values are the same - /// @tparam T the data type - /// @param v the other value - /// @return `true` if they are the same - template - bool operator()(const TV &v) - { - return std::holds_alternative(m_other) && std::get(m_other) == v; - } - - const DataSetValue &m_other; ///< The other value to compare + /// @brief Data Set Value type enumeration + enum class DataSetValueType : std::uint16_t + { + EMPTY = 0x0, ///< monostate for no value + TABLE_ROW = 0x01, ///< data set member for tables + STRING = 0x02, ///< string value + INTEGER = 0x3, ///< 64 bit integer + DOUBLE = 0x4 ///< double }; + /// @brief Data set value variant + using DataSetValue = std::variant; + /// @brief One entry in a data set. Has necessary interface to be work with maps. - using DataSetEntry = data_set::Entry; + using DataSetEntry = data_set::Entry; /// @brief A set of data set entries class DataSet : public data_set::Set @@ -248,7 +254,7 @@ namespace mtconnect::entity { public: using base = data_set::Set; using base::base; - + /// @brief Split the data set entries by space delimiters and account for the /// use of single and double quotes as well as curly braces bool parse(const std::string &s, bool table); From c04d2d8b710a8c83154cd6bdee865b1d06ab6d3a Mon Sep 17 00:00:00 2001 From: Will Sobel Date: Mon, 9 Jun 2025 12:53:02 -0400 Subject: [PATCH 5/9] Version 2.5.0.10 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 409f8f634..2cb3527f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ set(AGENT_VERSION_MAJOR 2) set(AGENT_VERSION_MINOR 5) set(AGENT_VERSION_PATCH 0) -set(AGENT_VERSION_BUILD 9) +set(AGENT_VERSION_BUILD 10) set(AGENT_VERSION_RC "") # This minimum version is to support Visual Studio 2019 and C++ feature checking and FetchContent From 22c9bdceebbe54c5d81ef6517c65db0e75643651 Mon Sep 17 00:00:00 2001 From: Will Sobel Date: Mon, 9 Jun 2025 13:42:51 -0400 Subject: [PATCH 6/9] Upgraded doxygen to version 1.14 --- conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conanfile.py b/conanfile.py index 0a4bfd368..3a10a0633 100644 --- a/conanfile.py +++ b/conanfile.py @@ -115,7 +115,7 @@ def tool_requires_version(self, package, version): def build_requirements(self): self.tool_requires_version("cmake", [3, 26, 4]) if self.options.with_docs: - self.tool_requires_version("doxygen", [1, 9, 4]) + self.tool_requires_version("doxygen", [1, 14, 0]) def requirements(self): self.requires("boost/1.85.0", headers=True, libs=True, transitive_headers=True, transitive_libs=True) From e4d6fc776a252f7ef3ddc4fcb610c09ae822da7b Mon Sep 17 00:00:00 2001 From: Will Sobel Date: Mon, 9 Jun 2025 14:29:31 -0400 Subject: [PATCH 7/9] For data set, removed visitor and replaced with a lambda --- src/mtconnect/entity/data_set.hpp | 35 +++++++------------------------ 1 file changed, 8 insertions(+), 27 deletions(-) diff --git a/src/mtconnect/entity/data_set.hpp b/src/mtconnect/entity/data_set.hpp index a57639407..9e95258ae 100644 --- a/src/mtconnect/entity/data_set.hpp +++ b/src/mtconnect/entity/data_set.hpp @@ -48,33 +48,10 @@ namespace mtconnect::entity { { return std::holds_alternative(v1) && std::get(v1) == v2; } - - /// @brief helper visitor to compare variant values - /// @tparam T The type of the underlying data - template - struct SameValueVisitor - { - /// @brief Construct the with a cell value to compare - SameValueVisitor(const T &o) : m_other(o) {} - - /// @brief Compare the types are the same and the values are the same - /// @tparam T the data type - /// @param v the other value - /// @return `true` if they are the same - template - bool operator()(const TV &v) - { - return SameValue(m_other, v); - } - - /// @brief the other value to compare - const T &m_other; - }; - + /// @brief One entry in a data set. Has necessary interface to be work with maps. - /// @tparam T The type of the underlying data - /// @tparam SV The visitor to compare values of the entry - template > + /// @tparam T The type of the underlying variant data + template struct Entry { /// @brief Create an entry with a key and value @@ -130,10 +107,14 @@ namespace mtconnect::entity { /// @brief Compares the values of the entiry /// @param other the other value to compare against `m_value` + /// @returns `true` if the values are the same + /// + /// Compares using the `SameValue` free function in the `data_set` namespace. It must be overloaded + /// for any special types required by the variant type T. bool sameValue(const Entry &other) const { const auto &ov = other.m_value; - return std::visit(SV(m_value), ov); + return std::visit([&ov](const auto &v) { return SameValue(ov, v); }, m_value); } /// @brief compare a data entry ewith another From 1fcb513947ff5fb03e11d921d5aaaf79c24c794c Mon Sep 17 00:00:00 2001 From: Will Sobel Date: Mon, 9 Jun 2025 15:11:34 -0400 Subject: [PATCH 8/9] Need to export DataSet for Windwows shared build --- src/mtconnect/entity/data_set.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mtconnect/entity/data_set.hpp b/src/mtconnect/entity/data_set.hpp index 9e95258ae..e07e300a9 100644 --- a/src/mtconnect/entity/data_set.hpp +++ b/src/mtconnect/entity/data_set.hpp @@ -52,7 +52,7 @@ namespace mtconnect::entity { /// @brief One entry in a data set. Has necessary interface to be work with maps. /// @tparam T The type of the underlying variant data template - struct Entry + struct AGENT_LIB_API Entry { /// @brief Create an entry with a key and value /// @param key the key @@ -230,7 +230,7 @@ namespace mtconnect::entity { using DataSetEntry = data_set::Entry; /// @brief A set of data set entries - class DataSet : public data_set::Set + class AGENT_LIB_API DataSet : public data_set::Set { public: using base = data_set::Set; From 726ec8b051fdea342d6ae797d0b760c0bdba38a4 Mon Sep 17 00:00:00 2001 From: Will Sobel Date: Mon, 9 Jun 2025 15:36:16 -0400 Subject: [PATCH 9/9] Fixed linking issue on Winddows shared --- src/mtconnect/entity/data_set.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mtconnect/entity/data_set.hpp b/src/mtconnect/entity/data_set.hpp index e07e300a9..55e35631c 100644 --- a/src/mtconnect/entity/data_set.hpp +++ b/src/mtconnect/entity/data_set.hpp @@ -52,7 +52,7 @@ namespace mtconnect::entity { /// @brief One entry in a data set. Has necessary interface to be work with maps. /// @tparam T The type of the underlying variant data template - struct AGENT_LIB_API Entry + struct Entry { /// @brief Create an entry with a key and value /// @param key the key @@ -132,7 +132,7 @@ namespace mtconnect::entity { /// @brief A set of data set entries /// @tparam EV the entry type for the set, must have < operator. template - class AGENT_LIB_API Set : public std::set + class Set : public std::set { public: using base = std::set;