IDS peak genericC++ v1.11.1
Loading...
Searching...
No Matches
peak_interface_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>
19
20#include <cstdint>
21#include <memory>
22#include <string>
23
24
25namespace peak
26{
27namespace core
28{
29
30class System;
31
40{
41public:
43 ~InterfaceDescriptor() override = default;
48
50 std::string Key() const;
51
53 RawInformation Info(int32_t infoCommand) const;
64 std::string DisplayName() const;
65
67 std::string TLType() const;
68
79 std::shared_ptr<System> ParentSystem() const;
80
91 std::shared_ptr<Interface> OpenInterface();
92
102 std::shared_ptr<Interface> OpenedInterface() const;
103
104private:
105 PEAK_MODULE_DESCRIPTOR_HANDLE ModuleDescriptorHandle() const override;
106
107 friend ClassCreator<InterfaceDescriptor>;
109 PEAK_INTERFACE_DESCRIPTOR_HANDLE interfaceDescriptorHandle, const std::weak_ptr<System>& parentSystem);
110 PEAK_INTERFACE_DESCRIPTOR_HANDLE m_backendHandle;
111
112 std::weak_ptr<System> m_parentSystem;
113 std::weak_ptr<Interface> m_openedInterface;
114
115 std::string m_key;
116};
117
118} /* namespace core */
119} /* namespace peak */
120
121/* Implementation */
122namespace peak
123{
124namespace core
125{
126
128 PEAK_INTERFACE_DESCRIPTOR_HANDLE interfaceDescriptorHandle, const std::weak_ptr<System>& parentSystem)
129 : m_backendHandle(interfaceDescriptorHandle)
130 , m_parentSystem(parentSystem)
131 , m_key(QueryStringFromCInterfaceFunction([&](char* key, size_t* keySize) {
132 return PEAK_C_ABI_PREFIX PEAK_InterfaceDescriptor_GetKey(interfaceDescriptorHandle, key, keySize);
133 }))
134{}
135
136inline std::string InterfaceDescriptor::Key() const
137{
138 return m_key;
139}
140
141inline RawInformation InterfaceDescriptor::Info(int32_t infoCommand) const
142{
143 return QueryRawInformationFromCInterfaceFunction([&](int32_t* dataType, uint8_t* buffer, size_t* bufferSize) {
145 m_backendHandle, infoCommand, dataType, buffer, bufferSize);
146 });
147}
148
149inline std::string InterfaceDescriptor::DisplayName() const
150{
151 return QueryStringFromCInterfaceFunction([&](char* displayName, size_t* displayNameSize) {
153 m_backendHandle, displayName, displayNameSize);
154 });
155}
156
157inline std::string InterfaceDescriptor::TLType() const
158{
159 return QueryStringFromCInterfaceFunction([&](char* tlType, size_t* tlTypeSize) {
160 return PEAK_C_ABI_PREFIX PEAK_InterfaceDescriptor_GetTLType(m_backendHandle, tlType, tlTypeSize);
161 });
162}
163
164inline std::shared_ptr<System> InterfaceDescriptor::ParentSystem() const
165{
166 return LockOrThrow(m_parentSystem);
167}
168
169inline std::shared_ptr<Interface> InterfaceDescriptor::OpenInterface()
170{
171 auto interfaceHandle = QueryNumericFromCInterfaceFunction<PEAK_INTERFACE_HANDLE>(
172 [&](PEAK_INTERFACE_HANDLE* _interfaceHandle) {
173 return PEAK_C_ABI_PREFIX PEAK_InterfaceDescriptor_OpenInterface(m_backendHandle, _interfaceHandle);
174 });
175
176 auto interface_ = std::make_shared<ClassCreator<Interface>>(interfaceHandle, m_parentSystem);
177 m_openedInterface = interface_;
178
179 return interface_;
180}
181
182inline std::shared_ptr<Interface> InterfaceDescriptor::OpenedInterface() const
183{
184 return LockOrThrowOpenedModule(m_openedInterface);
185}
186
187inline PEAK_MODULE_DESCRIPTOR_HANDLE InterfaceDescriptor::ModuleDescriptorHandle() const
188{
189 auto moduleDescriptorHandle = QueryNumericFromCInterfaceFunction<PEAK_MODULE_DESCRIPTOR_HANDLE>(
190 [&](PEAK_MODULE_DESCRIPTOR_HANDLE* _moduleDescriptorHandle) {
192 m_backendHandle, _moduleDescriptorHandle);
193 });
194
195 return moduleDescriptorHandle;
196}
197
198} /* namespace core */
199} /* namespace peak */
std::string TLType() const
Returns the TL (transport layer) type.
Definition peak_interface_descriptor.hpp:157
InterfaceDescriptor(InterfaceDescriptor &&other)=delete
std::shared_ptr< System > ParentSystem() const
Returns the parent system.
Definition peak_interface_descriptor.hpp:164
std::string DisplayName() const
Returns the display name.
Definition peak_interface_descriptor.hpp:149
InterfaceDescriptor(const InterfaceDescriptor &other)=delete
RawInformation Info(int32_t infoCommand) const
Delivers information based on the given GenTL info command.
Definition peak_interface_descriptor.hpp:141
std::shared_ptr< Interface > OpenedInterface() const
Returns the Interface that was opened with this InterfaceDescriptor.
Definition peak_interface_descriptor.hpp:182
InterfaceDescriptor & operator=(InterfaceDescriptor &&other)=delete
InterfaceDescriptor & operator=(const InterfaceDescriptor &other)=delete
std::string Key() const
Returns the unique key.
Definition peak_interface_descriptor.hpp:136
~InterfaceDescriptor() override=default
std::shared_ptr< Interface > OpenInterface()
Opens the interface.
Definition peak_interface_descriptor.hpp:169
Represents a GenTL System module.
Definition peak_system.hpp:51
The "core" namespace contains the direct GenAPI and GenTL wrapper.
Definition peak_buffer.hpp:31
The "peak" namespace directly contains convenience functionality like the DeviceManager as well as th...
Definition peak_dynamic_loader.h:33
PEAK_C_API PEAK_InterfaceDescriptor_OpenInterface(PEAK_INTERFACE_DESCRIPTOR_HANDLE interfaceDescriptorHandle, PEAK_INTERFACE_HANDLE *interfaceHandle)
Opens the interface being associated with the given interface descriptor.
struct PEAK_MODULE_DESCRIPTOR * PEAK_MODULE_DESCRIPTOR_HANDLE
Definition peak_backend.h:417
PEAK_C_API PEAK_InterfaceDescriptor_ToModuleDescriptor(PEAK_INTERFACE_DESCRIPTOR_HANDLE interfaceDescriptorHandle, PEAK_MODULE_DESCRIPTOR_HANDLE *moduleDescriptorHandle)
Casts the given interface descriptor to a module descriptor.
struct PEAK_INTERFACE_DESCRIPTOR * PEAK_INTERFACE_DESCRIPTOR_HANDLE
Definition peak_backend.h:377
PEAK_C_API PEAK_InterfaceDescriptor_GetKey(PEAK_INTERFACE_DESCRIPTOR_HANDLE interfaceDescriptorHandle, char *key, size_t *keySize)
Asks the given interface descriptor for its key.
struct PEAK_INTERFACE * PEAK_INTERFACE_HANDLE
Definition peak_backend.h:381
PEAK_C_API PEAK_InterfaceDescriptor_GetInfo(PEAK_INTERFACE_DESCRIPTOR_HANDLE interfaceDescriptorHandle, int32_t infoCommand, int32_t *infoDataType, uint8_t *info, size_t *infoSize)
Asks the given interface descriptor for an information based on a specific command.
PEAK_C_API PEAK_InterfaceDescriptor_GetDisplayName(PEAK_INTERFACE_DESCRIPTOR_HANDLE interfaceDescriptorHandle, char *displayName, size_t *displayNameSize)
Asks the given interface descriptor for its display name.
PEAK_C_API PEAK_InterfaceDescriptor_GetTLType(PEAK_INTERFACE_DESCRIPTOR_HANDLE interfaceDescriptorHandle, char *tlType, size_t *tlTypeSize)
Asks the given interface descriptor for its TL type.
#define PEAK_C_ABI_PREFIX
Definition peak_dll_defines.h:16
The struct returned by all raw information functions.
Definition peak_common_structs.hpp:25