Compute Graph Framework SDK Reference  5.12
ChannelPacketImpl.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) 2018-2023 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_CHANNEL_PACKET_HPP_
32#define DW_FRAMEWORK_CHANNEL_PACKET_HPP_
33
35
36#include <dwshared/dwfoundation/dw/core/base/ExceptionWithStatus.hpp>
37
38namespace dw
39{
40namespace framework
41{
42
44// coverity[autosar_cpp14_m3_4_1_violation]
46{
47public:
48 uint8_t* getBuffer() override
49 {
50 return m_buffer.get();
51 }
52
53 size_t getBufferSize() override
54 {
55 return m_bufferSize;
56 }
57
58 // coverity[autosar_cpp14_a2_10_5_violation] RFD Pending: TID-2053
59 size_t serialize() override
60 {
62 return m_bufferSize;
63 }
64
65 // Serializes the frame before transmission
66 virtual void serializeImpl()
67 {
68 throw ExceptionWithStatus(DW_NOT_SUPPORTED, "ChannelPacketBase: serialize: not implemented");
69 }
70
71 // Deserializes the frame before transmission
72 void deserialize(size_t) override
73 {
74 throw ExceptionWithStatus(DW_NOT_SUPPORTED, "ChannelPacketBase: deserialize: not implemented");
75 }
76
77protected:
79
80 ChannelSocketPacketBase(size_t bufferSize)
81 : IChannelPacket::SocketCallbacks()
82 {
83 initBuffer(bufferSize);
84 }
85
86 void initBuffer(size_t bufferSize)
87 {
88 m_bufferSize = bufferSize;
89
90 // TODO (ajayawardane): the extra uint32_t is to ensure there is enough room
91 // to insert sync count after buffer. Figure out a better way to handle this
92 // coverity[autosar_cpp14_a4_7_1_violation]
93 // coverity[cert_int30_c_violation]
94 m_buffer = std::make_unique<uint8_t[]>(m_bufferSize + sizeof(ChannelMetadata));
95
96 if (m_buffer == nullptr)
97 {
98 throw ExceptionWithStatus(DW_BAD_ALLOC, "ChannelPacketBase: initBuffer: cannot allocate memory");
99 }
100 }
101
102 // packet should have a buffer of type uint8_t
103 // for serialization and de-serialization
104 size_t m_bufferSize{0U};
105 std::unique_ptr<uint8_t[]> m_buffer;
106};
107
108// coverity[autosar_cpp14_m3_4_1_violation]
109// coverity[autosar_cpp14_a10_1_1_violation]
111{
112public:
114 {
115 if (!m_frame.has_value())
116 {
117 throw ExceptionWithStatus(DW_INTERNAL_ERROR, "ChannelPacketBase: getGenericData: not set by implementation.");
118 }
119 return m_frame.value();
120 }
121
123
124protected:
125 dw::core::Optional<GenericData> m_frame;
126};
127
128// coverity[autosar_cpp14_a14_1_1_violation]
129template <typename T>
131{
132 virtual void notImplemented() = 0;
133};
134
135} // namespace framework
136} // namespace dw
137
138#endif // DW_FRAMEWORK_CHANNEL_PACKET_HPP_
GenericData getGenericData() override
dw::core::Optional< GenericData > m_frame
Definition: Buffer.hpp:40