diff options
Diffstat (limited to 'logic')
-rw-r--r-- | logic/selected-libraries.cpp | 30 | ||||
-rw-r--r-- | logic/selected-libraries.hpp | 22 | ||||
-rw-r--r-- | logic/tracker.h | 2 |
3 files changed, 50 insertions, 4 deletions
diff --git a/logic/selected-libraries.cpp b/logic/selected-libraries.cpp index ffa3e496..1fc3da86 100644 --- a/logic/selected-libraries.cpp +++ b/logic/selected-libraries.cpp @@ -2,6 +2,24 @@ #include "options/scoped.hpp" #include <QDebug> +using ext_ord = IExtension::event_ordinal; +using ext_mask = IExtension::event_mask; +using ext_fun_type = void(IExtension::*)(Pose&); + +static constexpr struct event_type_mapping +{ + ext_fun_type ptr; + ext_mask m; + ext_ord idx; +} ordinal_to_function[] = { + { &IExtension::process_raw, ext_mask::on_raw, ext_ord::ev_raw, }, + { &IExtension::process_after_center, ext_mask::on_after_center, ext_ord::ev_after_center, }, + { &IExtension::process_before_filter, ext_mask::on_before_filter, ext_ord::ev_before_filter, }, + { &IExtension::process_before_transform, ext_mask::on_before_transform, ext_ord::ev_before_transform, }, + { &IExtension::process_before_mapping, ext_mask::on_before_mapping, ext_ord::ev_before_mapping, }, + { &IExtension::process_finished, ext_mask::on_finished, ext_ord::ev_finished, }, +}; + SelectedLibraries::SelectedLibraries(QFrame* frame, dylibptr t, dylibptr p, dylibptr f) : pTracker(nullptr), pFilter(nullptr), @@ -44,3 +62,15 @@ SelectedLibraries::SelectedLibraries(QFrame* frame, dylibptr t, dylibptr p, dyli end: opts::set_teardown_flag(prev_teardown_flag); } + +void runtime_event_handler::run_events(ext_event_ordinal k, Pose& pose) +{ + auto fun = std::mem_fn(ordinal_to_function[k].ptr); + + for (ext& x : extension_events[k]) + { + if (x == nullptr) + break; + fun(x, pose); + } +} diff --git a/logic/selected-libraries.hpp b/logic/selected-libraries.hpp index 65e9733e..041c77e5 100644 --- a/logic/selected-libraries.hpp +++ b/logic/selected-libraries.hpp @@ -9,11 +9,29 @@ #pragma once #include "api/plugin-support.hpp" +#include "export.hpp" + +#include <array> +#include <functional> + #include <QFrame> -#include "export.hpp" +// XXX todo remove camel case in identifier + +struct runtime_event_handler +{ + using ext_event_ordinal = IExtension::event_ordinal; + using ext = std::shared_ptr<IExtension>; + + enum : unsigned { ext_max_events = 64 }; + using ext_list = std::array<ext, ext_max_events>; + + std::array<ext_list, ext_event_ordinal::event_count> extension_events; + + void run_events(ext_event_ordinal k, Pose& pose); +}; -struct OTR_LOGIC_EXPORT SelectedLibraries +struct OTR_LOGIC_EXPORT SelectedLibraries : runtime_event_handler { using dylibptr = std::shared_ptr<dylib>; diff --git a/logic/tracker.h b/logic/tracker.h index 282b5c5b..ab0cc323 100644 --- a/logic/tracker.h +++ b/logic/tracker.h @@ -31,8 +31,6 @@ namespace gui_tracker_impl { -using Pose = Mat<double, 6, 1>; - struct bits { enum flags : unsigned { |