-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Daniel Pelanek
committed
Jun 13, 2024
1 parent
0683e69
commit 6a756e6
Showing
2 changed files
with
62 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,17 @@ | ||
add_executable(test | ||
add_executable(test1 | ||
basicExample.cpp | ||
) | ||
|
||
target_link_libraries(test PRIVATE | ||
target_link_libraries(test1 PRIVATE | ||
telemetry::telemetry | ||
telemetry::appFs | ||
) | ||
|
||
add_executable(test2 | ||
variantsExample.cpp | ||
) | ||
|
||
target_link_libraries(test2 PRIVATE | ||
telemetry::telemetry | ||
telemetry::appFs | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#include <telemetry.hpp> | ||
#include <appFs.hpp> | ||
#include <memory> | ||
|
||
// example help | ||
#include <iostream> | ||
|
||
// Simplest type. Only contains one value . | ||
// The values can be of type std::monostate, bool, uint64_t, int64_t, double, std::string. | ||
telemetry::Scalar scalarReturn() { | ||
return telemetry::Scalar(static_cast<uint64_t>(100)); | ||
} | ||
|
||
// Contains not only scalar but also has a unit. | ||
// The unit is of type string. | ||
telemetry::ScalarWithUnit scalartWithUnitReturn() { | ||
return telemetry::ScalarWithUnit(static_cast<double>(42), "%"); | ||
} | ||
|
||
// Array is a vector of Scalars. | ||
telemetry::Array arrayReturn() { | ||
telemetry::Array arr; | ||
|
||
const uint64_t nScalars = 10; | ||
|
||
for(uint64_t index = 0; index < nScalars; index++) { | ||
arr.emplace_back(telemetry::Scalar(index)); | ||
} | ||
|
||
return arr; | ||
} | ||
|
||
// Dict is a map with string as a key. | ||
// Value can be std::monostate or any one of the three previous types | ||
telemetry::Dict dictReturn() { | ||
telemetry::Dict dict; | ||
|
||
dict["1"] = telemetry::Scalar(static_cast<int64_t>(10)); | ||
dict["2"] = telemetry::ScalarWithUnit(static_cast<bool>(10), "bool"); | ||
dict["3"] = telemetry::Array(std::vector<telemetry::Scalar>()); | ||
|
||
return dict; | ||
} | ||
|
||
int main() { | ||
// telemetry::Content can be easily printed or stored as string with contentToString() | ||
std::cout << telemetry::contentToString(scalarReturn()); | ||
std::cout << telemetry::contentToString(scalartWithUnitReturn()); | ||
std::cout << telemetry::contentToString(arrayReturn()); | ||
std::cout << telemetry::contentToString(dictReturn()); | ||
} |