diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2017-09-25 16:25:12 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2017-09-25 16:29:43 +0200 |
commit | fe2a58edc267ff643e50b412f893e15cbafab6b5 (patch) | |
tree | 32e2c5515b67c418f4ab821fca7150be7f819d64 /api | |
parent | eca907d3c1240d04bbcfdf84a3a726353e56bc64 (diff) |
api, options: some `virtual' fixes
Diffstat (limited to 'api')
-rw-r--r-- | api/plugin-api.cpp | 7 | ||||
-rw-r--r-- | api/plugin-api.hpp | 67 |
2 files changed, 64 insertions, 10 deletions
diff --git a/api/plugin-api.cpp b/api/plugin-api.cpp index 729b011f..c1d83d09 100644 --- a/api/plugin-api.cpp +++ b/api/plugin-api.cpp @@ -6,11 +6,9 @@ using namespace plugin_api::detail; Metadata::~Metadata() {} IFilter::~IFilter() {} -IFilterDialog::~IFilterDialog() {} IProtocol::~IProtocol() {} -IProtocolDialog::~IProtocolDialog() {} ITracker::~ITracker() {} -ITrackerDialog::~ITrackerDialog() {} +IExtension::~IExtension() {} void ITrackerDialog::register_tracker(ITracker*) {} void ITrackerDialog::unregister_tracker() {} @@ -26,6 +24,8 @@ void BaseDialog::closeEvent(QCloseEvent*) } } +bool ITracker::center() { return false; } + Metadata::Metadata() {} IFilter::IFilter() {} IFilterDialog::IFilterDialog() {} @@ -42,3 +42,4 @@ void BaseDialog::done(int) close(); } } + diff --git a/api/plugin-api.hpp b/api/plugin-api.hpp index 1e7822c2..ab5025a7 100644 --- a/api/plugin-api.hpp +++ b/api/plugin-api.hpp @@ -15,6 +15,7 @@ #include <QWidget> #include <QDialog> +#include "compat/simple-mat.hpp" #include "export.hpp" using Pose = Mat<double, 6, 1>; @@ -101,7 +102,7 @@ struct OTR_API_EXPORT IFilterDialog : public plugin_api::detail::BaseDialog IFilterDialog(); // optional destructor - virtual ~IFilterDialog(); + //~IFilterDialog() override; // receive a pointer to the filter from ui thread virtual void register_filter(IFilter* filter) = 0; // received filter pointer is about to get deleted @@ -135,7 +136,7 @@ struct OTR_API_EXPORT IProtocol struct OTR_API_EXPORT IProtocolDialog : public plugin_api::detail::BaseDialog { // optional destructor - virtual ~IProtocolDialog(); + // ~IProtocolDialog() override; // receive a pointer to the protocol from ui thread virtual void register_protocol(IProtocol *protocol) = 0; // received protocol pointer is about to get deleted @@ -151,9 +152,6 @@ struct OTR_API_EXPORT IProtocolDialog : public plugin_api::detail::BaseDialog // implement this in trackers struct OTR_API_EXPORT ITracker { - ITracker(const ITracker&) = delete; - ITracker(ITracker&&) = delete; - ITracker& operator=(const ITracker&) = delete; ITracker(); // optional destructor @@ -164,13 +162,17 @@ struct OTR_API_EXPORT ITracker virtual void data(double *data) = 0; // tracker notified of centering // returning true makes identity the center pose - virtual bool center() { return false; } + virtual bool center(); + + ITracker(const ITracker&) = delete; + ITracker(ITracker&&) = delete; + ITracker& operator=(const ITracker&) = delete; }; struct OTR_API_EXPORT ITrackerDialog : public plugin_api::detail::BaseDialog { // optional destructor - virtual ~ITrackerDialog(); + //~ITrackerDialog() override; // receive a pointer to the tracker from ui thread virtual void register_tracker(ITracker *tracker); // received tracker pointer is about to get deleted @@ -182,3 +184,54 @@ struct OTR_API_EXPORT ITrackerDialog : public plugin_api::detail::BaseDialog // call once with your chosen class names in the plugin #define OPENTRACK_DECLARE_TRACKER(tracker_class, dialog_class, metadata_class) \ OPENTRACK_DECLARE_PLUGIN_INTERNAL(tracker_class, ITracker, metadata_class, dialog_class, ITrackerDialog) + +struct OTR_API_EXPORT IExtension +{ + enum event_mask : unsigned + { + none = 0u, + on_raw = 1 << 0, + on_after_center = 1 << 1, + on_before_filter = 1 << 2, + on_before_transform = 1 << 3, + on_before_mapping = 1 << 4, + on_finished = 1 << 5, + }; + + enum event_ordinal : unsigned + { + ev_raw = 0, + ev_after_center = 1, + ev_before_filter = 2, + ev_before_transform = 3, + ev_before_mapping = 4, + ev_finished = 5, + + event_count = 6, + }; + + IExtension() = default; + virtual ~IExtension(); + + virtual event_mask hook_types() = 0; + + virtual void process_raw(Pose&) {} + virtual void process_after_center(Pose&) {} + virtual void process_before_filter(Pose&) {} + virtual void process_before_transform(Pose&) {} + virtual void process_before_mapping(Pose&) {} + virtual void process_finished(Pose&) {} + + IExtension(const IExtension&) = delete; + IExtension(IExtension&&) = delete; + IExtension& operator=(const IExtension&) = delete; +}; + +struct OTR_API_EXPORT IExtensionDialog : public plugin_api::detail::BaseDialog +{ + virtual void register_extension(IExtension& ext) = 0; + virtual void unregister_extension() = 0; +}; + +#define OPENTRACK_DECLARE_EXTENSION(ext_class, dialog_class, metadata_class) \ + OPENTRACK_DECLARE_PLUGIN_INTERNAL(ext_class, IExtension, metadata_class, dialog_class, IExtensionDialog) |