Compute Graph Framework SDK Reference  5.6
ExceptionSafeNode.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) 2019-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_EXCEPTIONSAFENODE_HPP_
32#define DW_FRAMEWORK_EXCEPTIONSAFENODE_HPP_
33
34#include <dwcgf/Exception.hpp>
35
36namespace dw
37{
38namespace framework
39{
41{
42public:
43 explicit ExceptionSafeProcessNode(std::unique_ptr<Node> impl)
44 : m_impl(std::move(impl))
45 {
46 }
47
48 ~ExceptionSafeProcessNode() override = default;
49
50 dwStatus reset() override
51 {
52 return Exception::guardWithReturn([&]() {
53 return m_impl->reset();
54 });
55 }
56
57 dwStatus setInputChannel(ChannelObject* channel, uint8_t portID) override
58 {
59 return Exception::guardWithReturn([&]() {
60 return m_impl->setInputChannel(channel, portID);
61 });
62 }
63
64 dwStatus setInputChannel(ChannelObject* channel, uint8_t portID, dwSerializationType dataType) override
65 {
66 return Exception::guardWithReturn([&]() {
67 return m_impl->setInputChannel(channel, portID, dataType);
68 });
69 }
70
71 dwStatus setOutputChannel(ChannelObject* channel, uint8_t portID) override
72 {
73 return Exception::guardWithReturn([&]() {
74 return m_impl->setOutputChannel(channel, portID);
75 });
76 }
77
78 dwStatus validate() override
79 {
80 return Exception::guardWithReturn([&]() {
81 return m_impl->validate();
82 });
83 }
84
85 dwStatus run() override
86 {
87 return Exception::guardWithReturn([&]() {
88 return m_impl->run();
89 });
90 }
91
92 size_t getPassCount() const noexcept override
93 {
94 return m_impl->getPassCount();
95 }
96
97 dwStatus runPassByID(uint8_t passID) override
98 {
99 return Exception::guardWithReturn([&]() {
100 return m_impl->runPassByID(passID);
101 });
102 }
103
104 dwStatus runPass(size_t passIndex) override
105 {
106 return Exception::guardWithReturn([&]() {
107 return m_impl->runPass(passIndex);
108 },
109 dw::core::Logger::Verbosity::WARN);
110 }
111
112 dwStatus getPasses(VectorFixed<Pass*>& passList) override
113 {
114 return Exception::guardWithReturn([&]() {
115 return m_impl->getPasses(passList);
116 });
117 }
118
119 dwStatus getPasses(VectorFixed<Pass*>& passList,
120 dwProcessorType processorType,
121 dwProcessType processType) override
122 {
123 return Exception::guardWithReturn([&]() {
124 return m_impl->getPasses(passList, processorType, processType);
125 });
126 }
127
128 dwStatus setName(const char* name) override
129 {
130 return Exception::guardWithReturn([&]() {
131 return m_impl->setName(name);
132 });
133 }
134
135 dwStatus getName(const char** name) override
136 {
137 return Exception::guardWithReturn([&]() {
138 return m_impl->getName(name);
139 });
140 }
141
142 dwStatus getErrorSignal(dwGraphErrorSignal*& errorSignal) override
143 {
144 return Exception::guardWithReturn([&]() {
145 return m_impl->getErrorSignal(errorSignal);
146 });
147 }
148
149 dwStatus getHealthSignal(dwGraphHealthSignal*& healthSignal, bool updateFromModule = false) override
150 {
151 return Exception::guardWithReturn([&]() {
152 return m_impl->getHealthSignal(healthSignal, updateFromModule);
153 });
154 }
155
157 {
158 return Exception::guardWithReturn([&]() {
159 return m_impl->reportCurrentErrorSignal(signal);
160 });
161 }
162
164 {
165 return Exception::guardWithReturn([&]() {
166 return m_impl->reportCurrentHealthSignal(signal);
167 });
168 }
169
170 dwStatus setIterationCount(uint32_t iterationCount) override final
171 {
172 return Exception::guardWithReturn([&]() {
173 return m_impl->setIterationCount(iterationCount);
174 });
175 }
176
177 dwStatus setState(const char* state) override
178 {
179 return Exception::guardWithReturn([&]() {
180 return m_impl->setState(state);
181 });
182 }
183
184protected:
185 std::unique_ptr<Node> m_impl;
186};
187
189{
190public:
191 explicit ExceptionSafeSensorNode(std::unique_ptr<Node> impl)
192 : m_impl(std::move(impl))
193 , m_sensorNodeImpl(dynamic_cast<ISensorNode*>(m_impl.get()))
194 {
195 if (m_sensorNodeImpl == nullptr)
196 {
197 throw Exception(DW_INVALID_ARGUMENT, "Not a sensor node");
198 }
199 }
200
201 ~ExceptionSafeSensorNode() override = default;
202
203 dwStatus reset() override
204 {
205 return Exception::guardWithReturn([&]() {
206 return m_impl->reset();
207 });
208 }
209
210 dwStatus setInputChannel(ChannelObject* channel, uint8_t portID) override
211 {
212 return Exception::guardWithReturn([&]() {
213 return m_impl->setInputChannel(channel, portID);
214 });
215 }
216
217 dwStatus setInputChannel(ChannelObject* channel, uint8_t portID, dwSerializationType dataType) override
218 {
219 return Exception::guardWithReturn([&]() {
220 return m_impl->setInputChannel(channel, portID, dataType);
221 });
222 }
223
224 dwStatus setOutputChannel(ChannelObject* channel, uint8_t portID) override
225 {
226 return Exception::guardWithReturn([&]() {
227 return m_impl->setOutputChannel(channel, portID);
228 });
229 }
230
231 dwStatus validate() override
232 {
233 return Exception::guardWithReturn([&]() {
234 return m_impl->validate();
235 });
236 }
237
238 dwStatus start() override
239 {
240 return Exception::guardWithReturn([&]() {
241 return m_sensorNodeImpl->start();
242 });
243 }
244
245 dwStatus stop() override
246 {
247 return Exception::guardWithReturn([&]() {
248 return m_sensorNodeImpl->stop();
249 });
250 }
251
252 dwStatus setAffinityMask(uint mask) override
253 {
254 return Exception::guardWithReturn([&]() {
255 return m_sensorNodeImpl->setAffinityMask(mask);
256 });
257 }
258
259 dwStatus setThreadPriority(int prio) override
260 {
261 return Exception::guardWithReturn([&]() {
263 });
264 }
265
266 dwStatus setStartTime(dwTime_t startTime) override
267 {
268 return Exception::guardWithReturn([&]() {
269 return m_sensorNodeImpl->setStartTime(startTime);
270 });
271 }
272
273 dwStatus setEndTime(dwTime_t endTime) override
274 {
275 return Exception::guardWithReturn([&]() {
276 return m_sensorNodeImpl->setEndTime(endTime);
277 });
278 }
279
280 dwStatus run() override
281 {
282 return Exception::guardWithReturn([&]() {
283 return m_impl->run();
284 });
285 }
286
287 size_t getPassCount() const noexcept override
288 {
289 return m_impl->getPassCount();
290 }
291
292 dwStatus runPassByID(uint8_t passID) override
293 {
294 return Exception::guardWithReturn([&]() {
295 return m_impl->runPassByID(passID);
296 });
297 }
298
299 dwStatus runPass(size_t passIndex) override
300 {
301 return Exception::guardWithReturn([&]() {
302 return m_impl->runPass(passIndex);
303 },
304 dw::core::Logger::Verbosity::WARN);
305 }
306
307 dwStatus getPasses(VectorFixed<Pass*>& passList) override
308 {
309 return Exception::guardWithReturn([&]() {
310 return m_impl->getPasses(passList);
311 });
312 }
313
314 dwStatus getPasses(VectorFixed<Pass*>& passList,
315 dwProcessorType processorType,
316 dwProcessType processType) override
317 {
318 return Exception::guardWithReturn([&]() {
319 return m_impl->getPasses(passList, processorType, processType);
320 });
321 }
322
323 dwStatus setName(const char* name) override
324 {
325 return Exception::guardWithReturn([&]() {
326 return m_impl->setName(name);
327 });
328 }
329
330 dwStatus getName(const char** name) override
331 {
332 return Exception::guardWithReturn([&]() {
333 return m_impl->getName(name);
334 });
335 }
336
337 dwStatus isVirtual(bool* isVirtualBool) override
338 {
339 return Exception::guardWithReturn([&]() {
340 return m_sensorNodeImpl->isVirtual(isVirtualBool);
341 });
342 }
343
345 {
346 return Exception::guardWithReturn([&]() {
348 });
349 }
350
352 {
353 return Exception::guardWithReturn([&]() {
355 });
356 }
357
358 dwStatus getErrorSignal(dwGraphErrorSignal*& errorSignal) override
359 {
360 return Exception::guardWithReturn([&]() {
361 return m_impl->getErrorSignal(errorSignal);
362 });
363 }
364
365 dwStatus getHealthSignal(dwGraphHealthSignal*& healthSignal, bool updateFromModule = false) override
366 {
367 return Exception::guardWithReturn([&]() {
368 return m_impl->getHealthSignal(healthSignal, updateFromModule);
369 });
370 }
371
373 {
374 return Exception::guardWithReturn([&]() {
375 return m_impl->reportCurrentErrorSignal(signal);
376 });
377 }
378
380 {
381 return Exception::guardWithReturn([&]() {
382 return m_impl->reportCurrentHealthSignal(signal);
383 });
384 }
385
386 dwStatus setIterationCount(uint32_t iterationCount) override final
387 {
388 return Exception::guardWithReturn([&]() {
389 return m_impl->setIterationCount(iterationCount);
390 });
391 }
392
393 dwStatus setState(const char* state) override
394 {
395 return Exception::guardWithReturn([&]() {
396 return m_impl->setState(state);
397 });
398 }
399
400protected:
401 std::unique_ptr<Node> m_impl;
403};
404} // namespace framework
405} // namespace dw
406
407#endif // DW_FRAMEWORK_EXCEPTIONSAFENODE_HPP_
Basic error signal that gets reported only when there is an error.
Basic health signal that describes the health status of the graph.
~ExceptionSafeProcessNode() override=default
dwStatus setInputChannel(ChannelObject *channel, uint8_t portID, dwSerializationType dataType) override
dwStatus reportCurrentErrorSignal(dwGraphErrorSignal &signal) override
dwStatus getPasses(VectorFixed< Pass * > &passList, dwProcessorType processorType, dwProcessType processType) override
dwStatus setState(const char *state) override
dwStatus getErrorSignal(dwGraphErrorSignal *&errorSignal) override
dwStatus runPassByID(uint8_t passID) override
dwStatus setOutputChannel(ChannelObject *channel, uint8_t portID) override
size_t getPassCount() const noexcept override
dwStatus getName(const char **name) override
ExceptionSafeProcessNode(std::unique_ptr< Node > impl)
dwStatus runPass(size_t passIndex) override
dwStatus setIterationCount(uint32_t iterationCount) override final
dwStatus setName(const char *name) override
dwStatus getPasses(VectorFixed< Pass * > &passList) override
dwStatus setInputChannel(ChannelObject *channel, uint8_t portID) override
dwStatus getHealthSignal(dwGraphHealthSignal *&healthSignal, bool updateFromModule=false) override
dwStatus reportCurrentHealthSignal(dwGraphHealthSignal &signal) override
dwStatus setEndTime(dwTime_t endTime) override
dwStatus reportCurrentHealthSignal(dwGraphHealthSignal &signal) override
dwStatus setState(const char *state) override
dwStatus setName(const char *name) override
~ExceptionSafeSensorNode() override=default
dwStatus runPass(size_t passIndex) override
dwStatus setOutputChannel(ChannelObject *channel, uint8_t portID) override
dwStatus isVirtual(bool *isVirtualBool) override
dwStatus getHealthSignal(dwGraphHealthSignal *&healthSignal, bool updateFromModule=false) override
size_t getPassCount() const noexcept override
dwStatus setInputChannel(ChannelObject *channel, uint8_t portID, dwSerializationType dataType) override
dwStatus setDataEventWriteCallback(DataEventWriteCallback cb) override
dwStatus reportCurrentErrorSignal(dwGraphErrorSignal &signal) override
dwStatus setAffinityMask(uint mask) override
dwStatus setIterationCount(uint32_t iterationCount) override final
dwStatus setInputChannel(ChannelObject *channel, uint8_t portID) override
dwStatus getPasses(VectorFixed< Pass * > &passList) override
dwStatus getName(const char **name) override
dwStatus getPasses(VectorFixed< Pass * > &passList, dwProcessorType processorType, dwProcessType processType) override
ExceptionSafeSensorNode(std::unique_ptr< Node > impl)
dwStatus setStartTime(dwTime_t startTime) override
dwStatus setThreadPriority(int prio) override
dwStatus runPassByID(uint8_t passID) override
dwStatus getErrorSignal(dwGraphErrorSignal *&errorSignal) override
dwStatus setDataEventReadCallback(DataEventReadCallback cb) override
static dwStatus guardWithReturn(TryBlock tryBlock, dw::core::Logger::Verbosity verbosity=dw::core::Logger::Verbosity::DEBUG)
Definition: Exception.hpp:122
virtual dwStatus setAffinityMask(uint)=0
Sets the affinity mask of the sensor.
virtual dwStatus setDataEventReadCallback(DataEventReadCallback cb)=0
Set read timestamp function for dataset replay. Timestamps not in the sequence returned by the callba...
virtual dwStatus setDataEventWriteCallback(DataEventWriteCallback cb)=0
Set write timestamp function for live case. Each timestamp of data output from the node will be passe...
virtual dwStatus start()=0
Start the sensor.
virtual dwStatus setEndTime(dwTime_t)=0
Set end timestamp for dataset replay.
dw::core::Function< bool(DataEvent &)> DataEventReadCallback
Definition: Node.hpp:305
virtual dwStatus stop()=0
Stop the sensor.
virtual dwStatus isVirtual(bool *isVirtualBool)=0
distinguishes between a live and virtual sensor
dw::core::Function< void(DataEvent)> DataEventWriteCallback
Definition: Node.hpp:314
virtual dwStatus setThreadPriority(int)=0
Sets the thread priority of the sensor.
virtual dwStatus setStartTime(dwTime_t)=0
Set start timestamp for dataset replay.
constexpr size_t passIndex(dw::core::StringView identifier)
Get the the pass index for a pass identified by name.
Definition: Exception.hpp:47