Compute Graph Framework SDK Reference
5.4.5418 Release
For Test and Development only

ExceptionSafeNode.hpp
Go to the documentation of this file.
1 //
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-2021 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 
36 namespace dw
37 {
38 namespace framework
39 {
41 {
42 public:
43  explicit ExceptionSafeProcessNode(std::unique_ptr<ProcessNode> 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  }
110 
111  dwStatus getPasses(VectorFixed<Pass*>& passList) override
112  {
113  return Exception::guardWithReturn([&]() {
114  return m_impl->getPasses(passList);
115  });
116  }
117 
118  dwStatus getPasses(VectorFixed<Pass*>& passList,
119  dwProcessorType processorType,
120  dwProcessType processType) override
121  {
122  return Exception::guardWithReturn([&]() {
123  return m_impl->getPasses(passList, processorType, processType);
124  });
125  }
126 
127  dwStatus setName(const char* name) override
128  {
129  return Exception::guardWithReturn([&]() {
130  return m_impl->setName(name);
131  });
132  }
133 
134  dwStatus getName(const char** name) override
135  {
136  return Exception::guardWithReturn([&]() {
137  return m_impl->getName(name);
138  });
139  }
140 
141  dwStatus getHealthSignals(dwGraphHealthSignalArray*& healthSignals) override
142  {
143  return Exception::guardWithReturn([&]() {
144  return m_impl->getHealthSignals(healthSignals);
145  });
146  }
147 
148  dwStatus setIterationCount(uint32_t iterationCount) override final
149  {
150  return Exception::guardWithReturn([&]() {
151  return m_impl->setIterationCount(iterationCount);
152  });
153  }
154 
155 protected:
156  std::unique_ptr<ProcessNode> m_impl;
157 };
158 
160 {
161 public:
162  explicit ExceptionSafeSensorNode(std::unique_ptr<SensorNode> impl)
163  : m_impl(std::move(impl))
164  {
165  }
166 
167  ~ExceptionSafeSensorNode() override = default;
168 
169  dwStatus reset() override
170  {
171  return Exception::guardWithReturn([&]() {
172  return m_impl->reset();
173  });
174  }
175 
176  dwStatus setInputChannel(ChannelObject* channel, uint8_t portID) override
177  {
178  return Exception::guardWithReturn([&]() {
179  return m_impl->setInputChannel(channel, portID);
180  });
181  }
182 
183  dwStatus setInputChannel(ChannelObject* channel, uint8_t portID, dwSerializationType dataType) override
184  {
185  return Exception::guardWithReturn([&]() {
186  return m_impl->setInputChannel(channel, portID, dataType);
187  });
188  }
189 
190  dwStatus setOutputChannel(ChannelObject* channel, uint8_t portID) override
191  {
192  return Exception::guardWithReturn([&]() {
193  return m_impl->setOutputChannel(channel, portID);
194  });
195  }
196 
197  dwStatus validate() override
198  {
199  return Exception::guardWithReturn([&]() {
200  return m_impl->validate();
201  });
202  }
203 
204  dwStatus start() override
205  {
206  return Exception::guardWithReturn([&]() {
207  return m_impl->start();
208  });
209  }
210 
211  dwStatus stop() override
212  {
213  return Exception::guardWithReturn([&]() {
214  return m_impl->stop();
215  });
216  }
217 
218  dwStatus setAffinityMask(uint mask) override
219  {
220  return Exception::guardWithReturn([&]() {
221  return m_impl->setAffinityMask(mask);
222  });
223  }
224 
225  dwStatus setThreadPriority(int prio) override
226  {
227  return Exception::guardWithReturn([&]() {
228  return m_impl->setThreadPriority(prio);
229  });
230  }
231 
232  dwStatus setStartTime(dwTime_t startTime) override
233  {
234  return Exception::guardWithReturn([&]() {
235  return m_impl->setStartTime(startTime);
236  });
237  }
238 
239  dwStatus setEndTime(dwTime_t endTime) override
240  {
241  return Exception::guardWithReturn([&]() {
242  return m_impl->setEndTime(endTime);
243  });
244  }
245 
246  dwStatus run() override
247  {
248  return Exception::guardWithReturn([&]() {
249  return m_impl->run();
250  });
251  }
252 
253  size_t getPassCount() const noexcept override
254  {
255  return m_impl->getPassCount();
256  }
257 
258  dwStatus runPassByID(uint8_t passID) override
259  {
260  return Exception::guardWithReturn([&]() {
261  return m_impl->runPassByID(passID);
262  });
263  }
264 
265  dwStatus runPass(size_t passIndex) override
266  {
267  return Exception::guardWithReturn([&]() {
268  return m_impl->runPass(passIndex);
269  });
270  }
271 
272  dwStatus getPasses(VectorFixed<Pass*>& passList) override
273  {
274  return Exception::guardWithReturn([&]() {
275  return m_impl->getPasses(passList);
276  });
277  }
278 
279  dwStatus getPasses(VectorFixed<Pass*>& passList,
280  dwProcessorType processorType,
281  dwProcessType processType) override
282  {
283  return Exception::guardWithReturn([&]() {
284  return m_impl->getPasses(passList, processorType, processType);
285  });
286  }
287 
288  dwStatus setName(const char* name) override
289  {
290  return Exception::guardWithReturn([&]() {
291  return m_impl->setName(name);
292  });
293  }
294 
295  dwStatus getName(const char** name) override
296  {
297  return Exception::guardWithReturn([&]() {
298  return m_impl->getName(name);
299  });
300  }
301 
302  dwStatus isVirtual(bool* isVirtualBool) override
303  {
304  return Exception::guardWithReturn([&]() {
305  return m_impl->isVirtual(isVirtualBool);
306  });
307  }
308 
310  {
311  return Exception::guardWithReturn([&]() {
312  return m_impl->setDataEventReadCallback(cb);
313  });
314  }
315 
317  {
318  return Exception::guardWithReturn([&]() {
319  return m_impl->setDataEventWriteCallback(cb);
320  });
321  }
322 
323  dwStatus getHealthSignals(dwGraphHealthSignalArray*& healthSignals) override
324  {
325  return Exception::guardWithReturn([&]() {
326  return m_impl->getHealthSignals(healthSignals);
327  });
328  }
329 
330  dwStatus setIterationCount(uint32_t iterationCount) override final
331  {
332  return Exception::guardWithReturn([&]() {
333  return m_impl->setIterationCount(iterationCount);
334  });
335  }
336 
337 protected:
338  std::unique_ptr<SensorNode> m_impl;
339 };
340 } // namespace framework
341 } // namespace dw
342 
343 #endif // DW_FRAMEWORK_EXCEPTIONSAFENODE_HPP_
dwStatus runPassByID(uint8_t passID) override
static dwStatus guardWithReturn(TryBlock tryBlock)
Simple try/catch handler to catch dw::core::Exception and return a dwStatus error code if the given f...
Definition: Exception.hpp:122
dw::core::Function< void(DataEvent)> DataEventWriteCallback
Definition: Node.hpp:285
dwStatus setInputChannel(ChannelObject *channel, uint8_t portID) override
dwStatus getName(const char **name) override
dwStatus setStartTime(dwTime_t startTime) override
dwStatus getPasses(VectorFixed< Pass *> &passList) override
dwStatus setDataEventReadCallback(DataEventReadCallback cb) override
dwStatus setOutputChannel(ChannelObject *channel, uint8_t portID) override
dwStatus runPass(size_t passIndex) override
dwStatus runPass(size_t passIndex) override
dwStatus getHealthSignals(dwGraphHealthSignalArray *&healthSignals) override
std::unique_ptr< ProcessNode > m_impl
dwStatus setName(const char *name) override
std::unique_ptr< SensorNode > m_impl
dwStatus runPassByID(uint8_t passID) override
~ExceptionSafeProcessNode() override=default
dwStatus setThreadPriority(int prio) override
dwStatus getPasses(VectorFixed< Pass *> &passList) override
dwStatus setInputChannel(ChannelObject *channel, uint8_t portID) override
dwStatus getName(const char **name) override
dwStatus setIterationCount(uint32_t iterationCount) override final
ExceptionSafeProcessNode(std::unique_ptr< ProcessNode > impl)
dwStatus setEndTime(dwTime_t endTime) override
dwStatus setName(const char *name) override
size_t getPassCount() const noexcept override
dwStatus setIterationCount(uint32_t iterationCount) override final
dwStatus getPasses(VectorFixed< Pass *> &passList, dwProcessorType processorType, dwProcessType processType) override
ExceptionSafeSensorNode(std::unique_ptr< SensorNode > impl)
dwStatus setInputChannel(ChannelObject *channel, uint8_t portID, dwSerializationType dataType) override
dwStatus setOutputChannel(ChannelObject *channel, uint8_t portID) override
dw::core::Function< bool(DataEvent &)> DataEventReadCallback
Definition: Node.hpp:276
constexpr size_t passIndex(dw::core::StringView identifier)
Get the the pass index for a pass identified by name.
dwStatus setInputChannel(ChannelObject *channel, uint8_t portID, dwSerializationType dataType) override
Definition: Exception.hpp:46
dwStatus getPasses(VectorFixed< Pass *> &passList, dwProcessorType processorType, dwProcessType processType) override
dwStatus setDataEventWriteCallback(DataEventWriteCallback cb) override
dwStatus setAffinityMask(uint mask) override
size_t getPassCount() const noexcept override
dwStatus isVirtual(bool *isVirtualBool) override
dwStatus getHealthSignals(dwGraphHealthSignalArray *&healthSignals) override