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