IDS peak genericC++ v1.15.0
Loading...
Searching...
No Matches
peak_system_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>
20
21#include <cstdint>
22#include <functional>
23#include <memory>
24#include <string>
25#include <vector>
26
27
28namespace peak
29{
30namespace core
31{
32
33class ProducerLibrary;
34
44{
45public:
46 SystemDescriptor() = delete;
47 ~SystemDescriptor() override = default;
48 SystemDescriptor(const SystemDescriptor& other) = delete;
52
54 std::string Key() const;
55
89 RawInformation Info(int32_t infoCommand) const;
90
100 std::string DisplayName() const;
101
111 std::string VendorName() const;
112
122 std::string ModelName() const;
123
133 std::string Version() const;
134
144 std::string TLType() const;
145
155 std::string CTIFileName() const;
156
166 std::string CTIFullPath() const;
167
177 uint32_t GenTLVersionMajor() const;
178
188 uint32_t GenTLVersionMinor() const;
189
200
210 std::shared_ptr<ProducerLibrary> ParentLibrary() const;
211
222 std::shared_ptr<System> OpenSystem();
223
233 std::shared_ptr<System> OpenedSystem() const;
234
242 bool IsOpened() const;
243
244private:
246
247 friend ClassCreator<SystemDescriptor>;
249 PEAK_SYSTEM_DESCRIPTOR_HANDLE systemDescriptorHandle, const std::weak_ptr<ProducerLibrary>& parentLibrary);
250 PEAK_SYSTEM_DESCRIPTOR_HANDLE m_backendHandle;
251
252 std::weak_ptr<ProducerLibrary> m_parentLibrary;
253 std::weak_ptr<System> m_openedSystem;
254
255 std::string m_key;
256};
257
258} /* namespace core */
259} /* namespace peak */
260
261/* Implementation */
262namespace peak
263{
264namespace core
265{
266
268 PEAK_SYSTEM_DESCRIPTOR_HANDLE systemDescriptorHandle, const std::weak_ptr<ProducerLibrary>& parentLibrary)
269 : m_backendHandle(systemDescriptorHandle)
270 , m_parentLibrary(parentLibrary)
271 , m_key(QueryStringFromCInterfaceFunction([&](char* key, size_t* keySize) {
272 return PEAK_C_ABI_PREFIX PEAK_SystemDescriptor_GetKey(systemDescriptorHandle, key, keySize);
273 }))
274{}
275
276inline std::string SystemDescriptor::Key() const
277{
278 return m_key;
279}
280
281inline RawInformation SystemDescriptor::Info(int32_t infoCommand) const
282{
283 return QueryRawInformationFromCInterfaceFunction([&](int32_t* dataType, uint8_t* buffer, size_t* bufferSize) {
285 m_backendHandle, infoCommand, dataType, buffer, bufferSize);
286 });
287}
288
289inline std::string SystemDescriptor::DisplayName() const
290{
291 return QueryStringFromCInterfaceFunction([&](char* displayName, size_t* displayNameSize) {
293 m_backendHandle, displayName, displayNameSize);
294 });
295}
296
297inline std::string SystemDescriptor::VendorName() const
298{
299 return QueryStringFromCInterfaceFunction([&](char* vendorName, size_t* vendorNameSize) {
300 return PEAK_C_ABI_PREFIX PEAK_SystemDescriptor_GetVendorName(m_backendHandle, vendorName, vendorNameSize);
301 });
302}
303
304inline std::string SystemDescriptor::ModelName() const
305{
306 return QueryStringFromCInterfaceFunction([&](char* modelName, size_t* modelNameSize) {
307 return PEAK_C_ABI_PREFIX PEAK_SystemDescriptor_GetModelName(m_backendHandle, modelName, modelNameSize);
308 });
309}
310
311inline std::string SystemDescriptor::Version() const
312{
313 return QueryStringFromCInterfaceFunction([&](char* version, size_t* versionSize) {
314 return PEAK_C_ABI_PREFIX PEAK_SystemDescriptor_GetVersion(m_backendHandle, version, versionSize);
315 });
316}
317
318inline std::string SystemDescriptor::TLType() const
319{
320 return QueryStringFromCInterfaceFunction([&](char* tlType, size_t* tlTypeSize) {
321 return PEAK_C_ABI_PREFIX PEAK_SystemDescriptor_GetTLType(m_backendHandle, tlType, tlTypeSize);
322 });
323}
324
325inline std::string SystemDescriptor::CTIFileName() const
326{
327 return QueryStringFromCInterfaceFunction([&](char* ctiFileName, size_t* ctiFileNameSize) {
329 m_backendHandle, ctiFileName, ctiFileNameSize);
330 });
331}
332
333inline std::string SystemDescriptor::CTIFullPath() const
334{
335 return QueryStringFromCInterfaceFunction([&](char* ctiFullPath, size_t* ctiFullPathSize) {
337 m_backendHandle, ctiFullPath, ctiFullPathSize);
338 });
339}
340
342{
343 return QueryNumericFromCInterfaceFunction<uint32_t>([&](uint32_t* gentlVersionMajor) {
344 return PEAK_C_ABI_PREFIX PEAK_SystemDescriptor_GetGenTLVersionMajor(m_backendHandle, gentlVersionMajor);
345 });
346}
347
349{
350 return QueryNumericFromCInterfaceFunction<uint32_t>([&](uint32_t* gentlVersionMinor) {
351 return PEAK_C_ABI_PREFIX PEAK_SystemDescriptor_GetGenTLVersionMinor(m_backendHandle, gentlVersionMinor);
352 });
353}
354
356{
357 return static_cast<peak::core::CharacterEncoding>(
358 QueryNumericFromCInterfaceFunction<PEAK_CHARACTER_ENCODING>(
359 [&](PEAK_CHARACTER_ENCODING* characterEncoding) {
361 m_backendHandle, characterEncoding);
362 }));
363}
364
365inline std::shared_ptr<ProducerLibrary> SystemDescriptor::ParentLibrary() const
366{
367 return LockOrThrow(m_parentLibrary);
368}
369
370inline std::shared_ptr<System> SystemDescriptor::OpenSystem()
371{
372 auto systemHandle = QueryNumericFromCInterfaceFunction<PEAK_SYSTEM_HANDLE>(
373 [&](PEAK_SYSTEM_HANDLE* _systemHandle) {
374 return PEAK_C_ABI_PREFIX PEAK_SystemDescriptor_OpenSystem(m_backendHandle, _systemHandle);
375 });
376
377 auto system = std::make_shared<ClassCreator<System>>(systemHandle, m_parentLibrary);
378 m_openedSystem = system;
379 return system;
380}
381
382inline std::shared_ptr<System> SystemDescriptor::OpenedSystem() const
383{
384 return LockOrThrowOpenedModule(m_openedSystem);
385}
386
387inline bool SystemDescriptor::IsOpened() const
388{
389 return !m_openedSystem.expired();
390}
391
393{
394 auto moduleDescriptorHandle = QueryNumericFromCInterfaceFunction<PEAK_MODULE_DESCRIPTOR_HANDLE>(
395 [&](PEAK_MODULE_DESCRIPTOR_HANDLE* _moduleDescriptorHandle) {
397 m_backendHandle, _moduleDescriptorHandle);
398 });
399
400 return moduleDescriptorHandle;
401}
402
403
404
405} /* namespace core */
406} /* namespace peak */
virtual PEAK_MODULE_DESCRIPTOR_HANDLE ModuleDescriptorHandle() const =0
Represents a GenTL producer library (CTI).
Definition peak_producer_library.hpp:40
std::shared_ptr< System > OpenSystem()
Opens the system.
Definition peak_system_descriptor.hpp:370
SystemDescriptor & operator=(const SystemDescriptor &other)=delete
std::shared_ptr< System > OpenedSystem() const
Returns the System that was opened with this SystemDescriptor.
Definition peak_system_descriptor.hpp:382
std::string ModelName() const
Returns the model name.
Definition peak_system_descriptor.hpp:304
uint32_t GenTLVersionMajor() const
Returns the GenTL major version of the GenTL producer library this system belongs to.
Definition peak_system_descriptor.hpp:341
uint32_t GenTLVersionMinor() const
Returns the GenTL minor version of the GenTL producer library this system belongs to.
Definition peak_system_descriptor.hpp:348
std::string Key() const
Returns the unique key.
Definition peak_system_descriptor.hpp:276
std::string DisplayName() const
Returns the display name.
Definition peak_system_descriptor.hpp:289
peak::core::CharacterEncoding CharacterEncoding() const
Returns the character encoding of the GenTL producer library this system belongs to.
Definition peak_system_descriptor.hpp:355
bool IsOpened() const
Returns if the system is currently opened or not.
Definition peak_system_descriptor.hpp:387
SystemDescriptor & operator=(SystemDescriptor &&other)=delete
std::string Version() const
Returns the version.
Definition peak_system_descriptor.hpp:311
std::string CTIFullPath() const
Returns the full path of the GenTL producer library this system belongs to.
Definition peak_system_descriptor.hpp:333
std::string VendorName() const
Returns the vendor name.
Definition peak_system_descriptor.hpp:297
RawInformation Info(int32_t infoCommand) const
Delivers information based on the given GenTL info command.
Definition peak_system_descriptor.hpp:281
std::shared_ptr< ProducerLibrary > ParentLibrary() const
Returns the parent library.
Definition peak_system_descriptor.hpp:365
std::string TLType() const
Returns the TL (transport layer) type.
Definition peak_system_descriptor.hpp:318
std::string CTIFileName() const
Returns the file name of the GenTL producer library this system belongs to.
Definition peak_system_descriptor.hpp:325
~SystemDescriptor() override=default
SystemDescriptor(const SystemDescriptor &other)=delete
SystemDescriptor(SystemDescriptor &&other)=delete
The "core" namespace contains the direct GenAPI and GenTL wrapper.
Definition peak_buffer.hpp:34
CharacterEncoding
Possible character encodings.
Definition peak_common_system_enums.hpp:25
The "peak" namespace directly contains convenience functionality like the DeviceManager as well as th...
Definition peak_dynamic_loader.h:33
PEAK_C_API PEAK_SystemDescriptor_GetKey(PEAK_SYSTEM_DESCRIPTOR_HANDLE systemDescriptorHandle, char *key, size_t *keySize)
Asks the given system descriptor for its key.
struct PEAK_SYSTEM_DESCRIPTOR * PEAK_SYSTEM_DESCRIPTOR_HANDLE
Definition peak_backend.h:369
struct PEAK_MODULE_DESCRIPTOR * PEAK_MODULE_DESCRIPTOR_HANDLE
Definition peak_backend.h:417
PEAK_C_API PEAK_SystemDescriptor_GetCTIFullPath(PEAK_SYSTEM_DESCRIPTOR_HANDLE systemDescriptorHandle, char *ctiFullPath, size_t *ctiFullPathSize)
Asks the given system descriptor for its parent CTI's full path.
PEAK_C_API PEAK_SystemDescriptor_GetModelName(PEAK_SYSTEM_DESCRIPTOR_HANDLE systemDescriptorHandle, char *modelName, size_t *modelNameSize)
Asks the given system descriptor for its model name.
PEAK_C_API PEAK_SystemDescriptor_GetTLType(PEAK_SYSTEM_DESCRIPTOR_HANDLE systemDescriptorHandle, char *tlType, size_t *tlTypeSize)
Asks the given system descriptor for its TL type.
struct PEAK_SYSTEM * PEAK_SYSTEM_HANDLE
Definition peak_backend.h:373
PEAK_C_API PEAK_SystemDescriptor_OpenSystem(PEAK_SYSTEM_DESCRIPTOR_HANDLE systemDescriptorHandle, PEAK_SYSTEM_HANDLE *systemHandle)
Opens the system being associated with the given system descriptor.
PEAK_C_API PEAK_SystemDescriptor_GetCharacterEncoding(PEAK_SYSTEM_DESCRIPTOR_HANDLE systemDescriptorHandle, PEAK_CHARACTER_ENCODING *characterEncoding)
Asks the given system descriptor for its character encoding.
PEAK_C_API PEAK_SystemDescriptor_GetInfo(PEAK_SYSTEM_DESCRIPTOR_HANDLE systemDescriptorHandle, int32_t infoCommand, int32_t *infoDataType, uint8_t *info, size_t *infoSize)
Asks the given system descriptor for an information based on a specific command.
PEAK_C_API PEAK_SystemDescriptor_GetVendorName(PEAK_SYSTEM_DESCRIPTOR_HANDLE systemDescriptorHandle, char *vendorName, size_t *vendorNameSize)
Asks the given system descriptor for its vendor name.
PEAK_C_API PEAK_SystemDescriptor_GetGenTLVersionMinor(PEAK_SYSTEM_DESCRIPTOR_HANDLE systemDescriptorHandle, uint32_t *gentlVersionMinor)
Asks the given system descriptor for the minor component of its GenTL version.
PEAK_C_API PEAK_SystemDescriptor_GetDisplayName(PEAK_SYSTEM_DESCRIPTOR_HANDLE systemDescriptorHandle, char *displayName, size_t *displayNameSize)
Asks the given system descriptor for its display name.
PEAK_C_API PEAK_SystemDescriptor_GetGenTLVersionMajor(PEAK_SYSTEM_DESCRIPTOR_HANDLE systemDescriptorHandle, uint32_t *gentlVersionMajor)
Asks the given system descriptor for the major component of its GenTL version.
int32_t PEAK_CHARACTER_ENCODING
Definition peak_backend.h:107
PEAK_C_API PEAK_SystemDescriptor_GetCTIFileName(PEAK_SYSTEM_DESCRIPTOR_HANDLE systemDescriptorHandle, char *ctiFileName, size_t *ctiFileNameSize)
Asks the given system descriptor for its parent CTI's file name.
PEAK_C_API PEAK_SystemDescriptor_GetVersion(PEAK_SYSTEM_DESCRIPTOR_HANDLE systemDescriptorHandle, char *version, size_t *versionSize)
Asks the given system descriptor for its version.
PEAK_C_API PEAK_SystemDescriptor_ToModuleDescriptor(PEAK_SYSTEM_DESCRIPTOR_HANDLE systemDescriptorHandle, PEAK_MODULE_DESCRIPTOR_HANDLE *moduleDescriptorHandle)
Casts the given system descriptor to a module descriptor.
#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