IDS peak genericC++  v1.7.2
peak_system_descriptor.hpp
Go to the documentation of this file.
1 
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 
28 namespace peak
29 {
30 namespace core
31 {
32 
33 class ProducerLibrary;
34 
43 {
44 public:
45  SystemDescriptor() = delete;
46  ~SystemDescriptor() override = default;
47  SystemDescriptor(const SystemDescriptor& other) = delete;
48  SystemDescriptor& operator=(const SystemDescriptor& other) = delete;
49  SystemDescriptor(SystemDescriptor&& other) = delete;
50  SystemDescriptor& operator=(SystemDescriptor&& other) = delete;
51 
53  std::string Key() const;
54 
88  RawInformation Info(int32_t infoCommand) const;
89 
99  std::string DisplayName() const;
100 
110  std::string VendorName() const;
111 
121  std::string ModelName() const;
122 
132  std::string Version() const;
133 
143  std::string TLType() const;
144 
154  std::string CTIFileName() const;
155 
165  std::string CTIFullPath() const;
166 
176  uint32_t GenTLVersionMajor() const;
177 
187  uint32_t GenTLVersionMinor() const;
188 
199 
209  std::shared_ptr<ProducerLibrary> ParentLibrary() const;
210 
221  std::shared_ptr<System> OpenSystem();
222 
232  std::shared_ptr<System> OpenedSystem() const;
233 
241  bool IsOpened() const;
242 
243 private:
244  PEAK_MODULE_DESCRIPTOR_HANDLE ModuleDescriptorHandle() const override;
245 
246  friend ClassCreator<SystemDescriptor>;
248  PEAK_SYSTEM_DESCRIPTOR_HANDLE systemDescriptorHandle, const std::weak_ptr<ProducerLibrary>& parentLibrary);
249  PEAK_SYSTEM_DESCRIPTOR_HANDLE m_backendHandle;
250 
251  std::weak_ptr<ProducerLibrary> m_parentLibrary;
252  std::weak_ptr<System> m_openedSystem;
253 
254  std::string m_key;
255 };
256 
257 } /* namespace core */
258 } /* namespace peak */
259 
260 /* Implementation */
261 namespace peak
262 {
263 namespace core
264 {
265 
267  PEAK_SYSTEM_DESCRIPTOR_HANDLE systemDescriptorHandle, const std::weak_ptr<ProducerLibrary>& parentLibrary)
268  : m_backendHandle(systemDescriptorHandle)
269  , m_parentLibrary(parentLibrary)
270  , m_key(QueryStringFromCInterfaceFunction([&](char* key, size_t* keySize) {
271  return PEAK_C_ABI_PREFIX PEAK_SystemDescriptor_GetKey(systemDescriptorHandle, key, keySize);
272  }))
273 {}
274 
275 inline std::string SystemDescriptor::Key() const
276 {
277  return m_key;
278 }
279 
280 inline RawInformation SystemDescriptor::Info(int32_t infoCommand) const
281 {
282  return QueryRawInformationFromCInterfaceFunction([&](int32_t* dataType, uint8_t* buffer, size_t* bufferSize) {
284  m_backendHandle, infoCommand, dataType, buffer, bufferSize);
285  });
286 }
287 
288 inline std::string SystemDescriptor::DisplayName() const
289 {
290  return QueryStringFromCInterfaceFunction([&](char* displayName, size_t* displayNameSize) {
292  m_backendHandle, displayName, displayNameSize);
293  });
294 }
295 
296 inline std::string SystemDescriptor::VendorName() const
297 {
298  return QueryStringFromCInterfaceFunction([&](char* vendorName, size_t* vendorNameSize) {
299  return PEAK_C_ABI_PREFIX PEAK_SystemDescriptor_GetVendorName(m_backendHandle, vendorName, vendorNameSize);
300  });
301 }
302 
303 inline std::string SystemDescriptor::ModelName() const
304 {
305  return QueryStringFromCInterfaceFunction([&](char* modelName, size_t* modelNameSize) {
306  return PEAK_C_ABI_PREFIX PEAK_SystemDescriptor_GetModelName(m_backendHandle, modelName, modelNameSize);
307  });
308 }
309 
310 inline std::string SystemDescriptor::Version() const
311 {
312  return QueryStringFromCInterfaceFunction([&](char* version, size_t* versionSize) {
313  return PEAK_C_ABI_PREFIX PEAK_SystemDescriptor_GetVersion(m_backendHandle, version, versionSize);
314  });
315 }
316 
317 inline std::string SystemDescriptor::TLType() const
318 {
319  return QueryStringFromCInterfaceFunction([&](char* tlType, size_t* tlTypeSize) {
320  return PEAK_C_ABI_PREFIX PEAK_SystemDescriptor_GetTLType(m_backendHandle, tlType, tlTypeSize);
321  });
322 }
323 
324 inline std::string SystemDescriptor::CTIFileName() const
325 {
326  return QueryStringFromCInterfaceFunction([&](char* ctiFileName, size_t* ctiFileNameSize) {
328  m_backendHandle, ctiFileName, ctiFileNameSize);
329  });
330 }
331 
332 inline std::string SystemDescriptor::CTIFullPath() const
333 {
334  return QueryStringFromCInterfaceFunction([&](char* ctiFullPath, size_t* ctiFullPathSize) {
336  m_backendHandle, ctiFullPath, ctiFullPathSize);
337  });
338 }
339 
340 inline uint32_t SystemDescriptor::GenTLVersionMajor() const
341 {
342  return QueryNumericFromCInterfaceFunction<uint32_t>([&](uint32_t* gentlVersionMajor) {
343  return PEAK_C_ABI_PREFIX PEAK_SystemDescriptor_GetGenTLVersionMajor(m_backendHandle, gentlVersionMajor);
344  });
345 }
346 
347 inline uint32_t SystemDescriptor::GenTLVersionMinor() const
348 {
349  return QueryNumericFromCInterfaceFunction<uint32_t>([&](uint32_t* gentlVersionMinor) {
350  return PEAK_C_ABI_PREFIX PEAK_SystemDescriptor_GetGenTLVersionMinor(m_backendHandle, gentlVersionMinor);
351  });
352 }
353 
355 {
356  return static_cast<peak::core::CharacterEncoding>(
357  QueryNumericFromCInterfaceFunction<PEAK_CHARACTER_ENCODING>(
358  [&](PEAK_CHARACTER_ENCODING* characterEncoding) {
360  m_backendHandle, characterEncoding);
361  }));
362 }
363 
364 inline std::shared_ptr<ProducerLibrary> SystemDescriptor::ParentLibrary() const
365 {
366  return LockOrThrow(m_parentLibrary);
367 }
368 
369 inline std::shared_ptr<System> SystemDescriptor::OpenSystem()
370 {
371  auto systemHandle = QueryNumericFromCInterfaceFunction<PEAK_SYSTEM_HANDLE>(
372  [&](PEAK_SYSTEM_HANDLE* _systemHandle) {
373  return PEAK_C_ABI_PREFIX PEAK_SystemDescriptor_OpenSystem(m_backendHandle, _systemHandle);
374  });
375 
376  auto system = std::make_shared<ClassCreator<System>>(systemHandle, m_parentLibrary);
377  m_openedSystem = system;
378  return system;
379 }
380 
381 inline std::shared_ptr<System> SystemDescriptor::OpenedSystem() const
382 {
383  return LockOrThrowOpenedModule(m_openedSystem);
384 }
385 
386 inline bool SystemDescriptor::IsOpened() const
387 {
388  return !m_openedSystem.expired();
389 }
390 
391 inline PEAK_MODULE_DESCRIPTOR_HANDLE SystemDescriptor::ModuleDescriptorHandle() const
392 {
393  auto moduleDescriptorHandle = QueryNumericFromCInterfaceFunction<PEAK_MODULE_DESCRIPTOR_HANDLE>(
394  [&](PEAK_MODULE_DESCRIPTOR_HANDLE* _moduleDescriptorHandle) {
396  m_backendHandle, _moduleDescriptorHandle);
397  });
398 
399  return moduleDescriptorHandle;
400 }
401 
402 
403 
404 } /* namespace core */
405 } /* namespace peak */
std::shared_ptr< System > OpenedSystem() const
Returns the System that was opened with this SystemDescriptor.
Definition: peak_system_descriptor.hpp:381
std::string Key() const
Returns the unique key.
Definition: peak_system_descriptor.hpp:275
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&#39;s full path.
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_GetTLType(PEAK_SYSTEM_DESCRIPTOR_HANDLE systemDescriptorHandle, char *tlType, size_t *tlTypeSize)
Asks the given system descriptor for its TL type.
PEAK_C_API PEAK_SystemDescriptor_GetCharacterEncoding(PEAK_SYSTEM_DESCRIPTOR_HANDLE systemDescriptorHandle, PEAK_CHARACTER_ENCODING *characterEncoding)
Asks the given system descriptor for its character encoding.
The "peak" namespace directly contains convenience functionality like the DeviceManager as well as th...
Definition: peak_dynamic_loader.h:32
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&#39;s file name.
~SystemDescriptor() override=default
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_GetVersion(PEAK_SYSTEM_DESCRIPTOR_HANDLE systemDescriptorHandle, char *version, size_t *versionSize)
Asks the given system descriptor for its version.
Encapsulates the GenTL functions associated with the GenTL System module&#39;s ID.
Definition: peak_system_descriptor.hpp:42
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.
std::shared_ptr< ProducerLibrary > ParentLibrary() const
Returns the parent library.
Definition: peak_system_descriptor.hpp:364
int32_t PEAK_CHARACTER_ENCODING
Definition: peak_backend.h:90
uint32_t GenTLVersionMajor() const
Returns the GenTL major version of the GenTL producer library this system belongs to...
Definition: peak_system_descriptor.hpp:340
std::shared_ptr< System > OpenSystem()
Opens the system.
Definition: peak_system_descriptor.hpp:369
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.
struct PEAK_MODULE_DESCRIPTOR * PEAK_MODULE_DESCRIPTOR_HANDLE
Definition: peak_backend.h:399
std::string CTIFileName() const
Returns the file name of the GenTL producer library this system belongs to.
Definition: peak_system_descriptor.hpp:324
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_GetKey(PEAK_SYSTEM_DESCRIPTOR_HANDLE systemDescriptorHandle, char *key, size_t *keySize)
Asks the given system descriptor for its key.
std::string VendorName() const
Returns the vendor name.
Definition: peak_system_descriptor.hpp:296
bool IsOpened() const
Returns if the system is currently opened or not.
Definition: peak_system_descriptor.hpp:386
SystemDescriptor & operator=(const SystemDescriptor &other)=delete
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.
std::string TLType() const
Returns the TL (transport layer) type.
Definition: peak_system_descriptor.hpp:317
The base class for all openable modules.
Definition: peak_module_descriptor.hpp:30
struct PEAK_SYSTEM * PEAK_SYSTEM_HANDLE
Definition: peak_backend.h:355
struct PEAK_SYSTEM_DESCRIPTOR * PEAK_SYSTEM_DESCRIPTOR_HANDLE
Definition: peak_backend.h:351
RawInformation Info(int32_t infoCommand) const
Delivers information based on the given GenTL info command.
Definition: peak_system_descriptor.hpp:280
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.
std::string CTIFullPath() const
Returns the full path of the GenTL producer library this system belongs to.
Definition: peak_system_descriptor.hpp:332
CharacterEncoding
Possible character encodings.
Definition: peak_common_system_enums.hpp:24
#define PEAK_C_ABI_PREFIX
Definition: peak_dll_defines.h:16
uint32_t GenTLVersionMinor() const
Returns the GenTL minor version of the GenTL producer library this system belongs to...
Definition: peak_system_descriptor.hpp:347
peak::core::CharacterEncoding CharacterEncoding() const
Returns the character encoding of the GenTL producer library this system belongs to.
Definition: peak_system_descriptor.hpp:354
The struct returned by all raw information functions.
Definition: peak_common_structs.hpp:24
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.
std::string Version() const
Returns the version.
Definition: peak_system_descriptor.hpp:310
std::string DisplayName() const
Returns the display name.
Definition: peak_system_descriptor.hpp:288
std::string ModelName() const
Returns the model name.
Definition: peak_system_descriptor.hpp:303