NVIDIA DeepStream SDK API Reference

7.0 Release
memdata.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2021-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: LicenseRef-NvidiaProprietary
4  *
5  * NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
6  * property and proprietary rights in and to this material, related
7  * documentation and any modifications thereto. Any use, reproduction,
8  * disclosure or distribution of this material and related documentation
9  * without an express license agreement from NVIDIA CORPORATION or
10  * its affiliates is strictly prohibited.
11  */
12 
13 
14 #ifndef DS3D_COMMON_HELPER_MEMDATA_H
15 #define DS3D_COMMON_HELPER_MEMDATA_H
16 
18 
19 namespace ds3d {
20 
21 struct MemData {
22  void* data = nullptr;
23  size_t byteSize = 0;
24  int devId = 0;
26  MemData() = default;
27  virtual ~MemData() = default;
28 
29 protected:
31 };
32 
33 class CpuMemBuf : public MemData {
34 public:
35  CpuMemBuf() {}
36  static std::unique_ptr<CpuMemBuf> CreateBuf(size_t size)
37  {
38  auto mem = std::make_unique<CpuMemBuf>();
39  void* data = malloc(size);
40  if (!data) {
41  LOG_ERROR("DS3D, malloc out of memory");
42  return nullptr;
43  }
44  mem->data = data;
45  mem->byteSize = size;
46  mem->devId = 0;
47  mem->type = MemType::kCpu;
48  return mem;
49  }
51  {
52  if (data) {
53  free(data);
54  }
55  }
56 };
57 
58 };
59 #endif
ds3d::MemData::data
void * data
Definition: memdata.h:22
ds3d::MemData
Definition: memdata.h:21
ds3d::MemType::kCpu
@ kCpu
ds3d::MemData::type
MemType type
Definition: memdata.h:25
ds3d::CpuMemBuf::CpuMemBuf
CpuMemBuf()
Definition: memdata.h:35
ds3d::MemData::byteSize
size_t byteSize
Definition: memdata.h:23
ds3d::MemData::DS3D_DISABLE_CLASS_COPY
DS3D_DISABLE_CLASS_COPY(MemData)
LOG_ERROR
#define LOG_ERROR
Definition: logging.h:16
ds3d::CpuMemBuf::~CpuMemBuf
~CpuMemBuf()
Definition: memdata.h:50
ds3d::MemData::devId
int devId
Definition: memdata.h:24
ds3d::MemData::~MemData
virtual ~MemData()=default
safe_queue.h
ds3d::CpuMemBuf::CreateBuf
static std::unique_ptr< CpuMemBuf > CreateBuf(size_t size)
Definition: memdata.h:36
ds3d::CpuMemBuf
Definition: memdata.h:33
ds3d
Definition: lidar_3d_datatype.h:35
ds3d::MemType
MemType
Definition: idatatype.h:101
ds3d::MemData::MemData
MemData()=default