NVIDIA DeepStream SDK API Reference

9.1 Release
9.1/sources/includes/ds3d/common/hpp/dataloader.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2021-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef _DS3D_COMMON_HPP_DATALOADER_HPP
19 #define _DS3D_COMMON_HPP_DATALOADER_HPP
20 
21 #include <ds3d/common/common.h>
22 #include <ds3d/common/func_utils.h>
23 #include <ds3d/common/hpp/dataprocess.hpp>
24 
25 namespace ds3d {
26 
50 class GuardDataLoader : public GuardDataProcess<abiDataLoader> {
51  using _Base = GuardDataProcess<abiDataLoader>;
52 
53 public:
54  // GuardDataLoader() = default;
55  template <typename... Args /*, _EnableIfConstructible<_Base, Args...> = true*/>
56  GuardDataLoader(Args&&... args) : _Base(std::forward<Args>(args)...)
57  {
58  }
59  ~GuardDataLoader() = default;
60 
61  std::string getOutputCaps()
62  {
63  DS_ASSERT(ptr());
64  return cppString(ptr()->getCaps_i(CapsPort::kOutput));
65  }
66 
68  {
69  abiRefDataMap* data = nullptr;
70  DS_ASSERT(ptr());
71  ErrCode code = ptr()->readData_i(data);
72  datamap.reset(data);
73  return code;
74  }
75 
77  {
78  DS_ASSERT(ptr());
79  DS_ASSERT(dataReadyCB);
80  GuardCB<abiOnDataCB> guardCb;
81  guardCb.setFn<ErrCode, const abiRefDataMap*>(std::move(dataReadyCB));
82  return ptr()->readDataAsync_i(guardCb.abiRef());
83  }
84 };
85 
86 } // namespace ds3d
87 
88 #endif // _DS3D_COMMON_HPP_DATALOADER_HPP
ds3d::GuardDataLoader::GuardDataLoader
GuardDataLoader(Args &&... args)
Definition: 9.1/sources/includes/ds3d/common/hpp/dataloader.hpp:56
ds3d::GuardDataProcess< abiDataLoader >
ds3d::GuardRef< abiCB >::abiRef
abiCB * abiRef() const
Definition: sources/includes/ds3d/common/hpp/obj.hpp:273
ds3d::abiDataLoader::readData_i
virtual ErrCode readData_i(abiRefDataMap *&datamap)=0
ds3d::GuardDataLoader::readDataAsync
ErrCode readDataAsync(abiOnDataCB::CppFunc dataReadyCB)
Definition: 9.1/sources/includes/ds3d/common/hpp/dataloader.hpp:76
ds3d::abiRefT< abiDataMap >
DS_ASSERT
#define DS_ASSERT(...)
Definition: sources/includes/ds3d/common/defines.h:36
ds3d::ErrCode
ErrCode
Definition: sources/includes/ds3d/common/common.h:47
ds3d::GuardCB::setFn
void setFn(F f)
Definition: sources/includes/ds3d/common/hpp/obj.hpp:301
ds3d::GuardRef::reset
void reset(ref *abiref=nullptr)
Definition: sources/includes/ds3d/common/hpp/obj.hpp:264
ds3d::GuardDataT< abiDataLoader >::ptr
abiDataLoader * ptr() const
Definition: sources/includes/ds3d/common/hpp/obj.hpp:365
ds3d::CapsPort::kOutput
@ kOutput
ds3d::GuardDataMap
Definition: sources/includes/ds3d/common/hpp/datamap.hpp:27
ds3d::abiDataLoader::readDataAsync_i
virtual ErrCode readDataAsync_i(const abiOnDataCB *dataReadyCb)=0
ds3d::GuardDataLoader::~GuardDataLoader
~GuardDataLoader()=default
ds3d::cppString
std::string cppString(const char *str, size_t len=0)
Definition: sources/includes/ds3d/common/func_utils.h:112
ds3d
Definition: sources/includes/ds3d/common/abi_dataprocess.h:25
ds3d::abiCallBackT::CppFunc
std::function< void(Args...)> CppFunc
Definition: sources/includes/ds3d/common/abi_obj.h:76
ds3d::GuardDataLoader::getOutputCaps
std::string getOutputCaps()
Definition: 9.1/sources/includes/ds3d/common/hpp/dataloader.hpp:61
ds3d::GuardCB
Definition: sources/includes/ds3d/common/hpp/obj.hpp:289
ds3d::GuardDataLoader::readData
ErrCode readData(GuardDataMap &datamap)
Definition: 9.1/sources/includes/ds3d/common/hpp/dataloader.hpp:67