IDS peak genericC++ v1.17.0
Loading...
Searching...
No Matches
peak_producer_library.hpp
Go to the documentation of this file.
1
6
7#pragma once
8
10
12#include <peak/dll_interface/peak_dll_interface_util.hpp>
15
16#include <cstdint>
17#include <memory>
18#include <string>
19#include <vector>
20
21
22namespace peak
23{
24namespace core
25{
26
35 : public InitOnce
36 , public std::enable_shared_from_this<ProducerLibrary>
37{
38public:
39 ProducerLibrary() = delete;
40 ~ProducerLibrary() override;
41 ProducerLibrary(const ProducerLibrary& other) = delete;
42 ProducerLibrary& operator=(const ProducerLibrary& other) = delete;
45
58 PEAK_COMMON_NO_DISCARD static std::shared_ptr<ProducerLibrary> Open(const std::string& ctiPath);
59
71 PEAK_COMMON_NO_DISCARD std::string Key() const;
72
85 PEAK_COMMON_NO_DISCARD std::shared_ptr<SystemDescriptor> System() const;
86
87private:
88 friend ClassCreator<ProducerLibrary>;
89 explicit ProducerLibrary(PEAK_PRODUCER_LIBRARY_HANDLE producerLibraryHandle);
90 PEAK_PRODUCER_LIBRARY_HANDLE m_backendHandle;
91
92 void Initialize() const override;
93 mutable std::shared_ptr<SystemDescriptor> m_system;
94
95 std::string m_key;
96};
97
98} /* namespace core */
99} /* namespace peak */
100
101/* Implementation */
102namespace peak
103{
104namespace core
105{
106
107inline std::shared_ptr<ProducerLibrary> ProducerLibrary::Open(const std::string& ctiPath)
108{
109 auto producerLibraryHandle = QueryNumericFromCInterfaceFunction<PEAK_PRODUCER_LIBRARY_HANDLE>(
110 [&](PEAK_PRODUCER_LIBRARY_HANDLE* _producerLibraryHandle) {
112 ctiPath.c_str(), ctiPath.size() + 1, _producerLibraryHandle);
113 });
114
115 return std::make_shared<ClassCreator<ProducerLibrary>>(producerLibraryHandle);
116}
117
119 : m_backendHandle(producerLibraryHandle)
120 , m_system()
121 , m_key(QueryStringFromCInterfaceFunction([&](char* key, size_t* keySize) {
122 return PEAK_C_ABI_PREFIX PEAK_ProducerLibrary_GetKey(producerLibraryHandle, key, keySize);
123 }))
124{}
125
130
131inline std::string ProducerLibrary::Key() const
132{
133 return m_key;
134}
135
136inline std::shared_ptr<SystemDescriptor> ProducerLibrary::System() const
137{
138 InitializeIfNecessary();
139
140 return m_system;
141}
142
143inline void ProducerLibrary::Initialize() const
144{
145 auto systemDescriptorHandle = QueryNumericFromCInterfaceFunction<PEAK_SYSTEM_DESCRIPTOR_HANDLE>(
146 [&](PEAK_SYSTEM_DESCRIPTOR_HANDLE* _systemDescriptorHandle) {
147 return PEAK_C_ABI_PREFIX PEAK_ProducerLibrary_GetSystem(m_backendHandle, _systemDescriptorHandle);
148 });
149
150 m_system = std::make_shared<ClassCreator<SystemDescriptor>>(
151 systemDescriptorHandle, std::const_pointer_cast<ProducerLibrary>(shared_from_this()));
152}
153
154} /* namespace core */
155} /* namespace peak */
ProducerLibrary(const ProducerLibrary &other)=delete
ProducerLibrary & operator=(ProducerLibrary &&other)=delete
~ProducerLibrary() override
Definition peak_producer_library.hpp:126
PEAK_COMMON_NO_DISCARD std::string Key() const
Returns the unique key.
Definition peak_producer_library.hpp:131
ProducerLibrary & operator=(const ProducerLibrary &other)=delete
ProducerLibrary(ProducerLibrary &&other)=delete
static PEAK_COMMON_NO_DISCARD std::shared_ptr< ProducerLibrary > Open(const std::string &ctiPath)
Opens the given producer library (CTI).
Definition peak_producer_library.hpp:107
PEAK_COMMON_NO_DISCARD std::shared_ptr< SystemDescriptor > System() const
Returns the system descriptor.
Definition peak_producer_library.hpp:136
The "core" namespace contains the direct GenAPI and GenTL wrapper.
Definition peak_buffer.hpp:32
The "peak" namespace directly contains convenience functionality like the DeviceManager as well as th...
Definition peak_buffer.hpp:29
struct PEAK_SYSTEM_DESCRIPTOR * PEAK_SYSTEM_DESCRIPTOR_HANDLE
Definition peak_backend.h:367
struct PEAK_PRODUCER_LIBRARY * PEAK_PRODUCER_LIBRARY_HANDLE
Definition peak_backend.h:363
PEAK_C_API PEAK_ProducerLibrary_GetSystem(PEAK_PRODUCER_LIBRARY_HANDLE producerLibraryHandle, PEAK_SYSTEM_DESCRIPTOR_HANDLE *systemDescriptorHandle)
Asks the given producer library for its system descriptor.
PEAK_C_API PEAK_ProducerLibrary_GetKey(PEAK_PRODUCER_LIBRARY_HANDLE producerLibraryHandle, char *key, size_t *keySize)
Asks the given producer library for its key.
PEAK_C_API PEAK_ProducerLibrary_Construct(const char *ctiPath, size_t ctiPathSize, PEAK_PRODUCER_LIBRARY_HANDLE *producerLibraryHandle)
Creates a producer library.
PEAK_C_API PEAK_ProducerLibrary_Destruct(PEAK_PRODUCER_LIBRARY_HANDLE producerLibraryHandle)
Destroys the given producer library.
#define PEAK_COMMON_NO_DISCARD
Definition peak_common_defines.h:89
#define PEAK_C_ABI_PREFIX
Definition peak_dll_defines.h:13