0.4.1
Loading...
Searching...
No Matches
NodeRegistry.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
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
24namespace NAV
25{
26class Node;
27
28namespace NodeRegistry
29{
30/// @brief Holds info of the pins of registered nodes
31struct 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 PinInfo(const Pin::Kind& kind, const Pin::Type& type, std::vector<std::string> dataIdentifier)
39
40 /// Kind of the Pin (Input/Output)
42 /// Type of the Pin
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
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
64const 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
70bool 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
74std::vector<std::string> GetParentNodeDataTypes(const std::string& type);
75
76/// @brief Register all available Node types for the program
78
79/// @brief Register all available NodeData types for the program
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
85std::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
89bool 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
94std::shared_ptr<NodeData> CopyNodeData(const std::shared_ptr<const NodeData>& nodeData);
95
96} // namespace NodeRegistry
97
98} // namespace NAV
Pin class.
Abstract parent class for all nodes.
Definition Node.hpp:92
Pins in the GUI for information exchange.
Definition Pin.hpp:43
bool NodeDataTypeAnyIsChildOf(const std::vector< std::string > &childTypes, const std::vector< std::string > &parentTypes)
Checks if any of the provided child types is a child of any of the provided parent types.
const std::map< std::string, std::vector< NodeInfo > > & RegisteredNodes()
Reference to List of all registered Nodes.
std::vector< std::string > GetParentNodeDataTypes(const std::string &type)
Get the Parent Node Data Types of the specified Node Data Type.
void RegisterNodeDataTypes()
Register all available NodeData types for the program.
bool TypeHasDynamicData(const std::string &type)
Wether the specified Node Data Type can have dynamic data.
void RegisterNodeTypes()
Register all available Node types for the program.
std::vector< std::string > GetStaticDataDescriptors(const std::vector< std::string > &dataIdentifier)
Returns a vector of data descriptors for the pin data identifiers.
std::shared_ptr< NodeData > CopyNodeData(const std::shared_ptr< const NodeData > &nodeData)
Creates a copy of the data.
void move(std::vector< T > &v, size_t sourceIdx, size_t targetIdx)
Moves an element within a vector to a new position.
Definition Vector.hpp:27
Holds information for registered nodes.
std::function< Node *()> constructor
Constructor.
std::string type
Class Type of the node.
bool hasCompatiblePin(const Pin *pin) const
Checks if the node has a pin which can be linked.
std::vector< PinInfo > pinInfoList
List of port data types.
Pin::Type type
Type of the Pin.
Pin::Kind kind
Kind of the Pin (Input/Output)
PinInfo(const Pin::Kind &kind, const Pin::Type &type, std::vector< std::string > dataIdentifier)
Constructor.
std::vector< std::string > dataIdentifier
One or multiple Data Identifiers (Unique name which is used for data flows)
Kind of the Pin (Input/Output)
Definition Pin.hpp:165
@ None
None.
Definition Pin.hpp:169
Type of the data on the Pin.
Definition Pin.hpp:47
@ None
Not initialized.
Definition Pin.hpp:51