• <xmp id="om0om">
  • <table id="om0om"><noscript id="om0om"></noscript></table>
  • Compute Graph Framework SDK Reference  5.22
    All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
    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-2024 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#include <dwshared/dwfoundation/dw/core/safety/Safety.hpp>
    38
    39namespace dw
    40{
    41namespace framework
    42{
    43
    45// coverity[autosar_cpp14_m3_4_1_violation] RFD Pending: TID-2586
    47{
    48public:
    49 uint8_t* getBuffer() override
    50 {
    51 return m_buffer.get();
    52 }
    53
    54 size_t getBufferSize() override
    55 {
    56 return m_bufferSize;
    57 }
    58
    59 // coverity[autosar_cpp14_a2_10_5_violation]
    60 size_t serialize() override
    61 {
    63 return m_bufferSize;
    64 }
    65
    66 // Serializes the frame before transmission
    67 virtual void serializeImpl()
    68 {
    69 throw ExceptionWithStatus(DW_NOT_SUPPORTED, "ChannelPacketBase: serialize: not implemented");
    70 }
    71
    72 // Deserializes the frame before transmission
    73 void deserialize(size_t) override = 0;
    74
    75protected:
    77
    78 explicit ChannelSocketPacketBase(size_t bufferSize)
    79 : IChannelPacket::SocketCallbacks()
    80 {
    81 initBuffer(bufferSize);
    82 }
    83
    84 void initBuffer(size_t bufferSize)
    85 {
    86 m_bufferSize = bufferSize;
    87
    88 // TODO (ajayawardane): the extra uint32_t is to ensure there is enough room
    89 // to insert sync count after buffer. Figure out a better way to handle this
    90 // the buffer size isn't close to the maximum value of size_t, hence no risk of overflow
    91 m_buffer = std::make_unique<uint8_t[]>(dw::core::safeAdd(m_bufferSize, sizeof(ChannelMetadata)).value());
    92
    93 if (nullptr == m_buffer)
    94 {
    95 throw ExceptionWithStatus(DW_BAD_ALLOC, "ChannelPacketBase: initBuffer: cannot allocate memory");
    96 }
    97 }
    98
    99 // packet should have a buffer of type uint8_t
    100 // for serialization and de-serialization
    101 size_t m_bufferSize{0U};
    102 std::unique_ptr<uint8_t[]> m_buffer;
    103};
    104
    105// coverity[autosar_cpp14_m3_4_1_violation] RFD Pending: TID-2586
    106// coverity[autosar_cpp14_a10_1_1_violation]
    108{
    109public:
    111 {
    112 if (!m_frame.has_value())
    113 {
    114 throw ExceptionWithStatus(DW_INTERNAL_ERROR, "ChannelPacketBase: getGenericData: not set by implementation.");
    115 }
    116 return m_frame.value();
    117 }
    118
    120
    121protected:
    122 dw::core::Optional<GenericData> m_frame;
    123};
    124
    125template <typename T>
    127{
    128 static_assert(std::is_constructible<T>::value, "T must be constructible");
    129 static_assert(std::is_trivially_copyable<T>::value, "Type argument T is not trivially copyable");
    130
    131 virtual void notImplemented() = 0;
    132};
    133
    134} // namespace framework
    135} // namespace dw
    136
    137#endif // DW_FRAMEWORK_CHANNEL_PACKET_HPP_
    GenericData getGenericData() override
    dw::core::Optional< GenericData > m_frame
    void deserialize(size_t) override=0
    Definition: Buffer.hpp:41
    人人超碰97caoporen国产