IDS peak genericC++ v1.7.3
Loading...
Searching...
No Matches
peak_buffer_chunk.hpp
Go to the documentation of this file.
1
11#pragma once
12
13
15#include <peak/dll_interface/peak_dll_interface_util.hpp>
16
17#include <cstddef>
18#include <cstdint>
19#include <memory>
20
21
22namespace peak
23{
24namespace core
25{
26
27class Buffer;
28
36{
37public:
38 BufferChunk() = delete;
40 BufferChunk(const BufferChunk& other) = delete;
41 BufferChunk& operator=(const BufferChunk& other) = delete;
42 BufferChunk(BufferChunk&& other) = delete;
43 BufferChunk& operator=(BufferChunk&& other) = delete;
44
54 uint64_t ID() const;
55
65 void* BasePtr() const;
66
76 size_t Size() const;
77
87 std::shared_ptr<Buffer> ParentBuffer() const;
88
89private:
90 friend ClassCreator<BufferChunk>;
91 BufferChunk(PEAK_BUFFER_CHUNK_HANDLE bufferChunkHandle, const std::weak_ptr<Buffer>& parentBuffer);
92 PEAK_BUFFER_CHUNK_HANDLE m_backendHandle;
93
94 std::weak_ptr<Buffer> m_parentBuffer;
95};
96
97} /* namespace core */
98} /* namespace peak */
99
100/* Implementation */
101namespace peak
102{
103namespace core
104{
105
107 PEAK_BUFFER_CHUNK_HANDLE bufferChunkHandle, const std::weak_ptr<Buffer>& parentBuffer)
108 : m_backendHandle(bufferChunkHandle)
109 , m_parentBuffer(parentBuffer)
110{}
111
113{
114 (void)PEAK_C_ABI_PREFIX PEAK_BufferChunk_Destruct(m_backendHandle);
115}
116
117inline uint64_t BufferChunk::ID() const
118{
119 return QueryNumericFromCInterfaceFunction<uint64_t>(
120 [&](uint64_t* id) { return PEAK_C_ABI_PREFIX PEAK_BufferChunk_GetID(m_backendHandle, id); });
121}
122
123inline void* BufferChunk::BasePtr() const
124{
125 return QueryNumericFromCInterfaceFunction<void*>(
126 [&](void** basePtr) { return PEAK_C_ABI_PREFIX PEAK_BufferChunk_GetBasePtr(m_backendHandle, basePtr); });
127}
128
129inline size_t BufferChunk::Size() const
130{
131 return QueryNumericFromCInterfaceFunction<size_t>(
132 [&](size_t* size) { return PEAK_C_ABI_PREFIX PEAK_BufferChunk_GetSize(m_backendHandle, size); });
133}
134
135inline std::shared_ptr<Buffer> BufferChunk::ParentBuffer() const
136{
137 return LockOrThrow(m_parentBuffer);
138}
139
140} /* namespace core */
141} /* namespace peak */
Represents a buffer chunk.
Definition peak_buffer_chunk.hpp:36
std::shared_ptr< Buffer > ParentBuffer() const
Returns the parent buffer.
Definition peak_buffer_chunk.hpp:135
BufferChunk(BufferChunk &&other)=delete
~BufferChunk()
Definition peak_buffer_chunk.hpp:112
uint64_t ID() const
Returns the ID.
Definition peak_buffer_chunk.hpp:117
void * BasePtr() const
Returns the base pointer.
Definition peak_buffer_chunk.hpp:123
BufferChunk & operator=(BufferChunk &&other)=delete
size_t Size() const
Returns the size.
Definition peak_buffer_chunk.hpp:129
BufferChunk & operator=(const BufferChunk &other)=delete
BufferChunk(const BufferChunk &other)=delete
The "peak" namespace directly contains convenience functionality like the DeviceManager as well as th...
Definition peak_dynamic_loader.h:32
struct PEAK_BUFFER_CHUNK * PEAK_BUFFER_CHUNK_HANDLE
Definition peak_backend.h:391
PEAK_C_API PEAK_BufferChunk_GetID(PEAK_BUFFER_CHUNK_HANDLE bufferChunkHandle, uint64_t *id)
Asks the given buffer chunk for its ID.
PEAK_C_API PEAK_BufferChunk_GetBasePtr(PEAK_BUFFER_CHUNK_HANDLE bufferChunkHandle, void **basePtr)
Asks the given buffer chunk for its base pointer.
PEAK_C_API PEAK_BufferChunk_GetSize(PEAK_BUFFER_CHUNK_HANDLE bufferChunkHandle, size_t *size)
Asks the given buffer chunk for its size.
PEAK_C_API PEAK_BufferChunk_Destruct(PEAK_BUFFER_CHUNK_HANDLE bufferChunkHandle)
Destroys the given buffer chunk.
#define PEAK_C_ABI_PREFIX
Definition peak_dll_defines.h:16