diff --git a/include/telemetry/content.hpp b/include/telemetry/content.hpp index 74be8f5..40404fd 100644 --- a/include/telemetry/content.hpp +++ b/include/telemetry/content.hpp @@ -34,6 +34,9 @@ using Content = std::variant; /** * @brief Convert telemetry @p content to human readable string. + * + * @param content Telemetry content + * @return Human readable string */ std::string contentToString(const Content& content); diff --git a/include/telemetry/directory.hpp b/include/telemetry/directory.hpp index c3e3fc3..a675d92 100644 --- a/include/telemetry/directory.hpp +++ b/include/telemetry/directory.hpp @@ -37,12 +37,16 @@ class Directory : public Node { /** * @brief Construct an empty root directory. + * @return Shared pointer to the root directory */ [[nodiscard]] static std::shared_ptr create(); /** * @brief Add/Get a subdirectory with the given @p name. * + * @param name Name of the subdirectory + * @return Shared pointer to the subdirectory + * * If the subdirectory with the given name already exists, it will be returned. * Otherwise a new empty subdirectory will be created. If a file with the same name * already exists, the subdirectory cannot be created. @@ -69,6 +73,9 @@ class Directory : public Node { /** * @brief Add a new file with the given @p name and @p ops I/O operations. + * @param name Name of the file + * @param ops I/O operations + * @return Shared pointer to the newly created file * * @note * The directory only holds a weak pointer to the file, so if the returned pointer diff --git a/include/telemetry/file.hpp b/include/telemetry/file.hpp index 1b3da02..f587c21 100644 --- a/include/telemetry/file.hpp +++ b/include/telemetry/file.hpp @@ -25,8 +25,8 @@ class Directory; * Asynchronously called function implemented by a file. All functions are optional. */ struct FileOps { - std::function read = nullptr; - std::function clear = nullptr; + std::function read = nullptr; ///< Read operation + std::function clear = nullptr; ///< Clear operation }; /** @@ -53,9 +53,15 @@ class File : public Node { File(File&& other) = delete; File& operator=(File&& other) = delete; - /** Test whether the file supports read operation. */ + /** + * @brief Test whether the file supports read operation. + * @return True if the file supports read operation. + */ bool hasRead(); - /** Test whether the file supports clear operation. */ + /** + * @brief Test whether the file supports clear operation. + * @return True if the file supports clear operation. + */ bool hasClear(); /** diff --git a/include/telemetry/holder.hpp b/include/telemetry/holder.hpp index 9766d71..7e122e1 100644 --- a/include/telemetry/holder.hpp +++ b/include/telemetry/holder.hpp @@ -41,7 +41,10 @@ class Holder { Holder(Holder&& other) = default; Holder& operator=(Holder&& other) = default; - /** @brief Add a telemetry node. */ + /** + * @brief Add a telemetry node. + * @param node Node to add + */ void add(const std::shared_ptr& node); /** @brief Disable callbacks of all held files. */ diff --git a/include/telemetry/node.hpp b/include/telemetry/node.hpp index e491bd9..3ecc45e 100644 --- a/include/telemetry/node.hpp +++ b/include/telemetry/node.hpp @@ -21,8 +21,17 @@ namespace telemetry { */ class TelemetryException : public std::runtime_error { public: + /** + * @brief Construct a new exception with the given message. + * @param whatArg Message of the exception. + */ TelemetryException(const char* whatArg) : std::runtime_error(whatArg) {}; + + /** + * @brief Construct a new exception with the given message. + * @param whatArg Message of the exception. + */ TelemetryException(const std::string& whatArg) : std::runtime_error(whatArg) {}; }; @@ -56,11 +65,20 @@ class Node : public std::enable_shared_from_this { Node(Node&& other) = delete; Node& operator=(Node&& other) = delete; - /** @brief Get reference to the internal mutex. */ + /** + * @brief Get reference to the internal mutex. + * @return Reference to the internal mutex. + */ std::mutex& getMutex() { return m_mutex; }; - /** @brief Get the name of the node. */ + /** + * @brief Get the name of the node. + * @return Name of the node. + */ const std::string& getName() const noexcept { return m_name; }; - /** @brief Get full path from the root to this node (including this node name). */ + /** + * @brief Get full path from the root to this node (including this node name). + * @return Full path to this node. + */ std::string getFullPath(); protected: diff --git a/src/telemetry/aggregator/aggAvg.cpp b/src/telemetry/aggregator/aggAvg.cpp index 54289ac..2600860 100644 --- a/src/telemetry/aggregator/aggAvg.cpp +++ b/src/telemetry/aggregator/aggAvg.cpp @@ -29,7 +29,7 @@ static void makeAverage(Scalar& result, size_t count) } } -static ResultType convertToAverage(AggContent& aggContent, size_t count) +static AggMethodSum::ResultType convertToAverage(AggContent& aggContent, size_t count) { if (std::holds_alternative(aggContent)) { makeAverage(std::get(aggContent), count); @@ -50,7 +50,7 @@ Content AggMethodAvg::aggregate(const std::vector& contents) const Content aggregatedSum = AggMethodSum::aggregate(contents); const bool useDictResultNameAsKey = true; AggContent aggContent = getAggContent(aggregatedSum, useDictResultNameAsKey); - const ResultType result = convertToAverage(aggContent, contents.size()); + const AggMethodSum::ResultType result = convertToAverage(aggContent, contents.size()); return createContent(result); } diff --git a/src/telemetry/aggregator/aggSum.cpp b/src/telemetry/aggregator/aggSum.cpp index 8ec8c18..5f9d94c 100644 --- a/src/telemetry/aggregator/aggSum.cpp +++ b/src/telemetry/aggregator/aggSum.cpp @@ -74,7 +74,7 @@ static ScalarWithUnit aggregateScalarWithUnit(std::vector& values) return {result, unit}; } -static ResultType aggregateGatheredValues(std::vector& values) +static AggMethodSum::ResultType aggregateGatheredValues(std::vector& values) { if (std::holds_alternative(values.front())) { return aggregateScalar(values); @@ -87,7 +87,7 @@ static ResultType aggregateGatheredValues(std::vector& values) throw TelemetryException("Unexpected variant alternative."); } -static Content createDictContent(const std::string& dictKey, const ResultType& result) +static Content createDictContent(const std::string& dictKey, const AggMethodSum::ResultType& result) { Dict dict; @@ -97,7 +97,7 @@ static Content createDictContent(const std::string& dictKey, const ResultType& r return dict; } -Content AggMethodSum::createContent(const ResultType& result) +Content AggMethodSum::createContent(const AggMethodSum::ResultType& result) { const auto dictResultName = getDictResultName(); if (!dictResultName.empty()) { diff --git a/src/telemetry/aggregator/aggSum.hpp b/src/telemetry/aggregator/aggSum.hpp index bfa3ce1..6dbce7e 100644 --- a/src/telemetry/aggregator/aggSum.hpp +++ b/src/telemetry/aggregator/aggSum.hpp @@ -16,8 +16,6 @@ namespace telemetry { -using ResultType = std::variant; - /** * @brief Implementation of the SUM aggregation method. */ @@ -32,6 +30,11 @@ class AggMethodSum : public AggMethod { */ Content aggregate(const std::vector& contents) override; + /** + * @brief Get the result type of the aggregation + */ + using ResultType = std::variant; + protected: Content createContent(const ResultType& result); }; diff --git a/src/telemetry/aggregator/tests/testAggAvg.cpp b/src/telemetry/aggregator/tests/testAggAvg.cpp index 27a881c..29a5e80 100644 --- a/src/telemetry/aggregator/tests/testAggAvg.cpp +++ b/src/telemetry/aggregator/tests/testAggAvg.cpp @@ -53,7 +53,7 @@ TEST(AggAvgTest, convertToAverage) // Test converting Scalar to average { AggContent aggContent = Scalar {5.0}; - ResultType result = convertToAverage(aggContent, 10); + AggMethodSum::ResultType result = convertToAverage(aggContent, 10); EXPECT_TRUE(std::holds_alternative(result)); const auto& scalar = std::get(result); EXPECT_EQ(0.5, std::get(scalar)); @@ -62,7 +62,7 @@ TEST(AggAvgTest, convertToAverage) // Test converting ScalarWithUnit to average { AggContent aggContent = ScalarWithUnit {5.0, "unit"}; - ResultType result = convertToAverage(aggContent, 2); + AggMethodSum::ResultType result = convertToAverage(aggContent, 2); EXPECT_TRUE(std::holds_alternative(result)); const auto& [scalar, unit] = std::get(result); EXPECT_EQ(2.5, std::get(scalar)); diff --git a/src/telemetry/aggregator/tests/testAggSum.cpp b/src/telemetry/aggregator/tests/testAggSum.cpp index a2d3676..00604c0 100644 --- a/src/telemetry/aggregator/tests/testAggSum.cpp +++ b/src/telemetry/aggregator/tests/testAggSum.cpp @@ -107,7 +107,7 @@ TEST(AggSumTest, TestAggregateScalarWithUnit) */ TEST(AggSumTest, TestCreateDictContent) { - ResultType result = Scalar {uint64_t(30)}; + AggMethodSum::ResultType result = Scalar {uint64_t(30)}; Content content = createDictContent("sum", result); EXPECT_TRUE(std::holds_alternative(content));