• <xmp id="om0om">
  • <table id="om0om"><noscript id="om0om"></noscript></table>
  • Compute Graph Framework SDK Reference  5.14
    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-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#include <dwshared/dwfoundation/dw/core/safety/Safety.hpp>
    38
    39namespace dw
    40{
    41namespace framework
    42{
    43
    45// coverity[autosar_cpp14_m3_4_1_violation]
    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] RFD Pending: TID-2053
    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
    74 {
    75 throw ExceptionWithStatus(DW_NOT_SUPPORTED, "ChannelPacketBase: deserialize: not implemented");
    76 }
    77
    78protected:
    80
    81 ChannelSocketPacketBase(size_t bufferSize)
    82 : IChannelPacket::SocketCallbacks()
    83 {
    84 initBuffer(bufferSize);
    85 }
    86
    87 void initBuffer(size_t bufferSize)
    88 {
    89 m_bufferSize = bufferSize;
    90
    91 // TODO (ajayawardane): the extra uint32_t is to ensure there is enough room
    92 // to insert sync count after buffer. Figure out a better way to handle this
    93 m_buffer = std::make_unique<uint8_t[]>(dw::core::safeAdd(m_bufferSize, sizeof(ChannelMetadata)).value());
    94
    95 if (m_buffer == nullptr)
    96 {
    97 throw ExceptionWithStatus(DW_BAD_ALLOC, "ChannelPacketBase: initBuffer: cannot allocate memory");
    98 }
    99 }
    100
    101 // packet should have a buffer of type uint8_t
    102 // for serialization and de-serialization
    103 size_t m_bufferSize{0U};
    104 std::unique_ptr<uint8_t[]> m_buffer;
    105};
    106
    107// coverity[autosar_cpp14_m3_4_1_violation]
    108// coverity[autosar_cpp14_a10_1_1_violation]
    110{
    111public:
    113 {
    114 if (!m_frame.has_value())
    115 {
    116 throw ExceptionWithStatus(DW_INTERNAL_ERROR, "ChannelPacketBase: getGenericData: not set by implementation.");
    117 }
    118 return m_frame.value();
    119 }
    120
    122
    123protected:
    124 dw::core::Optional<GenericData> m_frame;
    125};
    126
    127// coverity[autosar_cpp14_a14_1_1_violation]
    128template <typename T>
    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
    Definition: Buffer.hpp:40
    人人超碰97caoporen国产