Compute Graph Framework SDK Reference  5.8
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
184 void resetPorts() override
185 {
186 Exception::guard([&]() {
187 return m_impl->resetPorts();
188 });
189 }
190
191protected:
192 std::unique_ptr<Node> m_impl;
193};
194
196{
197public:
198 explicit ExceptionSafeSensorNode(std::unique_ptr<Node> impl)
199 : m_impl(std::move(impl))
200 , m_sensorNodeImpl(dynamic_cast<ISensorNode*>(m_impl.get()))
201 {
202 if (m_sensorNodeImpl == nullptr)
203 {
204 throw Exception(DW_INVALID_ARGUMENT, "Not a sensor node");
205 }
206 }
207
208 ~ExceptionSafeSensorNode() override = default;
209
210 dwStatus reset() override
211 {
212 return Exception::guardWithReturn([&]() {
213 return m_impl->reset();
214 });
215 }
216
217 dwStatus setInputChannel(ChannelObject* channel, uint8_t portID) override
218 {
219 return Exception::guardWithReturn([&]() {
220 return m_impl->setInputChannel(channel, portID);
221 });
222 }
223
224 dwStatus setInputChannel(ChannelObject* channel, uint8_t portID, dwSerializationType dataType) override
225 {
226 return Exception::guardWithReturn([&]() {
227 return m_impl->setInputChannel(channel, portID, dataType);
228 });
229 }
230
231 dwStatus setOutputChannel(ChannelObject* channel, uint8_t portID) override
232 {
233 return Exception::guardWithReturn([&]() {
234 return m_impl->setOutputChannel(channel, portID);
235 });
236 }
237
238 dwStatus validate() override
239 {
240 return Exception::guardWithReturn([&]() {
241 return m_impl->validate();
242 });
243 }
244
245 dwStatus start() override
246 {
247 return Exception::guardWithReturn([&]() {
248 return m_sensorNodeImpl->start();
249 });
250 }
251
252 dwStatus stop() override
253 {
254 return Exception::guardWithReturn([&]() {
255 return m_sensorNodeImpl->stop();
256 });
257 }
258
259 dwStatus setAffinityMask(uint mask) override
260 {
261 return Exception::guardWithReturn([&]() {
262 return m_sensorNodeImpl->setAffinityMask(mask);
263 });
264 }
265
266 dwStatus setThreadPriority(int prio) override
267 {
268 return Exception::guardWithReturn([&]() {
270 });
271 }
272
273 dwStatus setStartTime(dwTime_t startTime) override
274 {
275 return Exception::guardWithReturn([&]() {
276 return m_sensorNodeImpl->setStartTime(startTime);
277 });
278 }
279
280 dwStatus setEndTime(dwTime_t endTime) override
281 {
282 return Exception::guardWithReturn([&]() {
283 return m_sensorNodeImpl->setEndTime(endTime);
284 });
285 }
286
287 dwStatus run() override
288 {
289 return Exception::guardWithReturn([&]() {
290 return m_impl->run();
291 });
292 }
293
294 size_t getPassCount() const noexcept override
295 {
296 return m_impl->getPassCount();
297 }
298
299 dwStatus runPassByID(uint8_t passID) override
300 {
301 return Exception::guardWithReturn([&]() {
302 return m_impl->runPassByID(passID);
303 });
304 }
305
306 dwStatus runPass(size_t passIndex) override
307 {
308 return Exception::guardWithReturn([&]() {
309 return m_impl->runPass(passIndex);
310 },
311 dw::core::Logger::Verbosity::WARN);
312 }
313
314 dwStatus getPasses(VectorFixed<Pass*>& passList) override
315 {
316 return Exception::guardWithReturn([&]() {
317 return m_impl->getPasses(passList);
318 });
319 }
320
321 dwStatus getPasses(VectorFixed<Pass*>& passList,
322 dwProcessorType processorType,
323 dwProcessType processType) override
324 {
325 return Exception::guardWithReturn([&]() {
326 return m_impl->getPasses(passList, processorType, processType);
327 });
328 }
329
330 dwStatus setName(const char* name) override
331 {
332 return Exception::guardWithReturn([&]() {
333 return m_impl->setName(name);
334 });
335 }
336
337 dwStatus getName(const char** name) override
338 {
339 return Exception::guardWithReturn([&]() {
340 return m_impl->getName(name);
341 });
342 }
343
344 dwStatus isVirtual(bool* isVirtualBool) override
345 {
346 return Exception::guardWithReturn([&]() {
347 return m_sensorNodeImpl->isVirtual(isVirtualBool);
348 });
349 }
350
352 {
353 return Exception::guardWithReturn([&]() {
355 });
356 }
357
359 {
360 return Exception::guardWithReturn([&]() {
362 });
363 }
364
365 dwStatus getErrorSignal(dwGraphErrorSignal*& errorSignal) override
366 {
367 return Exception::guardWithReturn([&]() {
368 return m_impl->getErrorSignal(errorSignal);
369 });
370 }
371
372 dwStatus getHealthSignal(dwGraphHealthSignal*& healthSignal, bool updateFromModule = false) override
373 {
374 return Exception::guardWithReturn([&]() {
375 return m_impl->getHealthSignal(healthSignal, updateFromModule);
376 });
377 }
378
380 {
381 return Exception::guardWithReturn([&]() {
382 return m_impl->reportCurrentErrorSignal(signal);
383 });
384 }
385
387 {
388 return Exception::guardWithReturn([&]() {
389 return m_impl->reportCurrentHealthSignal(signal);
390 });
391 }
392
393 dwStatus setIterationCount(uint32_t iterationCount) override final
394 {
395 return Exception::guardWithReturn([&]() {
396 return m_impl->setIterationCount(iterationCount);
397 });
398 }
399
400 dwStatus setState(const char* state) override
401 {
402 return Exception::guardWithReturn([&]() {
403 return m_impl->setState(state);
404 });
405 }
406
407 void resetPorts() override
408 {
409 Exception::guard([&]() {
410 return m_impl->resetPorts();
411 });
412 }
413
414protected:
415 std::unique_ptr<Node> m_impl;
417};
418} // namespace framework
419} // namespace dw
420
421#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 guard(TryBlock tryBlock, dw::core::Logger::Verbosity verbosity=dw::core::Logger::Verbosity::DEBUG)
Definition: Exception.hpp:228
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:310
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:319
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.
dwTrivialDataType dataType
Number of levels in the pyramid.
Definition: Exception.hpp:47