• <xmp id="om0om">
  • <table id="om0om"><noscript id="om0om"></noscript></table>
  • Compute Graph Framework SDK Reference  5.10
    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-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_CHANNEL_PACKET_HPP_
    32#define DW_FRAMEWORK_CHANNEL_PACKET_HPP_
    33
    35
    36#include <dw/core/base/Exception.hpp>
    37
    38namespace dw
    39{
    40namespace framework
    41{
    42
    45{
    46public:
    47 uint8_t* getBuffer() override
    48 {
    49 return m_buffer.get();
    50 }
    51
    52 size_t getBufferSize() override
    53 {
    54 return m_bufferSize;
    55 }
    56
    57 size_t serialize() override
    58 {
    60 return m_bufferSize;
    61 }
    62
    63 // Serializes the frame before transmission
    64 virtual void serializeImpl()
    65 {
    66 throw ExceptionWithStatus(DW_NOT_SUPPORTED, "ChannelPacketBase: serialize: not implemented");
    67 }
    68
    69 // Deserializes the frame before transmission
    70 void deserialize(size_t) override
    71 {
    72 throw ExceptionWithStatus(DW_NOT_SUPPORTED, "ChannelPacketBase: deserialize: not implemented");
    73 }
    74
    75protected:
    77
    78 ChannelSocketPacketBase(size_t bufferSize)
    79 {
    80 initBuffer(bufferSize);
    81 }
    82
    83 void initBuffer(size_t bufferSize)
    84 {
    85 m_bufferSize = bufferSize;
    86
    87 // TODO (ajayawardane): the extra uint32_t is to ensure there is enough room
    88 // to insert sync count after buffer. Figure out a better way to handle this
    89 m_buffer = std::make_unique<uint8_t[]>(m_bufferSize + sizeof(ChannelMetadata));
    90
    91 if (m_buffer == nullptr)
    92 {
    93 throw ExceptionWithStatus(DW_BAD_ALLOC, "ChannelPacketBase: initBuffer: cannot allocate memory");
    94 }
    95 }
    96
    97 // packet should have a buffer of type uint8_t
    98 // for serialization and de-serialization
    99 size_t m_bufferSize = 0;
    100 std::unique_ptr<uint8_t[]> m_buffer;
    101};
    102
    104{
    105public:
    107 {
    108 if (!m_frame)
    109 {
    110 throw ExceptionWithStatus(DW_INTERNAL_ERROR, "ChannelPacketBase: getGenericData: not set by implementation.");
    111 }
    112 return m_frame.value();
    113 }
    114
    116
    117protected:
    118 dw::core::Optional<GenericData> m_frame;
    119};
    120
    121template <typename T>
    123{
    124 virtual void notImplemented() = 0;
    125};
    126
    127} // namespace framework
    128} // namespace dw
    129
    130#endif // DW_FRAMEWORK_CHANNEL_PACKET_HPP_
    GenericData getGenericData() override
    dw::core::Optional< GenericData > m_frame
    Definition: Buffer.hpp:40
    人人超碰97caoporen国产