INSTINCT Code Coverage Report


Directory: src/
File: NodeRegistry.hpp
Date: 2025-02-07 16:54:41
Exec Total Coverage
Lines: 2 2 100.0%
Functions: 1 1 100.0%
Branches: 0 0 -%

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 NodeRegistry.hpp
10 /// @brief Utility class which specifies available nodes
11 /// @author T. Topp (topp@ins.uni-stuttgart.de)
12 /// @date 2020-12-20
13
14 #pragma once
15
16 #include <string>
17 #include <memory>
18 #include <functional>
19 #include <vector>
20 #include <map>
21
22 #include "internal/Node/Pin.hpp"
23
24 namespace NAV
25 {
26 class Node;
27
28 namespace NodeRegistry
29 {
30 /// @brief Holds info of the pins of registered nodes
31 struct PinInfo
32 {
33 /// @brief Constructor
34 /// @param[in] kind Kind of the pin
35 /// @param[in] type Type of the pin
36 /// @param[in] dataIdentifier Identifiers supplied by the pin
37 12096 PinInfo(const Pin::Kind& kind, const Pin::Type& type, std::vector<std::string> dataIdentifier)
38 12096 : kind(kind), type(type), dataIdentifier(std::move(dataIdentifier)) {}
39
40 /// Kind of the Pin (Input/Output)
41 Pin::Kind kind = Pin::Kind::None;
42 /// Type of the Pin
43 Pin::Type type = Pin::Type::None;
44 /// One or multiple Data Identifiers (Unique name which is used for data flows)
45 std::vector<std::string> dataIdentifier;
46 };
47
48 /// @brief Holds information for registered nodes
49 struct NodeInfo
50 {
51 /// Constructor
52 std::function<Node*()> constructor;
53 /// Class Type of the node
54 std::string type;
55 /// List of port data types
56 std::vector<PinInfo> pinInfoList;
57
58 /// @brief Checks if the node has a pin which can be linked
59 /// @param[in] pin Pin to link to
60 [[nodiscard]] bool hasCompatiblePin(const Pin* pin) const;
61 };
62
63 /// @brief Reference to List of all registered Nodes
64 const std::map<std::string, std::vector<NodeInfo>>& RegisteredNodes();
65
66 /// @brief Checks if any of the provided child types is a child of any of the provided parent types
67 /// @param[in] childTypes Child types to check parentship
68 /// @param[in] parentTypes Parent types to check parentship
69 /// @return True if any of the child types is a child of any of the parent types
70 bool NodeDataTypeAnyIsChildOf(const std::vector<std::string>& childTypes, const std::vector<std::string>& parentTypes);
71
72 /// @brief Get the Parent Node Data Types of the specified Node Data Type
73 /// @param[in] type The Child Node Data Type
74 std::vector<std::string> GetParentNodeDataTypes(const std::string& type);
75
76 /// @brief Register all available Node types for the program
77 void RegisterNodeTypes();
78
79 /// @brief Register all available NodeData types for the program
80 void RegisterNodeDataTypes();
81
82 /// @brief Returns a vector of data descriptors for the pin data identifiers
83 /// @param dataIdentifier List of data identifiers
84 /// @return List of data descriptors
85 std::vector<std::string> GetStaticDataDescriptors(const std::vector<std::string>& dataIdentifier);
86
87 /// @brief Wether the specified Node Data Type can have dynamic data
88 /// @param[in] type The Child Node Data Type
89 bool TypeHasDynamicData(const std::string& type);
90
91 /// @brief Creates a copy of the data
92 /// @param nodeData Node data to copy
93 /// @return Copied data
94 std::shared_ptr<NodeData> CopyNodeData(const std::shared_ptr<const NodeData>& nodeData);
95
96 } // namespace NodeRegistry
97
98 } // namespace NAV
99