diff options
author | David Robillard <d@drobilla.net> | 2020-11-28 22:23:54 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-11-28 22:49:10 +0100 |
commit | 924775a79c07a4f5798fcefddb523b189e473080 (patch) | |
tree | 6a201df93b109d10cb5c5cab018ee89448c00e00 /src/Driver.hpp | |
parent | 5128bfab7ddb9504abf17375e910e5bc94af291e (diff) | |
download | patchage-924775a79c07a4f5798fcefddb523b189e473080.tar.gz patchage-924775a79c07a4f5798fcefddb523b189e473080.tar.bz2 patchage-924775a79c07a4f5798fcefddb523b189e473080.zip |
Abstract out sending of events
This removes the details of how events are handled from drivers, so the owner
can set them up to do anything. For example, a driver could be run in the GUI
thread and have its events simply dispatched immediately, but here everything
is enqueued to the same queue which is drained later for simplicity.
Diffstat (limited to 'src/Driver.hpp')
-rw-r--r-- | src/Driver.hpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/Driver.hpp b/src/Driver.hpp index d40f7b5..d85e5bc 100644 --- a/src/Driver.hpp +++ b/src/Driver.hpp @@ -22,6 +22,7 @@ #include <sigc++/sigc++.h> #include <functional> +#include <utility> class Patchage; @@ -31,7 +32,9 @@ class Driver public: using EventSink = std::function<void(const PatchageEvent&)>; - Driver() = default; + explicit Driver(EventSink emit_event) + : _emit_event{std::move(emit_event)} + {} Driver(const Driver&) = delete; Driver& operator=(const Driver&) = delete; @@ -41,8 +44,6 @@ public: virtual ~Driver() = default; - virtual void process_events(Patchage* app) = 0; - virtual void attach(bool launch_daemon) = 0; virtual void detach() = 0; virtual bool is_attached() const = 0; @@ -54,6 +55,9 @@ public: sigc::signal<void> signal_attached; sigc::signal<void> signal_detached; + +protected: + EventSink _emit_event; }; #endif // PATCHAGE_DRIVER_HPP |