WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
RawEvent.hpp
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <string>
8#include <string_view>
9
10#include "wpi/cs/VideoMode.hpp"
11#include "wpi/cs/cscore_c.h"
12
13namespace wpi::cs {
14
15/**
16 * Listener event
17 */
18struct RawEvent {
41
42 RawEvent() = default;
43 explicit RawEvent(RawEvent::Kind kind_) : kind{kind_} {}
44 RawEvent(std::string_view name_, CS_Handle handle_, RawEvent::Kind kind_)
45 : kind{kind_}, name{name_} {
46 if (kind_ == kSinkCreated || kind_ == kSinkDestroyed ||
47 kind_ == kSinkEnabled || kind_ == kSinkDisabled) {
48 sinkHandle = handle_;
49 } else {
50 sourceHandle = handle_;
51 }
52 }
53 RawEvent(std::string_view name_, CS_Source source_, const VideoMode& mode_)
55 sourceHandle{source_},
56 name{name_},
57 mode{mode_} {}
58 RawEvent(std::string_view name_, CS_Source source_, RawEvent::Kind kind_,
59 CS_Property property_, CS_PropertyKind propertyKind_, int value_,
60 std::string_view valueStr_)
61 : kind{kind_},
62 sourceHandle{source_},
63 name{name_},
64 propertyHandle{property_},
65 propertyKind{propertyKind_},
66 value{value_},
67 valueStr{valueStr_} {}
68
70
71 // Valid for kSource* and kSink* respectively
74
75 // Source/sink/property name
76 std::string name;
77
78 // Fields for kSourceVideoModeChanged event
80
81 // Fields for kSourceProperty* events
84 int value;
85 std::string valueStr;
86
87 // Listener that was triggered
89};
90
91} // namespace wpi::cs
CS_PropertyKind
Property kinds.
Definition cscore_c.h:97
@ CS_SOURCE_PROPERTY_CREATED
Definition cscore_c.h:145
@ CS_SOURCE_VIDEOMODES_UPDATED
Definition cscore_c.h:143
@ CS_SINK_PROPERTY_VALUE_UPDATED
Definition cscore_c.h:156
@ CS_SOURCE_CONNECTED
Definition cscore_c.h:141
@ CS_TELEMETRY_UPDATED
Definition cscore_c.h:154
@ CS_SINK_ENABLED
Definition cscore_c.h:151
@ CS_USB_CAMERAS_CHANGED
Definition cscore_c.h:158
@ CS_SOURCE_CREATED
Definition cscore_c.h:139
@ CS_SINK_DESTROYED
Definition cscore_c.h:150
@ CS_SINK_PROPERTY_CREATED
Definition cscore_c.h:155
@ CS_SINK_PROPERTY_CHOICES_UPDATED
Definition cscore_c.h:157
@ CS_NETWORK_INTERFACES_CHANGED
Definition cscore_c.h:153
@ CS_SOURCE_VIDEOMODE_CHANGED
Definition cscore_c.h:144
@ CS_SINK_SOURCE_CHANGED
Definition cscore_c.h:148
@ CS_SOURCE_PROPERTY_VALUE_UPDATED
Definition cscore_c.h:146
@ CS_SOURCE_DISCONNECTED
Definition cscore_c.h:142
@ CS_SOURCE_DESTROYED
Definition cscore_c.h:140
@ CS_SINK_CREATED
Definition cscore_c.h:149
@ CS_SOURCE_PROPERTY_CHOICES_UPDATED
Definition cscore_c.h:147
@ CS_SINK_DISABLED
Definition cscore_c.h:152
@ CS_INVALID_HANDLE
Definition cscore_c.h:57
CS_Handle CS_Source
Definition cscore_c.h:48
CS_Handle CS_Property
Definition cscore_c.h:44
CS_Handle CS_Sink
Definition cscore_c.h:47
int CS_Handle
Definition cscore_c.h:43
CS_Handle CS_Listener
Definition cscore_c.h:45
CameraServer (cscore) namespace.
Definition CvSource.hpp:15
int value
Definition RawEvent.hpp:84
CS_Listener listener
Definition RawEvent.hpp:88
Kind
Definition RawEvent.hpp:19
@ kSinkCreated
Definition RawEvent.hpp:30
@ kSinkDestroyed
Definition RawEvent.hpp:31
@ kSourcePropertyValueUpdated
Definition RawEvent.hpp:27
@ kSinkPropertyChoicesUpdated
Definition RawEvent.hpp:38
@ kSinkDisabled
Definition RawEvent.hpp:33
@ kSourceConnected
Definition RawEvent.hpp:22
@ kSourceDestroyed
Definition RawEvent.hpp:21
@ kNetworkInterfacesChanged
Definition RawEvent.hpp:34
@ kUsbCamerasChanged
Definition RawEvent.hpp:39
@ kSinkPropertyCreated
Definition RawEvent.hpp:36
@ kSourceDisconnected
Definition RawEvent.hpp:23
@ kSinkSourceChanged
Definition RawEvent.hpp:29
@ kTelemetryUpdated
Definition RawEvent.hpp:35
@ kSinkPropertyValueUpdated
Definition RawEvent.hpp:37
@ kSourceVideoModeChanged
Definition RawEvent.hpp:25
@ kSinkEnabled
Definition RawEvent.hpp:32
@ kSourceCreated
Definition RawEvent.hpp:20
@ kSourcePropertyChoicesUpdated
Definition RawEvent.hpp:28
@ kSourcePropertyCreated
Definition RawEvent.hpp:26
@ kSourceVideoModesUpdated
Definition RawEvent.hpp:24
VideoMode mode
Definition RawEvent.hpp:79
CS_Source sourceHandle
Definition RawEvent.hpp:72
RawEvent(std::string_view name_, CS_Source source_, RawEvent::Kind kind_, CS_Property property_, CS_PropertyKind propertyKind_, int value_, std::string_view valueStr_)
Definition RawEvent.hpp:58
RawEvent(RawEvent::Kind kind_)
Definition RawEvent.hpp:43
CS_Sink sinkHandle
Definition RawEvent.hpp:73
std::string valueStr
Definition RawEvent.hpp:85
CS_Property propertyHandle
Definition RawEvent.hpp:82
std::string name
Definition RawEvent.hpp:76
CS_PropertyKind propertyKind
Definition RawEvent.hpp:83
Kind kind
Definition RawEvent.hpp:69
RawEvent(std::string_view name_, CS_Source source_, const VideoMode &mode_)
Definition RawEvent.hpp:53
RawEvent()=default
RawEvent(std::string_view name_, CS_Handle handle_, RawEvent::Kind kind_)
Definition RawEvent.hpp:44
Video mode.
Definition VideoMode.hpp:15