0.2.0
Loading...
Searching...
No Matches
DynamicData.hpp
Go to the documentation of this file.
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
13
14#pragma once
15
16#include <vector>
17#include <string>
18
19#include "NodeData/NodeData.hpp"
20
21namespace NAV
22{
24class DynamicData : public NodeData
25{
26 public:
29 [[nodiscard]] static std::string type() { return "DynamicData"; }
30
33 [[nodiscard]] static std::vector<std::string> parentTypes()
34 {
35 return { NodeData::type() };
36 }
37
39 struct Data
40 {
41 std::string description;
42 double value;
43 std::vector<std::string> events;
44 };
45
47 std::vector<Data> data;
48
50 [[nodiscard]] std::vector<std::string> dynamicDataDescriptors() const override
51 {
52 std::vector<std::string> descriptors;
53 descriptors.reserve(data.size());
54
55 for (const auto& d : data)
56 {
57 descriptors.push_back(d.description);
58 }
59
60 return descriptors;
61 }
62
65 [[nodiscard]] std::optional<double> getDynamicDataAt(const std::string& descriptor) const override
66 {
67 for (const auto& d : data)
68 {
69 if (descriptor == d.description) { return d.value; }
70 }
71 return std::nullopt;
72 }
73
75 [[nodiscard]] std::vector<std::pair<std::string, double>> getDynamicData() const override
76 {
77 std::vector<std::pair<std::string, double>> dynData;
78 dynData.reserve(data.size());
79
80 for (const auto& d : data)
81 {
82 dynData.emplace_back(d.description, d.value);
83 }
84 return dynData;
85 }
86};
87
88} // namespace NAV
Abstract NodeData Class.
Dynamic Data container.
Definition DynamicData.hpp:25
std::optional< double > getDynamicDataAt(const std::string &descriptor) const override
Get the value for the descriptor.
Definition DynamicData.hpp:65
std::vector< std::pair< std::string, double > > getDynamicData() const override
Returns a vector of data descriptors and values for the dynamic data.
Definition DynamicData.hpp:75
static std::string type()
Returns the type of the data class.
Definition DynamicData.hpp:29
std::vector< std::string > dynamicDataDescriptors() const override
Returns a vector of data descriptors for the dynamic data.
Definition DynamicData.hpp:50
std::vector< Data > data
Data storage.
Definition DynamicData.hpp:47
static std::vector< std::string > parentTypes()
Returns the parent types of the data class.
Definition DynamicData.hpp:33
Parent class for all data transmitted over Flow pins.
Definition NodeData.hpp:27
static std::string type()
Returns the type of the data class.
Definition NodeData.hpp:44
Data struct.
Definition DynamicData.hpp:40
std::string description
Description.
Definition DynamicData.hpp:41
std::vector< std::string > events
List of events.
Definition DynamicData.hpp:43
double value
Value.
Definition DynamicData.hpp:42