IDS peak genericC++ v1.15.0
Loading...
Searching...
No Matches
peak_data_stream_descriptor.hpp
Go to the documentation of this file.
1
10
11#pragma once
12
13
17#include <peak/dll_interface/peak_dll_interface_util.hpp>
18
19#include <memory>
20#include <string>
21
22
23namespace peak
24{
25namespace core
26{
27
28class Device;
29
39{
40public:
42 ~DataStreamDescriptor() override = default;
47
49 std::string Key() const;
50
60 std::shared_ptr<Device> ParentDevice() const;
61
72 std::shared_ptr<DataStream> OpenDataStream();
73
83 std::shared_ptr<DataStream> OpenedDataStream() const;
84
85private:
87
88 friend ClassCreator<DataStreamDescriptor>;
90 PEAK_DATA_STREAM_DESCRIPTOR_HANDLE dataStreamDescriptorHandle, const std::weak_ptr<Device>& parentDevice);
92
93 std::weak_ptr<Device> m_parentDevice;
94 std::weak_ptr<DataStream> m_openedDataStream;
95
96 std::string m_key;
97};
98
99} /* namespace core */
100} /* namespace peak */
101
102/* Implementation */
103namespace peak
104{
105namespace core
106{
107
109 PEAK_DATA_STREAM_DESCRIPTOR_HANDLE dataStreamDescriptorHandle, const std::weak_ptr<Device>& parentDevice)
110 : m_backendHandle(dataStreamDescriptorHandle)
111 , m_parentDevice(parentDevice)
112 , m_key(QueryStringFromCInterfaceFunction([&](char* key, size_t* keySize) {
113 return PEAK_C_ABI_PREFIX PEAK_DataStreamDescriptor_GetKey(dataStreamDescriptorHandle, key, keySize);
114 }))
115{}
116
117inline std::string DataStreamDescriptor::Key() const
118{
119 return m_key;
120}
121
122inline std::shared_ptr<Device> DataStreamDescriptor::ParentDevice() const
123{
124 return LockOrThrow(m_parentDevice);
125}
126
127inline std::shared_ptr<DataStream> DataStreamDescriptor::OpenDataStream()
128{
129 auto dataStreamHandle = QueryNumericFromCInterfaceFunction<PEAK_DATA_STREAM_HANDLE>(
130 [&](PEAK_DATA_STREAM_HANDLE* _dataStreamHandle) {
131 return PEAK_C_ABI_PREFIX PEAK_DataStreamDescriptor_OpenDataStream(m_backendHandle, _dataStreamHandle);
132 });
133
134 auto dataStream = std::make_shared<ClassCreator<DataStream>>(dataStreamHandle, m_parentDevice);
135 m_openedDataStream = dataStream;
136 return dataStream;
137}
138
139inline std::shared_ptr<DataStream> DataStreamDescriptor::OpenedDataStream() const
140{
141 return LockOrThrowOpenedModule(m_openedDataStream);
142}
143
145{
146 auto moduleDescriptorHandle = QueryNumericFromCInterfaceFunction<PEAK_MODULE_DESCRIPTOR_HANDLE>(
147 [&](PEAK_MODULE_DESCRIPTOR_HANDLE* _moduleDescriptorHandle) {
149 m_backendHandle, _moduleDescriptorHandle);
150 });
151
152 return moduleDescriptorHandle;
153}
154
155} /* namespace core */
156} /* namespace peak */
std::shared_ptr< DataStream > OpenedDataStream() const
Returns the DataStream that was opened with this DataStreamDescriptor.
Definition peak_data_stream_descriptor.hpp:139
DataStreamDescriptor & operator=(DataStreamDescriptor &&other)=delete
DataStreamDescriptor(DataStreamDescriptor &&other)=delete
DataStreamDescriptor(const DataStreamDescriptor &other)=delete
~DataStreamDescriptor() override=default
std::shared_ptr< DataStream > OpenDataStream()
Opens the data stream.
Definition peak_data_stream_descriptor.hpp:127
std::shared_ptr< Device > ParentDevice() const
Returns the parent device.
Definition peak_data_stream_descriptor.hpp:122
std::string Key() const
Returns the unique key.
Definition peak_data_stream_descriptor.hpp:117
DataStreamDescriptor & operator=(const DataStreamDescriptor &other)=delete
Represents a GenTL Device module, i.e. a local virtual Device proxy for the actual hardware RemoteDev...
Definition peak_device.hpp:56
virtual PEAK_MODULE_DESCRIPTOR_HANDLE ModuleDescriptorHandle() const =0
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_DATA_STREAM * PEAK_DATA_STREAM_HANDLE
Definition peak_backend.h:401
struct PEAK_MODULE_DESCRIPTOR * PEAK_MODULE_DESCRIPTOR_HANDLE
Definition peak_backend.h:417
struct PEAK_DATA_STREAM_DESCRIPTOR * PEAK_DATA_STREAM_DESCRIPTOR_HANDLE
Definition peak_backend.h:397
PEAK_C_API PEAK_DataStreamDescriptor_ToModuleDescriptor(PEAK_DATA_STREAM_DESCRIPTOR_HANDLE dataStreamDescriptorHandle, PEAK_MODULE_DESCRIPTOR_HANDLE *moduleDescriptorHandle)
Casts the given data stream descriptor to a module descriptor.
PEAK_C_API PEAK_DataStreamDescriptor_GetKey(PEAK_DATA_STREAM_DESCRIPTOR_HANDLE dataStreamDescriptorHandle, char *key, size_t *keySize)
Asks the given data stream descriptor for its key.
PEAK_C_API PEAK_DataStreamDescriptor_OpenDataStream(PEAK_DATA_STREAM_DESCRIPTOR_HANDLE dataStreamDescriptorHandle, PEAK_DATA_STREAM_HANDLE *dataStreamHandle)
Opens the data stream being associated with the given data stream descriptor.
#define PEAK_C_ABI_PREFIX
Definition peak_dll_defines.h:16