IDS peak genericC++ v1.17.0
Loading...
Searching...
No Matches
peak_buffer_guard.hpp
Go to the documentation of this file.
1
7
8#pragma once
9
11
15
16#include <memory>
17
18
19namespace peak
20{
21
22namespace core
23{
24
34{
35public:
47 explicit BufferGuard(std::shared_ptr<core::Buffer> buffer);
48
55
56 BufferGuard(const BufferGuard& other) = delete;
57 BufferGuard& operator=(const BufferGuard& other) = delete;
58 BufferGuard(BufferGuard&& other) noexcept = default;
59 BufferGuard& operator=(BufferGuard&& other) noexcept = default;
60
68 PEAK_COMMON_NO_DISCARD std::shared_ptr<core::Buffer> Buffer() const;
69
78
79private:
80 std::shared_ptr<core::Buffer> m_buffer;
81};
82
83} /* namespace core */
84} /* namespace peak */
85
86/* Implementation */
87namespace peak
88{
89namespace core
90{
91
92inline BufferGuard::BufferGuard(std::shared_ptr<core::Buffer> buffer)
93 : m_buffer(std::move(buffer))
94{
95 if (m_buffer == nullptr)
96 {
97 throw InvalidArgumentException("The given buffer is a nullptr!");
98 }
99}
100
102{
103 if (m_buffer)
104 {
105 try
106 {
107 m_buffer->ParentDataStream()->QueueBuffer(m_buffer);
108 }
109 catch (...)
110 {}
111 }
112}
113
114inline std::shared_ptr<core::Buffer> BufferGuard::Buffer() const
115{
116 return m_buffer;
117}
118
120{
121 return m_buffer.get();
122}
123
124} /* namespace core */
125} /* namespace peak */
BufferGuard & operator=(BufferGuard &&other) noexcept=default
BufferGuard(BufferGuard &&other) noexcept=default
PEAK_COMMON_NO_DISCARD core::Buffer * operator->() const
Returns the guarded buffer.
Definition peak_buffer_guard.hpp:119
~BufferGuard()
Requeues the guarded buffer.
Definition peak_buffer_guard.hpp:101
PEAK_COMMON_NO_DISCARD std::shared_ptr< core::Buffer > Buffer() const
Returns the guarded buffer.
Definition peak_buffer_guard.hpp:114
BufferGuard(std::shared_ptr< core::Buffer > buffer)
Creates a buffer guard for the given buffer.
Definition peak_buffer_guard.hpp:92
BufferGuard & operator=(const BufferGuard &other)=delete
BufferGuard(const BufferGuard &other)=delete
Represents a GenTL buffer module.
Definition peak_buffer.hpp:85
The exception thrown for passing an invalid argument to a function.
Definition peak_exception.hpp:118
The "core" namespace contains the direct GenAPI and GenTL wrapper.
Definition peak_buffer.hpp:32
The "peak" namespace directly contains convenience functionality like the DeviceManager as well as th...
Definition peak_buffer.hpp:29
#define PEAK_COMMON_NO_DISCARD
Definition peak_common_defines.h:89