summaryrefslogtreecommitdiffstats
path: root/src/Reactor.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-07-19 09:55:42 -0400
committerDavid Robillard <d@drobilla.net>2022-07-20 10:35:32 -0400
commit808a0cbc8d47f2c77fc69f2ad850d2e91dc9ca21 (patch)
tree1aae618f7f8fb79bf5a405e740dfb6a6bfbe7d23 /src/Reactor.cpp
parent2f6bec60c6bd0f4bac2a8a5f47b1994b65ed7ed0 (diff)
downloadpatchage-808a0cbc8d47f2c77fc69f2ad850d2e91dc9ca21.tar.gz
patchage-808a0cbc8d47f2c77fc69f2ad850d2e91dc9ca21.tar.bz2
patchage-808a0cbc8d47f2c77fc69f2ad850d2e91dc9ca21.zip
Use a uniform interface for changing settings in the UI
Diffstat (limited to 'src/Reactor.cpp')
-rw-r--r--src/Reactor.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/Reactor.cpp b/src/Reactor.cpp
index 02eb108..f72086d 100644
--- a/src/Reactor.cpp
+++ b/src/Reactor.cpp
@@ -31,6 +31,25 @@ PATCHAGE_RESTORE_WARNINGS
namespace patchage {
+class SettingVisitor
+{
+public:
+ using result_type = void; ///< For boost::apply_visitor
+
+ explicit SettingVisitor(Configuration& conf)
+ : _conf{conf}
+ {}
+
+ template<class S>
+ void operator()(const S& setting) const
+ {
+ _conf.set_setting(setting);
+ }
+
+private:
+ Configuration& _conf;
+};
+
inline std::ostream&
operator<<(std::ostream& os, const ClientType type)
{
@@ -55,6 +74,13 @@ Reactor::Reactor(Configuration& conf,
{}
void
+Reactor::operator()(const action::ChangeSetting& action)
+{
+ SettingVisitor visitor{_conf};
+ boost::apply_visitor(visitor, action.setting);
+}
+
+void
Reactor::operator()(const action::ConnectPorts& action)
{
if (action.tail.type() == action.head.type()) {