0.2.0
Loading...
Searching...
No Matches
NodeData.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 <string>
17#include <vector>
18#include <optional>
19
21#include "util/Assert.h"
22
23namespace NAV
24{
27{
28 public:
30 NodeData() = default;
32 virtual ~NodeData() = default;
34 NodeData(const NodeData&) = default;
36 NodeData(NodeData&&) = default;
38 NodeData& operator=(const NodeData&) = default;
41
44 [[nodiscard]] static std::string type() { return "NodeData"; }
45
48 [[nodiscard]] static std::vector<std::string> parentTypes() { return {}; }
49
51 [[nodiscard]] static std::vector<std::string> GetStaticDataDescriptors() { return {}; }
52
54 [[nodiscard]] static constexpr size_t GetStaticDescriptorCount() { return 0; }
55
57 [[nodiscard]] virtual std::vector<std::string> staticDataDescriptors() const { return GetStaticDataDescriptors(); }
58
60 [[nodiscard]] virtual size_t staticDescriptorCount() const { return GetStaticDescriptorCount(); }
61
63 [[nodiscard]] const std::vector<std::string>& events() const { return _events; }
64
67 void addEvent(const std::string& text) { _events.push_back(text); }
68
71 [[nodiscard]] virtual std::optional<double> getValueAt(size_t /* idx */) const { return std::nullopt; }
72
76 [[nodiscard]] double getValueAtOrNaN(size_t idx) const { return getValueAt(idx).value_or(std::nan("")); }
77
79 [[nodiscard]] virtual std::vector<std::string> dynamicDataDescriptors() const { return {}; }
80
83 [[nodiscard]] virtual std::optional<double> getDynamicDataAt(const std::string& /* descriptor */) const { return std::nullopt; }
84
86 [[nodiscard]] virtual std::vector<std::pair<std::string, double>> getDynamicData() const { return {}; }
87
90
91 protected:
93 std::vector<std::string> _events;
94};
95
96} // namespace NAV
Assertion helpers.
The class is responsible for all time-related tasks.
The class is responsible for all time-related tasks.
Definition InsTime.hpp:667
Parent class for all data transmitted over Flow pins.
Definition NodeData.hpp:27
virtual std::vector< std::string > dynamicDataDescriptors() const
Returns a vector of data descriptors for the dynamic data.
Definition NodeData.hpp:79
virtual ~NodeData()=default
Destructor.
NodeData & operator=(NodeData &&)=default
Move assignment operator.
NodeData()=default
Default constructor.
NodeData(NodeData &&)=default
Move constructor.
virtual std::vector< std::pair< std::string, double > > getDynamicData() const
Returns a vector of data descriptors and values for the dynamic data.
Definition NodeData.hpp:86
void addEvent(const std::string &text)
Adds the event to the list.
Definition NodeData.hpp:67
static std::vector< std::string > GetStaticDataDescriptors()
Returns a vector of data descriptors.
Definition NodeData.hpp:51
std::vector< std::string > _events
List of events.
Definition NodeData.hpp:93
NodeData & operator=(const NodeData &)=default
Copy assignment operator.
static std::string type()
Returns the type of the data class.
Definition NodeData.hpp:44
static std::vector< std::string > parentTypes()
Returns the parent types of the data class.
Definition NodeData.hpp:48
virtual std::optional< double > getValueAt(size_t) const
Get the value at the index.
Definition NodeData.hpp:71
double getValueAtOrNaN(size_t idx) const
Get the value at the index or NaN if not in the observation.
Definition NodeData.hpp:76
const std::vector< std::string > & events() const
Returns a vector of string events associated with this data.
Definition NodeData.hpp:63
static constexpr size_t GetStaticDescriptorCount()
Get the amount of descriptors.
Definition NodeData.hpp:54
virtual std::vector< std::string > staticDataDescriptors() const
Returns a vector of data descriptors.
Definition NodeData.hpp:57
InsTime insTime
Time at which the message was received.
Definition NodeData.hpp:89
virtual std::optional< double > getDynamicDataAt(const std::string &) const
Get the value for the descriptor.
Definition NodeData.hpp:83
virtual size_t staticDescriptorCount() const
Get the amount of descriptors.
Definition NodeData.hpp:60
NodeData(const NodeData &)=default
Copy constructor.