Skip to content

Commit

Permalink
telemetry - fix missing doxygen documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
SiskaPavel committed Oct 4, 2024
1 parent 3a4c8c4 commit bd618b5
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 18 deletions.
3 changes: 3 additions & 0 deletions include/telemetry/content.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ using Content = std::variant<Scalar, ScalarWithUnit, Array, Dict>;

/**
* @brief Convert telemetry @p content to human readable string.
*
* @param content Telemetry content
* @return Human readable string
*/
std::string contentToString(const Content& content);

Expand Down
7 changes: 7 additions & 0 deletions include/telemetry/directory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Directory> 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.
Expand All @@ -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
Expand Down
14 changes: 10 additions & 4 deletions include/telemetry/file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class Directory;
* Asynchronously called function implemented by a file. All functions are optional.
*/
struct FileOps {
std::function<Content()> read = nullptr;
std::function<void()> clear = nullptr;
std::function<Content()> read = nullptr; ///< Read operation
std::function<void()> clear = nullptr; ///< Clear operation
};

/**
Expand All @@ -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();

/**
Expand Down
5 changes: 4 additions & 1 deletion include/telemetry/holder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>& node);

/** @brief Disable callbacks of all held files. */
Expand Down
24 changes: 21 additions & 3 deletions include/telemetry/node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {};
};
Expand Down Expand Up @@ -56,11 +65,20 @@ class Node : public std::enable_shared_from_this<Node> {
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:
Expand Down
4 changes: 2 additions & 2 deletions src/telemetry/aggregator/aggAvg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Scalar>(aggContent)) {
makeAverage(std::get<Scalar>(aggContent), count);
Expand All @@ -50,7 +50,7 @@ Content AggMethodAvg::aggregate(const std::vector<Content>& 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);
}

Expand Down
6 changes: 3 additions & 3 deletions src/telemetry/aggregator/aggSum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ static ScalarWithUnit aggregateScalarWithUnit(std::vector<AggContent>& values)
return {result, unit};
}

static ResultType aggregateGatheredValues(std::vector<AggContent>& values)
static AggMethodSum::ResultType aggregateGatheredValues(std::vector<AggContent>& values)
{
if (std::holds_alternative<Scalar>(values.front())) {
return aggregateScalar(values);
Expand All @@ -87,7 +87,7 @@ static ResultType aggregateGatheredValues(std::vector<AggContent>& 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;

Expand All @@ -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()) {
Expand Down
7 changes: 5 additions & 2 deletions src/telemetry/aggregator/aggSum.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

namespace telemetry {

using ResultType = std::variant<Scalar, ScalarWithUnit>;

/**
* @brief Implementation of the SUM aggregation method.
*/
Expand All @@ -32,6 +30,11 @@ class AggMethodSum : public AggMethod {
*/
Content aggregate(const std::vector<Content>& contents) override;

/**
* @brief Get the result type of the aggregation
*/
using ResultType = std::variant<Scalar, ScalarWithUnit>;

protected:
Content createContent(const ResultType& result);
};
Expand Down
4 changes: 2 additions & 2 deletions src/telemetry/aggregator/tests/testAggAvg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Scalar>(result));
const auto& scalar = std::get<Scalar>(result);
EXPECT_EQ(0.5, std::get<double>(scalar));
Expand All @@ -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<ScalarWithUnit>(result));
const auto& [scalar, unit] = std::get<ScalarWithUnit>(result);
EXPECT_EQ(2.5, std::get<double>(scalar));
Expand Down
2 changes: 1 addition & 1 deletion src/telemetry/aggregator/tests/testAggSum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Dict>(content));
Expand Down

0 comments on commit bd618b5

Please sign in to comment.