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

ChannelFactory.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) 2020-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_ICHANNELFACTORY_HPP_
32 #define DW_FRAMEWORK_ICHANNELFACTORY_HPP_
33 
37 #include <nvscisync.h>
38 
39 namespace dw
40 {
41 namespace framework
42 {
43 
44 using ChannelPacketConstructor = dw::core::Function<std::unique_ptr<IChannelPacket>(GenericData dataSpecimen, dwContextHandle_t context)>;
45 using ChannelPacketConstructorSignature = std::pair<ChannelPacketTypeID, ChannelType>;
46 using ChannelPacketConstructorRegistration = std::pair<ChannelPacketConstructorSignature, ChannelPacketConstructor>;
47 
48 class ChannelFactoryImpl;
49 
51 {
52 public:
53  static void registerPacketConstructor(const ChannelPacketConstructorSignature& signature, const ChannelPacketConstructor& constructor);
55 
56  ChannelFactory(dwContextHandle_t ctx = DW_NULL_HANDLE);
57  virtual ~ChannelFactory() = default;
58  // Create a channel with given channelParams
59  std::shared_ptr<ChannelObject> makeChannel(const char* channelParams);
60 
61  using OnDispatchDataReady = dw::core::Function<void(void* opaque, IChannelPacketFactory::OnDataReady)>;
62  void setOnDispatchDataReady(OnDispatchDataReady dispatchDataReady);
63 
64  void setTraceMode(ChannelTraceMode traceMode);
65 
66  void setOnRegisterTraceWriter(ChannelOnRegisterTraceWriter onRegisterTraceWriter);
67  void setOnRegisterTraceReader(ChannelOnRegisterTraceReader onRegisterTraceReader);
68 
69  // Get the packet factory so registered packet constructors can be accessed directly
71 
72  // Get the nvscisync module used by underlying NvSciStream channels. This NvSciSyncModule is owned
73  // internally by channels and shall not be freed by application.
74  NvSciSyncModule getNvSciSyncModule();
75 
76 private:
77  std::shared_ptr<ChannelFactoryImpl> m_pimpl;
78 };
79 
80 } // namespace framework
81 } // namespace dw
82 
83 #endif // DW_FRAMEWORK_ICHANNELFACTORY_HPP_
static void registerPacketConstructor(const ChannelPacketConstructorSignature &signature, const ChannelPacketConstructor &constructor)
void setOnDispatchDataReady(OnDispatchDataReady dispatchDataReady)
void setOnRegisterTraceReader(ChannelOnRegisterTraceReader onRegisterTraceReader)
std::shared_ptr< IChannelPacketFactory > ChannelPacketFactoryPtr
void setTraceMode(ChannelTraceMode traceMode)
ChannelFactory(dwContextHandle_t ctx=DW_NULL_HANDLE)
dw::core::Function< std::unique_ptr< IChannelPacket >(GenericData dataSpecimen, dwContextHandle_t context)> ChannelPacketConstructor
ChannelTraceMode
A channel is created with a particular mode for these traces.
std::shared_ptr< ChannelObject > makeChannel(const char *channelParams)
static void unregisterPacketConstructor(const ChannelPacketConstructorSignature &signature)
void setOnRegisterTraceWriter(ChannelOnRegisterTraceWriter onRegisterTraceWriter)
dw::core::Function< ChannelTraceWriteCallback(const char *channelID)> ChannelOnRegisterTraceWriter
Callback used by channel to register its need to write trace points.
std::pair< ChannelPacketConstructorSignature, ChannelPacketConstructor > ChannelPacketConstructorRegistration
Definition: Exception.hpp:46
NvSciSyncModule getNvSciSyncModule()
dw::core::Function< ChannelTraceReadCallback(const char *channelID)> ChannelOnRegisterTraceReader
Callback used by channel to register its need to read trace points.
std::pair< ChannelPacketTypeID, ChannelType > ChannelPacketConstructorSignature
dw::core::Function< void(void *opaque, IChannelPacketFactory::OnDataReady)> OnDispatchDataReady
ChannelPacketFactoryPtr getPacketFactory()
virtual ~ChannelFactory()=default