IDS peak genericC++ v1.17.0
Loading...
Searching...
No Matches
peak_system_descriptor.hpp
Go to the documentation of this file.
1
6
7#pragma once
8
10
14#include <peak/dll_interface/peak_dll_interface_util.hpp>
17
18#include <cstdint>
19#include <functional>
20#include <memory>
21#include <string>
22#include <vector>
23
24
25namespace peak
26{
27namespace core
28{
29
30class ProducerLibrary;
31
41{
42public:
43 SystemDescriptor() = delete;
44 ~SystemDescriptor() override = default;
45 SystemDescriptor(const SystemDescriptor& other) = delete;
49
51 PEAK_COMMON_NO_DISCARD std::string Key() const;
52
86 PEAK_COMMON_NO_DISCARD RawInformation Info(int32_t infoCommand) const;
87
97 PEAK_COMMON_NO_DISCARD std::string DisplayName() const;
98
108 PEAK_COMMON_NO_DISCARD std::string VendorName() const;
109
119 PEAK_COMMON_NO_DISCARD std::string ModelName() const;
120
130 PEAK_COMMON_NO_DISCARD std::string Version() const;
131
141 PEAK_COMMON_NO_DISCARD std::string TLType() const;
142
152 PEAK_COMMON_NO_DISCARD std::string CTIFileName() const;
153
163 PEAK_COMMON_NO_DISCARD std::string CTIFullPath() const;
164
175
186
197
207 PEAK_COMMON_NO_DISCARD std::shared_ptr<ProducerLibrary> ParentLibrary() const;
208
219 PEAK_COMMON_NO_DISCARD std::shared_ptr<System> OpenSystem();
220
230 PEAK_COMMON_NO_DISCARD std::shared_ptr<System> OpenedSystem() const;
231
242 PEAK_COMMON_NO_DISCARD std::shared_ptr<System> EnsureOpenedSystem();
243
251 PEAK_COMMON_NO_DISCARD bool IsOpened() const;
252
253private:
255
256 friend ClassCreator<SystemDescriptor>;
258 PEAK_SYSTEM_DESCRIPTOR_HANDLE systemDescriptorHandle, const std::weak_ptr<ProducerLibrary>& parentLibrary);
259 PEAK_SYSTEM_DESCRIPTOR_HANDLE m_backendHandle;
260
261 std::weak_ptr<ProducerLibrary> m_parentLibrary;
262 std::weak_ptr<System> m_openedSystem;
263
264 std::string m_key;
265};
266
267} /* namespace core */
268} /* namespace peak */
269
270/* Implementation */
271namespace peak
272{
273namespace core
274{
275
277 PEAK_SYSTEM_DESCRIPTOR_HANDLE systemDescriptorHandle, const std::weak_ptr<ProducerLibrary>& parentLibrary)
278 : m_backendHandle(systemDescriptorHandle)
279 , m_parentLibrary(parentLibrary)
280 , m_key(QueryStringFromCInterfaceFunction([&](char* key, size_t* keySize) {
281 return PEAK_C_ABI_PREFIX PEAK_SystemDescriptor_GetKey(systemDescriptorHandle, key, keySize);
282 }))
283{}
284
285inline std::string SystemDescriptor::Key() const
286{
287 return m_key;
288}
289
290inline RawInformation SystemDescriptor::Info(int32_t infoCommand) const
291{
292 return QueryRawInformationFromCInterfaceFunction([&](int32_t* dataType, uint8_t* buffer, size_t* bufferSize) {
294 m_backendHandle, infoCommand, dataType, buffer, bufferSize);
295 });
296}
297
298inline std::string SystemDescriptor::DisplayName() const
299{
300 return QueryStringFromCInterfaceFunction([&](char* displayName, size_t* displayNameSize) {
302 m_backendHandle, displayName, displayNameSize);
303 });
304}
305
306inline std::string SystemDescriptor::VendorName() const
307{
308 return QueryStringFromCInterfaceFunction([&](char* vendorName, size_t* vendorNameSize) {
309 return PEAK_C_ABI_PREFIX PEAK_SystemDescriptor_GetVendorName(m_backendHandle, vendorName, vendorNameSize);
310 });
311}
312
313inline std::string SystemDescriptor::ModelName() const
314{
315 return QueryStringFromCInterfaceFunction([&](char* modelName, size_t* modelNameSize) {
316 return PEAK_C_ABI_PREFIX PEAK_SystemDescriptor_GetModelName(m_backendHandle, modelName, modelNameSize);
317 });
318}
319
320inline std::string SystemDescriptor::Version() const
321{
322 return QueryStringFromCInterfaceFunction([&](char* version, size_t* versionSize) {
323 return PEAK_C_ABI_PREFIX PEAK_SystemDescriptor_GetVersion(m_backendHandle, version, versionSize);
324 });
325}
326
327inline std::string SystemDescriptor::TLType() const
328{
329 return QueryStringFromCInterfaceFunction([&](char* tlType, size_t* tlTypeSize) {
330 return PEAK_C_ABI_PREFIX PEAK_SystemDescriptor_GetTLType(m_backendHandle, tlType, tlTypeSize);
331 });
332}
333
334inline std::string SystemDescriptor::CTIFileName() const
335{
336 return QueryStringFromCInterfaceFunction([&](char* ctiFileName, size_t* ctiFileNameSize) {
338 m_backendHandle, ctiFileName, ctiFileNameSize);
339 });
340}
341
342inline std::string SystemDescriptor::CTIFullPath() const
343{
344 return QueryStringFromCInterfaceFunction([&](char* ctiFullPath, size_t* ctiFullPathSize) {
346 m_backendHandle, ctiFullPath, ctiFullPathSize);
347 });
348}
349
351{
352 return QueryNumericFromCInterfaceFunction<uint32_t>([&](uint32_t* gentlVersionMajor) {
353 return PEAK_C_ABI_PREFIX PEAK_SystemDescriptor_GetGenTLVersionMajor(m_backendHandle, gentlVersionMajor);
354 });
355}
356
358{
359 return QueryNumericFromCInterfaceFunction<uint32_t>([&](uint32_t* gentlVersionMinor) {
360 return PEAK_C_ABI_PREFIX PEAK_SystemDescriptor_GetGenTLVersionMinor(m_backendHandle, gentlVersionMinor);
361 });
362}
363
365{
366 return static_cast<peak::core::CharacterEncoding>(
367 QueryNumericFromCInterfaceFunction<PEAK_CHARACTER_ENCODING>(
368 [&](PEAK_CHARACTER_ENCODING* characterEncoding) {
370 m_backendHandle, characterEncoding);
371 }));
372}
373
374inline std::shared_ptr<ProducerLibrary> SystemDescriptor::ParentLibrary() const
375{
376 return LockOrThrow(m_parentLibrary);
377}
378
379inline std::shared_ptr<System> SystemDescriptor::OpenSystem()
380{
381 auto systemHandle = QueryNumericFromCInterfaceFunction<PEAK_SYSTEM_HANDLE>(
382 [&](PEAK_SYSTEM_HANDLE* _systemHandle) {
383 return PEAK_C_ABI_PREFIX PEAK_SystemDescriptor_OpenSystem(m_backendHandle, _systemHandle);
384 });
385
386 auto system = std::make_shared<ClassCreator<System>>(systemHandle, m_parentLibrary);
387 m_openedSystem = system;
388 return system;
389}
390
391inline std::shared_ptr<System> SystemDescriptor::OpenedSystem() const
392{
393 return LockOrThrowOpenedModule(m_openedSystem);
394}
395
396inline std::shared_ptr<System> SystemDescriptor::EnsureOpenedSystem()
397{
398 return IsOpened() ? OpenedSystem() : OpenSystem();
399}
400
401inline bool SystemDescriptor::IsOpened() const
402{
403 return !m_openedSystem.expired();
404}
405
407{
408 auto moduleDescriptorHandle = QueryNumericFromCInterfaceFunction<PEAK_MODULE_DESCRIPTOR_HANDLE>(
409 [&](PEAK_MODULE_DESCRIPTOR_HANDLE* _moduleDescriptorHandle) {
411 m_backendHandle, _moduleDescriptorHandle);
412 });
413
414 return moduleDescriptorHandle;
415}
416
417
418} /* namespace core */
419} /* namespace peak */
virtual PEAK_MODULE_DESCRIPTOR_HANDLE ModuleDescriptorHandle() const =0
Represents a GenTL producer library (CTI).
Definition peak_producer_library.hpp:37
PEAK_COMMON_NO_DISCARD std::shared_ptr< System > OpenSystem()
Opens the system.
Definition peak_system_descriptor.hpp:379
SystemDescriptor & operator=(const SystemDescriptor &other)=delete
PEAK_COMMON_NO_DISCARD std::shared_ptr< System > OpenedSystem() const
Returns the System that was opened with this SystemDescriptor.
Definition peak_system_descriptor.hpp:391
PEAK_COMMON_NO_DISCARD std::string ModelName() const
Returns the model name.
Definition peak_system_descriptor.hpp:313
PEAK_COMMON_NO_DISCARD uint32_t GenTLVersionMajor() const
Returns the GenTL major version of the GenTL producer library this system belongs to.
Definition peak_system_descriptor.hpp:350
PEAK_COMMON_NO_DISCARD uint32_t GenTLVersionMinor() const
Returns the GenTL minor version of the GenTL producer library this system belongs to.
Definition peak_system_descriptor.hpp:357
PEAK_COMMON_NO_DISCARD std::string Key() const
Returns the unique key.
Definition peak_system_descriptor.hpp:285
PEAK_COMMON_NO_DISCARD std::string DisplayName() const
Returns the display name.
Definition peak_system_descriptor.hpp:298
PEAK_COMMON_NO_DISCARD peak::core::CharacterEncoding CharacterEncoding() const
Returns the character encoding of the GenTL producer library this system belongs to.
Definition peak_system_descriptor.hpp:364
PEAK_COMMON_NO_DISCARD bool IsOpened() const
Returns whether the system is open.
Definition peak_system_descriptor.hpp:401
SystemDescriptor & operator=(SystemDescriptor &&other)=delete
PEAK_COMMON_NO_DISCARD std::string Version() const
Returns the version.
Definition peak_system_descriptor.hpp:320
PEAK_COMMON_NO_DISCARD std::string CTIFullPath() const
Returns the full path of the GenTL producer library this system belongs to.
Definition peak_system_descriptor.hpp:342
PEAK_COMMON_NO_DISCARD std::string VendorName() const
Returns the vendor name.
Definition peak_system_descriptor.hpp:306
PEAK_COMMON_NO_DISCARD RawInformation Info(int32_t infoCommand) const
Delivers information based on the given GenTL info command.
Definition peak_system_descriptor.hpp:290
PEAK_COMMON_NO_DISCARD std::shared_ptr< ProducerLibrary > ParentLibrary() const
Returns the parent library.
Definition peak_system_descriptor.hpp:374
PEAK_COMMON_NO_DISCARD std::string TLType() const
Returns the TL (transport layer) type.
Definition peak_system_descriptor.hpp:327
PEAK_COMMON_NO_DISCARD std::string CTIFileName() const
Returns the file name of the GenTL producer library this system belongs to.
Definition peak_system_descriptor.hpp:334
~SystemDescriptor() override=default
PEAK_COMMON_NO_DISCARD std::shared_ptr< System > EnsureOpenedSystem()
Returns the opened system or opens it if it is not already open.
Definition peak_system_descriptor.hpp:396
SystemDescriptor(const SystemDescriptor &other)=delete
SystemDescriptor(SystemDescriptor &&other)=delete
The "core" namespace contains the direct GenAPI and GenTL wrapper.
Definition peak_buffer.hpp:32
CharacterEncoding
Possible character encodings.
Definition peak_common_system_enums.hpp:23
The "peak" namespace directly contains convenience functionality like the DeviceManager as well as th...
Definition peak_buffer.hpp:29
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:367
struct PEAK_MODULE_DESCRIPTOR * PEAK_MODULE_DESCRIPTOR_HANDLE
Definition peak_backend.h:415
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:371
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:105
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_COMMON_NO_DISCARD
Definition peak_common_defines.h:89
#define PEAK_C_ABI_PREFIX
Definition peak_dll_defines.h:13
The struct returned by all raw information functions.
Definition peak_common_structs.hpp:21