-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNotification.h
More file actions
150 lines (139 loc) · 4.33 KB
/
Notification.h
File metadata and controls
150 lines (139 loc) · 4.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
// Notification types and dispatch for async notification delivery.
//
// LICENSE: This file is distributed under the "Lesser GPL" (LGPL)
// license. License text is included with the source
// distribution.
#pragma once
#include "MMEventCallback.h"
#include <string>
#include <variant>
namespace mmcore {
namespace internal {
namespace notification {
struct PropertiesChanged {};
struct PropertyChanged {
std::string deviceLabel;
std::string propertyName;
std::string propertyValue;
};
struct ConfigGroupChanged {
std::string groupName;
std::string configName;
};
struct PixelSizeChanged {
double pixelSizeUm;
};
struct PixelSizeAffineChanged {
double v0, v1, v2, v3, v4, v5;
};
struct StagePositionChanged {
std::string deviceLabel;
double position;
};
struct XYStagePositionChanged {
std::string deviceLabel;
double x, y;
};
struct ExposureChanged {
std::string deviceLabel;
double exposure;
};
struct SLMExposureChanged {
std::string deviceLabel;
double exposure;
};
struct ShutterOpenChanged {
std::string deviceLabel;
bool open;
};
struct ImageSnapped {
std::string cameraLabel;
};
struct SequenceAcquisitionStarted {
std::string cameraLabel;
};
struct SequenceAcquisitionStopped {
std::string cameraLabel;
};
struct SystemConfigurationLoaded {};
struct ChannelGroupChanged {
std::string channelGroupName;
};
} // namespace notification
using Notification = std::variant<
notification::PropertiesChanged,
notification::PropertyChanged,
notification::ConfigGroupChanged,
notification::PixelSizeChanged,
notification::PixelSizeAffineChanged,
notification::StagePositionChanged,
notification::XYStagePositionChanged,
notification::ExposureChanged,
notification::SLMExposureChanged,
notification::ShutterOpenChanged,
notification::ImageSnapped,
notification::SequenceAcquisitionStarted,
notification::SequenceAcquisitionStopped,
notification::SystemConfigurationLoaded,
notification::ChannelGroupChanged
>;
namespace detail {
template <class... Ts> struct overloaded : Ts... { using Ts::operator()...; };
template <class... Ts> overloaded(Ts...) -> overloaded<Ts...>;
} // namespace detail
inline void DispatchNotification(const Notification& notification,
MMEventCallback& cb) {
std::visit(detail::overloaded{
[&](const notification::PropertiesChanged&) {
cb.onPropertiesChanged();
},
[&](const notification::PropertyChanged& n) {
cb.onPropertyChanged(
n.deviceLabel.c_str(), n.propertyName.c_str(),
n.propertyValue.c_str());
},
[&](const notification::ConfigGroupChanged& n) {
cb.onConfigGroupChanged(
n.groupName.c_str(), n.configName.c_str());
},
[&](const notification::PixelSizeChanged& n) {
cb.onPixelSizeChanged(n.pixelSizeUm);
},
[&](const notification::PixelSizeAffineChanged& n) {
cb.onPixelSizeAffineChanged(n.v0, n.v1, n.v2, n.v3, n.v4, n.v5);
},
[&](const notification::StagePositionChanged& n) {
cb.onStagePositionChanged(n.deviceLabel.c_str(), n.position);
},
[&](const notification::XYStagePositionChanged& n) {
cb.onXYStagePositionChanged(
n.deviceLabel.c_str(), n.x, n.y);
},
[&](const notification::ExposureChanged& n) {
cb.onExposureChanged(n.deviceLabel.c_str(), n.exposure);
},
[&](const notification::SLMExposureChanged& n) {
cb.onSLMExposureChanged(n.deviceLabel.c_str(), n.exposure);
},
[&](const notification::ShutterOpenChanged& n) {
cb.onShutterOpenChanged(n.deviceLabel.c_str(), n.open);
},
[&](const notification::ImageSnapped& n) {
cb.onImageSnapped(n.cameraLabel.c_str());
},
[&](const notification::SequenceAcquisitionStarted& n) {
cb.onSequenceAcquisitionStarted(n.cameraLabel.c_str());
},
[&](const notification::SequenceAcquisitionStopped& n) {
cb.onSequenceAcquisitionStopped(n.cameraLabel.c_str());
},
[&](const notification::SystemConfigurationLoaded&) {
cb.onSystemConfigurationLoaded();
},
[&](const notification::ChannelGroupChanged& n) {
cb.onChannelGroupChanged(n.channelGroupName.c_str());
},
}, notification);
}
} // namespace internal
} // namespace mmcore