diff --git a/include/telemetry/aggFile.hpp b/include/telemetry/aggFile.hpp index daeff6c..c0b986b 100644 --- a/include/telemetry/aggFile.hpp +++ b/include/telemetry/aggFile.hpp @@ -61,7 +61,7 @@ class AggregatedFile : public File { FileOps getOps(); - const std::string m_filesRegexPattern; + const std::string M_FILES_REGEX_PATTERN; std::shared_ptr m_patternRootDir; std::vector m_paths; diff --git a/include/telemetry/aggMethod.hpp b/include/telemetry/aggMethod.hpp index 1368059..2fa5ad1 100644 --- a/include/telemetry/aggMethod.hpp +++ b/include/telemetry/aggMethod.hpp @@ -36,7 +36,9 @@ enum class AggMethodType { AVG, SUM, JOIN }; */ struct AggOperation { AggMethodType method; ///< Aggregation method + // NOLINTNEXTLINE(readability-redundant-string-init) std::string dictFieldName = ""; ///< Name of the field in the dictionary + // NOLINTNEXTLINE(readability-redundant-string-init) std::string dictResultName = ""; ///< Name of the field in the aggregated dictionary }; @@ -78,6 +80,9 @@ class AggMethod { protected: AggContent getAggContent(const Content& content, bool useDictResultName = false); + [[nodiscard]] std::string getDictResultName() const { return m_dictResultname; } + +private: std::string m_dictFieldName; std::string m_dictResultname; }; diff --git a/include/telemetry/node.hpp b/include/telemetry/node.hpp index e3fb096..e491bd9 100644 --- a/include/telemetry/node.hpp +++ b/include/telemetry/node.hpp @@ -64,9 +64,11 @@ class Node : public std::enable_shared_from_this { std::string getFullPath(); protected: - std::shared_ptr m_parent; + std::shared_ptr getParent() { return m_parent; }; private: + std::shared_ptr m_parent; + std::mutex m_mutex; std::string m_name; diff --git a/src/telemetry/aggFile.cpp b/src/telemetry/aggFile.cpp index 481dcdd..e62a5e1 100644 --- a/src/telemetry/aggFile.cpp +++ b/src/telemetry/aggFile.cpp @@ -119,10 +119,10 @@ Content AggregatedFile::read() if (m_patternRootDir) { patternRootDir = m_patternRootDir; } else { - patternRootDir = std::dynamic_pointer_cast(m_parent); + patternRootDir = std::dynamic_pointer_cast(getParent()); } - const auto files = getFilesMatchingPattern(m_filesRegexPattern, patternRootDir); + const auto files = getFilesMatchingPattern(M_FILES_REGEX_PATTERN, patternRootDir); if (files.empty()) { return content; } @@ -159,7 +159,7 @@ AggregatedFile::AggregatedFile( const std::vector& ops, std::shared_ptr patternRootDir) : File(parent, name, getOps()) - , m_filesRegexPattern(std::move(aggFilesPattern)) + , M_FILES_REGEX_PATTERN(std::move(aggFilesPattern)) , m_patternRootDir(std::move(patternRootDir)) { validateAggOperations(ops); diff --git a/src/telemetry/aggregator/aggCommon.hpp b/src/telemetry/aggregator/aggCommon.hpp index 8e61567..cb52238 100644 --- a/src/telemetry/aggregator/aggCommon.hpp +++ b/src/telemetry/aggregator/aggCommon.hpp @@ -69,7 +69,7 @@ static ScalarWithUnit getReferenceVariant(const std::vector& values) if (std::holds_alternative(values.front())) { for (const auto& value : values) { - const Array& array = std::get(value); + const auto& array = std::get(value); if (!array.empty()) { return {array.front(), ""}; } @@ -102,7 +102,7 @@ static bool containsSameScalarAlternative(const std::vector& values) return false; } - size_t refIndex = refScalar.index(); + const size_t refIndex = refScalar.index(); for (const auto& value : values) { if (std::holds_alternative(value)) { @@ -119,7 +119,7 @@ static bool containsSameScalarAlternative(const std::vector& values) return false; } } else if (std::holds_alternative(value)) { - const Array& array = std::get(value); + const auto& array = std::get(value); if (std::any_of(array.begin(), array.end(), [&](const auto& scalar) { return scalar.index() != refIndex; })) { diff --git a/src/telemetry/aggregator/aggJoin.cpp b/src/telemetry/aggregator/aggJoin.cpp index 0e9e2d5..408493b 100644 --- a/src/telemetry/aggregator/aggJoin.cpp +++ b/src/telemetry/aggregator/aggJoin.cpp @@ -61,7 +61,7 @@ Content AggMethodJoin::aggregate(const std::vector& contents) } const auto& result = aggregateGatheredValues(values); - return createContent(m_dictResultname, result); + return createContent(getDictResultName(), result); } } // namespace telemetry diff --git a/src/telemetry/aggregator/aggSum.cpp b/src/telemetry/aggregator/aggSum.cpp index be66ce6..8ec8c18 100644 --- a/src/telemetry/aggregator/aggSum.cpp +++ b/src/telemetry/aggregator/aggSum.cpp @@ -99,8 +99,9 @@ static Content createDictContent(const std::string& dictKey, const ResultType& r Content AggMethodSum::createContent(const ResultType& result) { - if (!m_dictResultname.empty()) { - return createDictContent(m_dictResultname, result); + const auto dictResultName = getDictResultName(); + if (!dictResultName.empty()) { + return createDictContent(dictResultName, result); } auto visitor = [&](const auto& arg) -> Content { return arg; };