| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // This file is part of INSTINCT, the INS Toolkit for Integrated | ||
| 2 | // Navigation Concepts and Training by the Institute of Navigation of | ||
| 3 | // the University of Stuttgart, Germany. | ||
| 4 | // | ||
| 5 | // This Source Code Form is subject to the terms of the Mozilla Public | ||
| 6 | // License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| 7 | // file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
| 8 | |||
| 9 | /// @file DynamicData.hpp | ||
| 10 | /// @brief Dynamic Data container | ||
| 11 | /// @author T. Topp (topp@ins.uni-stuttgart.de) | ||
| 12 | /// @date 2024-01-29 | ||
| 13 | |||
| 14 | #pragma once | ||
| 15 | |||
| 16 | #include <memory> | ||
| 17 | #include <vector> | ||
| 18 | #include <string> | ||
| 19 | |||
| 20 | #include "NodeData/NodeData.hpp" | ||
| 21 | |||
| 22 | namespace NAV | ||
| 23 | { | ||
| 24 | /// Dynamic Data container | ||
| 25 | class DynamicData : public NodeData | ||
| 26 | { | ||
| 27 | public: | ||
| 28 | /// @brief Returns the type of the data class | ||
| 29 | /// @return The data type | ||
| 30 |
1/2✓ Branch 1 taken 625109 times.
✗ Branch 2 not taken.
|
1875327 | [[nodiscard]] static std::string type() { return "DynamicData"; } |
| 31 | |||
| 32 | /// @brief Returns the type of the data class | ||
| 33 | /// @return The data type | ||
| 34 | ✗ | [[nodiscard]] std::string getType() const override { return type(); } | |
| 35 | |||
| 36 | /// @brief Returns the parent types of the data class | ||
| 37 | /// @return The parent data types | ||
| 38 | 114 | [[nodiscard]] static std::vector<std::string> parentTypes() | |
| 39 | { | ||
| 40 |
3/6✓ Branch 1 taken 114 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
✓ Branch 4 taken 114 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
342 | return { NodeData::type() }; |
| 41 | 114 | } | |
| 42 | |||
| 43 | /// Data struct | ||
| 44 | struct Data | ||
| 45 | { | ||
| 46 | std::string description; ///< Description | ||
| 47 | double value; ///< Value | ||
| 48 | std::vector<std::pair<std::string, std::shared_ptr<const NodeData>>> rawData; ///< List of raw data (used in this dynamic data) | ||
| 49 | }; | ||
| 50 | |||
| 51 | /// @brief Data storage | ||
| 52 | std::vector<Data> data; | ||
| 53 | |||
| 54 | /// @brief Returns a vector of data descriptors for the dynamic data | ||
| 55 | ✗ | [[nodiscard]] std::vector<std::string> dynamicDataDescriptors() const override | |
| 56 | { | ||
| 57 | ✗ | std::vector<std::string> descriptors; | |
| 58 | ✗ | descriptors.reserve(data.size()); | |
| 59 | |||
| 60 | ✗ | for (const auto& d : data) | |
| 61 | { | ||
| 62 | ✗ | descriptors.push_back(d.description); | |
| 63 | } | ||
| 64 | |||
| 65 | ✗ | return descriptors; | |
| 66 | ✗ | } | |
| 67 | |||
| 68 | /// @brief Get the value for the descriptor | ||
| 69 | /// @return Value if in the observation | ||
| 70 | ✗ | [[nodiscard]] std::optional<double> getDynamicDataAt(const std::string& descriptor) const override | |
| 71 | { | ||
| 72 | ✗ | for (const auto& d : data) | |
| 73 | { | ||
| 74 | ✗ | if (descriptor == d.description) { return d.value; } | |
| 75 | } | ||
| 76 | ✗ | return std::nullopt; | |
| 77 | } | ||
| 78 | |||
| 79 | /// @brief Returns a vector of data descriptors and values for the dynamic data | ||
| 80 | ✗ | [[nodiscard]] std::vector<std::pair<std::string, double>> getDynamicData() const override | |
| 81 | { | ||
| 82 | ✗ | std::vector<std::pair<std::string, double>> dynData; | |
| 83 | ✗ | dynData.reserve(data.size()); | |
| 84 | |||
| 85 | ✗ | for (const auto& d : data) | |
| 86 | { | ||
| 87 | ✗ | dynData.emplace_back(d.description, d.value); | |
| 88 | } | ||
| 89 | ✗ | return dynData; | |
| 90 | ✗ | } | |
| 91 | |||
| 92 | /// @brief Shows a GUI tooltip to look into details of the observation | ||
| 93 | /// @param[in] detailView Flag to show the detailed view | ||
| 94 | /// @param[in] firstOpen Flag whether the tooltip is opened once | ||
| 95 | /// @param[in] displayName Data identifier, can be used in dynamic data to identify the correct data | ||
| 96 | /// @param[in] id Unique identifier | ||
| 97 | /// @param[in] rootWindow Pointer to the root window opening the tooltip | ||
| 98 | void guiTooltip(bool detailView, bool firstOpen, const char* displayName, const char* id, int* rootWindow) const override; | ||
| 99 | |||
| 100 | /// @brief Return whether this data has a tooltip | ||
| 101 | ✗ | [[nodiscard]] bool hasTooltip() const override { return true; } | |
| 102 | }; | ||
| 103 | |||
| 104 | } // namespace NAV | ||
| 105 |