IDS peak genericC++ v1.14.0
Loading...
Searching...
No Matches
peak_event.hpp
Go to the documentation of this file.
1
10
11#pragma once
12
13
16#include <peak/dll_interface/peak_dll_interface_util.hpp>
17
18#include <cstdint>
19#include <vector>
20
21
22namespace peak
23{
24namespace core
25{
26
45
46class NodeMap;
47
53class Event
54{
55public:
56 Event() = delete;
57 ~Event();
58 Event(const Event& other) = delete;
59 Event& operator=(const Event& other) = delete;
60 Event(Event&& other) = delete;
61 Event& operator=(Event&& other) = delete;
62
64 RawInformation Info(int32_t infoCommand) const;
65
75 uint64_t ID() const;
76
88 std::vector<uint8_t> Data() const;
89
90
98 EventType Type() const;
99
112 std::vector<uint8_t> RawData() const;
113
114private:
115 friend NodeMap;
116 friend ClassCreator<Event>;
117 explicit Event(PEAK_EVENT_HANDLE eventHandle);
118 PEAK_EVENT_HANDLE m_backendHandle;
119};
120
121} /* namespace core */
122} /* namespace peak */
123
124/* Implementation */
125namespace peak
126{
127namespace core
128{
129
130inline Event::Event(PEAK_EVENT_HANDLE eventHandle)
131 : m_backendHandle(eventHandle)
132{}
133
134inline RawInformation Event::Info(int32_t infoCommand) const
135{
136 return QueryRawInformationFromCInterfaceFunction([&](int32_t* dataType, uint8_t* buffer, size_t* bufferSize) {
137 return PEAK_C_ABI_PREFIX PEAK_Event_GetInfo(m_backendHandle, infoCommand, dataType, buffer, bufferSize);
138 });
139}
140
141inline uint64_t Event::ID() const
142{
143 return QueryNumericFromCInterfaceFunction<uint64_t>(
144 [&](uint64_t* id) { return PEAK_C_ABI_PREFIX PEAK_Event_GetID(m_backendHandle, id); });
145}
146
147inline std::vector<uint8_t> Event::Data() const
148{
149 return QueryNumericArrayFromCInterfaceFunction<uint8_t>([&](uint8_t* data, size_t* dataSize) {
150 return PEAK_C_ABI_PREFIX PEAK_Event_GetData(m_backendHandle, data, dataSize);
151 });
152}
153
154inline EventType Event::Type() const
155{
156 return static_cast<EventType>(QueryNumericFromCInterfaceFunction<PEAK_EVENT_TYPE>(
157 [&](PEAK_EVENT_TYPE* type) { return PEAK_C_ABI_PREFIX PEAK_Event_GetType(m_backendHandle, type); }));
158}
159
160inline std::vector<uint8_t> Event::RawData() const
161{
162 return QueryNumericArrayFromCInterfaceFunction<uint8_t>([&](uint8_t* rawData, size_t* rawDataSize) {
163 return PEAK_C_ABI_PREFIX PEAK_Event_GetRawData(m_backendHandle, rawData, rawDataSize);
164 });
165}
166
168{
169 (void)PEAK_C_ABI_PREFIX PEAK_Event_Destruct(m_backendHandle);
170}
171
172inline std::string ToString(EventType entry)
173{
174 std::string entryString;
175
176 if (entry == EventType::Error)
177 {
178 entryString = "Error";
179 }
180 else if (entry == EventType::FeatureInvalidate)
181 {
182 entryString = "FeatureInvalidate";
183 }
184 else if (entry == EventType::FeatureChange)
185 {
186 entryString = "FeatureChange";
187 }
188 else if (entry == EventType::RemoteDevice)
189 {
190 entryString = "RemoteDevice";
191 }
192 else if (entry == EventType::Module)
193 {
194 entryString = "Module";
195 }
196 else if (entry >= EventType::Custom)
197 {
198 entryString = "Custom";
199 }
200
201 return entryString;
202}
203
204} /* namespace core */
205} /* namespace peak */
RawInformation Info(int32_t infoCommand) const
Delivers information based on the given GenTL info command.
Definition peak_event.hpp:134
std::vector< uint8_t > Data() const
Returns the event payload data.
Definition peak_event.hpp:147
~Event()
Definition peak_event.hpp:167
Event & operator=(Event &&other)=delete
Event(const Event &other)=delete
Event(Event &&other)=delete
EventType Type() const
Returns the type.
Definition peak_event.hpp:154
std::vector< uint8_t > RawData() const
Returns the event raw data.
Definition peak_event.hpp:160
uint64_t ID() const
Returns the ID.
Definition peak_event.hpp:141
Event & operator=(const Event &other)=delete
Represents an extended GenTL port.
Definition peak_module.hpp:38
Allows to access the physical Device.
Definition peak_remote_device.hpp:38
@ Custom
Definition peak_buffer.hpp:56
EventType
Different types of events.
Definition peak_event.hpp:36
@ FeatureChange
Definition peak_event.hpp:39
@ FeatureInvalidate
Definition peak_event.hpp:38
@ RemoteDevice
Definition peak_event.hpp:40
@ Error
Definition peak_event.hpp:37
@ Custom
Definition peak_event.hpp:43
@ Module
Definition peak_event.hpp:41
The "core" namespace contains the direct GenAPI and GenTL wrapper.
Definition peak_buffer.hpp:34
std::string ToString(BufferPayloadType entry)
Definition peak_buffer.hpp:557
The "peak" namespace directly contains convenience functionality like the DeviceManager as well as th...
Definition peak_dynamic_loader.h:33
struct PEAK_EVENT * PEAK_EVENT_HANDLE
Definition peak_backend.h:485
PEAK_C_API PEAK_Event_GetType(PEAK_EVENT_HANDLE eventHandle, PEAK_EVENT_TYPE *type)
Asks the given event for its type.
PEAK_C_API PEAK_Event_GetInfo(PEAK_EVENT_HANDLE eventHandle, int32_t infoCommand, int32_t *infoDataType, uint8_t *info, size_t *infoSize)
Asks the given event for an information based on a specific command.
int32_t PEAK_EVENT_TYPE
Definition peak_backend.h:185
PEAK_C_API PEAK_Event_GetData(PEAK_EVENT_HANDLE eventHandle, uint8_t *data, size_t *dataSize)
Asks the given event for its data.
PEAK_C_API PEAK_Event_Destruct(PEAK_EVENT_HANDLE eventHandle)
Destroys the given event.
PEAK_C_API PEAK_Event_GetID(PEAK_EVENT_HANDLE eventHandle, uint64_t *id)
Asks the given event for its ID.
PEAK_C_API PEAK_Event_GetRawData(PEAK_EVENT_HANDLE eventHandle, uint8_t *rawData, size_t *rawDataSize)
Asks the given event for its raw data.
#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