IDS peak genericC++ v1.14.0
Loading...
Searching...
No Matches
peak_buffer_chunk.hpp
Go to the documentation of this file.
1
10
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
37{
38public:
39 BufferChunk() = delete;
41 BufferChunk(const BufferChunk& other) = delete;
42 BufferChunk& operator=(const BufferChunk& other) = delete;
43 BufferChunk(BufferChunk&& other) = delete;
44 BufferChunk& operator=(BufferChunk&& other) = delete;
45
55 uint64_t ID() const;
56
66 void* BasePtr() const;
67
77 size_t Size() const;
78
88 std::shared_ptr<Buffer> ParentBuffer() const;
89
90private:
91 friend ClassCreator<BufferChunk>;
92 BufferChunk(PEAK_BUFFER_CHUNK_HANDLE bufferChunkHandle, const std::weak_ptr<Buffer>& parentBuffer);
93 PEAK_BUFFER_CHUNK_HANDLE m_backendHandle;
94
95 std::weak_ptr<Buffer> m_parentBuffer;
96};
97
98} /* namespace core */
99} /* namespace peak */
100
101/* Implementation */
102namespace peak
103{
104namespace core
105{
106
108 PEAK_BUFFER_CHUNK_HANDLE bufferChunkHandle, const std::weak_ptr<Buffer>& parentBuffer)
109 : m_backendHandle(bufferChunkHandle)
110 , m_parentBuffer(parentBuffer)
111{}
112
114{
115 (void)PEAK_C_ABI_PREFIX PEAK_BufferChunk_Destruct(m_backendHandle);
116}
117
118inline uint64_t BufferChunk::ID() const
119{
120 return QueryNumericFromCInterfaceFunction<uint64_t>(
121 [&](uint64_t* id) { return PEAK_C_ABI_PREFIX PEAK_BufferChunk_GetID(m_backendHandle, id); });
122}
123
124inline void* BufferChunk::BasePtr() const
125{
126 return QueryNumericFromCInterfaceFunction<void*>(
127 [&](void** basePtr) { return PEAK_C_ABI_PREFIX PEAK_BufferChunk_GetBasePtr(m_backendHandle, basePtr); });
128}
129
130inline size_t BufferChunk::Size() const
131{
132 return QueryNumericFromCInterfaceFunction<size_t>(
133 [&](size_t* size) { return PEAK_C_ABI_PREFIX PEAK_BufferChunk_GetSize(m_backendHandle, size); });
134}
135
136inline std::shared_ptr<Buffer> BufferChunk::ParentBuffer() const
137{
138 return LockOrThrow(m_parentBuffer);
139}
140
141} /* namespace core */
142} /* namespace peak */
std::shared_ptr< Buffer > ParentBuffer() const
Returns the parent buffer.
Definition peak_buffer_chunk.hpp:136
BufferChunk(BufferChunk &&other)=delete
~BufferChunk()
Definition peak_buffer_chunk.hpp:113
uint64_t ID() const
Returns the ID.
Definition peak_buffer_chunk.hpp:118
void * BasePtr() const
Returns the base pointer.
Definition peak_buffer_chunk.hpp:124
BufferChunk & operator=(BufferChunk &&other)=delete
size_t Size() const
Returns the size.
Definition peak_buffer_chunk.hpp:130
BufferChunk & operator=(const BufferChunk &other)=delete
BufferChunk(const BufferChunk &other)=delete
Represents a GenTL buffer module.
Definition peak_buffer.hpp:87
The "core" namespace contains the direct GenAPI and GenTL wrapper.
Definition peak_buffer.hpp:34
The "peak" namespace directly contains convenience functionality like the DeviceManager as well as th...
Definition peak_dynamic_loader.h:33
struct PEAK_BUFFER_CHUNK * PEAK_BUFFER_CHUNK_HANDLE
Definition peak_backend.h:409
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