Compute Graph Framework SDK Reference  5.8
PortCollectionDescriptor.hpp
Go to the documentation of this file.
1
2//
3// Notice
4// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES
5// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
6// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,
7// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8//
9// NVIDIA CORPORATION & AFFILIATES assumes no responsibility for the consequences of use of such
10// information or for any infringement of patents or other rights of third parties that may
11// result from its use. No license is granted by implication or otherwise under any patent
12// or patent rights of NVIDIA CORPORATION & AFFILIATES. No third party distribution is allowed unless
13// expressly authorized by NVIDIA. Details are subject to change without notice.
14// This code supersedes and replaces all information previously supplied.
15// NVIDIA CORPORATION & AFFILIATES products are not authorized for use as critical
16// components in life support devices or systems without express written approval of
17// NVIDIA CORPORATION & AFFILIATES.
18//
19// SPDX-FileCopyrightText: Copyright (c) 2021-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
20// SPDX-License-Identifier: LicenseRef-NvidiaProprietary
21//
22// NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
23// property and proprietary rights in and to this material, related
24// documentation and any modifications thereto. Any use, reproduction,
25// disclosure or distribution of this material and related documentation
26// without an express license agreement from NVIDIA CORPORATION or
27// its affiliates is strictly prohibited.
28//
30
31#ifndef DW_FRAMEWORK_PORTCOLLECTIONDESCRIPTOR_HPP_
32#define DW_FRAMEWORK_PORTCOLLECTIONDESCRIPTOR_HPP_
33
34#include <dwcgf/port/Port.hpp>
36
37#include <dw/core/container/BaseString.hpp>
38#include <dw/core/container/StringView.hpp>
39#include <dw/core/container/VectorFixed.hpp>
40#include <dw/core/language/Tuple.hpp>
41
42#include <string>
43#include <typeinfo>
44
46#define NODE_GET_INPUT_PORT_INDEX_EXTERNAL(NodeT, identifier) dw::framework::portIndex<NodeT, dw::framework::PortDirection::INPUT>(identifier)
48#define NODE_GET_OUTPUT_PORT_INDEX_EXTERNAL(NodeT, identifier) dw::framework::portIndex<NodeT, dw::framework::PortDirection::OUTPUT>(identifier)
49
50namespace dw
51{
52namespace framework
53{
54
56{
57public:
59 PortDirection direction, dw::core::StringView name,
60 dw::core::StringView typeName, size_t arraySize, bool bindingRequired,
61 dw::core::StringView comment);
63
64 const dw::core::StringView& getName() const;
65
66 const dw::core::StringView& getTypeName() const;
67
68 bool isArray() const;
69
70 size_t getArraySize() const;
71
72 bool isBindingRequired() const;
73
74 const dw::core::StringView& getComment() const;
75
76private:
77 PortDirection m_direction;
78 dw::core::StringView m_name;
79 dw::core::StringView m_typeName;
80 size_t m_arraySize;
81 bool m_bindingRequired;
82 dw::core::StringView m_comment;
83};
84
85// coverity[autosar_cpp14_a0_1_1_violation]
86// coverity[autosar_cpp14_a5_1_1_violation]
87// coverity[autosar_cpp14_m0_1_4_violation]
88static constexpr size_t MAX_PORT_DESCRIPTOR_PER_COLLECTION{256U};
89
91{
92public:
93 PortCollectionDescriptor(PortDirection direction, size_t portOffset = 0);
94
96
97 size_t getDescriptorSize() const;
98
99 size_t getPortSize() const;
100
101 const PortDescriptor& getDescriptor(size_t index) const;
102
103 size_t getDescriptorIndex(const char* identifier) const;
104
105 const PortDescriptor& getDescriptor(const char* identifier) const;
106
107 size_t getPortIndex(const char* identifier) const;
108
109 bool isValid(size_t portIndex) const;
110
111 bool isValid(const char* identifier) const;
112
113 void addDescriptor(PortDescriptor&& descriptor);
114
115protected:
118 dw::core::VectorFixed<PortDescriptor, MAX_PORT_DESCRIPTOR_PER_COLLECTION> m_descriptors;
119};
120
121namespace detail
122{
123
124template <
125 typename NodeT, PortDirection Direction, size_t Index,
126 typename std::enable_if_t<Index == dw::core::tuple_size<decltype(describePorts<NodeT, Direction>())>::value, void>* = nullptr>
127void addDescriptors(PortCollectionDescriptor& d)
128{
129 (void)d;
130 return;
131}
132
133template <
134 typename NodeT, PortDirection Direction, size_t Index,
135 typename std::enable_if_t<Index<dw::core::tuple_size<decltype(describePorts<NodeT, Direction>())>::value, void>* = nullptr>
136 // TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
137 // coverity[autosar_cpp14_a2_10_5_violation]
138 void addDescriptors(PortCollectionDescriptor& d)
139{
140 constexpr auto t = dw::core::get<Index>(describePorts<NodeT, Direction>());
141 d.addDescriptor(PortDescriptor(
142 Direction,
143 std::get<PORT_NAME>(t).data(),
144 std::get<PORT_TYPE_NAME>(t).data(),
145 std::get<PORT_ARRAY_SIZE>(t),
146 std::get<PORT_BINDING>(t) == PortBinding::REQUIRED,
147 std::get<PORT_COMMENT>(t).data()));
148 addDescriptors<NodeT, Direction, Index + 1>(d);
149}
150
151} // namespace detail
152
153template <
154 typename NodeT, PortDirection Direction,
155 typename std::enable_if_t<Direction == PortDirection::INPUT, void>* = nullptr>
156// TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
157// coverity[autosar_cpp14_a2_10_4_violation]
159{
160 PortCollectionDescriptor d(Direction);
161 detail::addDescriptors<NodeT, Direction, 0>(d);
162 return d;
163}
164
165template <
166 typename NodeT, PortDirection Direction,
167 typename std::enable_if_t<Direction == PortDirection::OUTPUT, void>* = nullptr>
168// TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
169// coverity[autosar_cpp14_a2_10_4_violation]
170// coverity[autosar_cpp14_a2_10_5_violation]
171static PortCollectionDescriptor createPortCollectionDescriptor()
172{
173 PortCollectionDescriptor d(Direction, portSize<NodeT, PortDirection::INPUT>());
174 detail::addDescriptors<NodeT, Direction, 0>(d);
175 return d;
176}
177
178} // namespace framework
179} // namespace dw
180
181#endif // DW_FRAMEWORK_PORTCOLLECTIONDESCRIPTOR_HPP_
bool isValid(const char *identifier) const
PortCollectionDescriptor(PortDirection direction, size_t portOffset=0)
dw::core::VectorFixed< PortDescriptor, MAX_PORT_DESCRIPTOR_PER_COLLECTION > m_descriptors
const PortDescriptor & getDescriptor(const char *identifier) const
const PortDescriptor & getDescriptor(size_t index) const
void addDescriptor(PortDescriptor &&descriptor)
size_t getDescriptorIndex(const char *identifier) const
bool isValid(size_t portIndex) const
size_t getPortIndex(const char *identifier) const
PortDescriptor(PortDirection direction, dw::core::StringView name, dw::core::StringView typeName, size_t arraySize, bool bindingRequired, dw::core::StringView comment)
PortDirection getDirection() const
const dw::core::StringView & getName() const
const dw::core::StringView & getTypeName() const
const dw::core::StringView & getComment() const
constexpr size_t portIndex(StringView identifier)
static PortCollectionDescriptor createPortCollectionDescriptor()
static constexpr size_t MAX_PORT_DESCRIPTOR_PER_COLLECTION
Definition: Exception.hpp:47