From 577fc3945f7515aef936f0d05d4756423a0b5bc2 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 16 Jul 2015 11:29:27 +0200 Subject: api: document stuff to be implemented --- opentrack/plugin-qt-api.hpp | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) (limited to 'opentrack') diff --git a/opentrack/plugin-qt-api.hpp b/opentrack/plugin-qt-api.hpp index dd9cc280..89b71f81 100644 --- a/opentrack/plugin-qt-api.hpp +++ b/opentrack/plugin-qt-api.hpp @@ -4,58 +4,90 @@ #include #include +// implement this in all plugins struct Metadata { public: + // plugin name to be displayed in the interface virtual QString name() = 0; + // plugin icon, you can return an empty QIcon() virtual QIcon icon() = 0; + // optional destructor virtual ~Metadata() {} }; -// XXX TODO get rid of QString/QFrame to fix ABI woes -// will lead plugins from different C++ runtimes working -sh 20141004 - +// implement this in filters struct IFilter { public: + // optional destructor virtual ~IFilter() {} + // perform filtering step. + // you have to take care of dt on your own, try "opentrack/timer.hpp" virtual void filter(const double *input, double *output) = 0; }; struct IFilterDialog : public QWidget { + // optional destructor virtual ~IFilterDialog() {} + // receive a pointer to thefilter from ui thread virtual void register_filter(IFilter* filter) = 0; + // received filter pointer is about to get deleted virtual void unregister_filter() = 0; }; +// call once with your chosen class names in the plugin +#define OPENTRACK_DECLARE_FILTER(filter_class, dialog_class, metadata_class) \ + OPENTRACK_DECLARE_PLUGIN_INTERNAL(filter_class, IFilter, metadata_class, dialog_class, IFilterDialog) + +// implement this in protocols struct IProtocol { public: + // optional destructor virtual ~IProtocol() {} + // return true if protocol was properly initialized virtual bool correct() = 0; + // called 250 times a second with XYZ yaw pitch roll pose + // try not to perform intense computation here. if you must, use a thread. virtual void pose(const double* headpose) = 0; + // return game name or placeholder text virtual QString game_name() = 0; }; struct IProtocolDialog : public QWidget { + // optional destructor virtual ~IProtocolDialog() {} + // receive a pointer to theprotocol from ui thread virtual void register_protocol(IProtocol *protocol) = 0; + // received protocol pointer is about to get deleted virtual void unregister_protocol() = 0; }; +// call once with your chosen class names in the plugin +#define OPENTRACK_DECLARE_PROTOCOL(protocol_class, dialog_class, metadata_class) \ + OPENTRACK_DECLARE_PLUGIN_INTERNAL(protocol_class, IProtocol, metadata_class, dialog_class, IProtocolDialog) + +// implement this in trackers struct ITracker { public: + // optional destructor virtual ~ITracker() {} + // start tracking, and grab a frame to display webcam video in, optionally virtual void start_tracker(QFrame* frame) = 0; + // return XYZ yaw pitch roll data. don't block here, use a separate thread for computation. virtual void data(double *data) = 0; }; struct ITrackerDialog : public QWidget { + // optional destructor virtual ~ITrackerDialog() {} + // receive a pointer to thetracker from ui thread virtual void register_tracker(ITracker *tracker) = 0; + // received tracker pointer is about to get deleted virtual void unregister_tracker() = 0; }; -- cgit v1.2.3 From dfbe00cb1d9ce4cb52448cf4c1d577fe7b1eaad7 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 16 Jul 2015 11:29:45 +0200 Subject: api: introduce macros for symbol exposure --- opentrack/plugin-qt-api.hpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'opentrack') diff --git a/opentrack/plugin-qt-api.hpp b/opentrack/plugin-qt-api.hpp index 89b71f81..2ccdad19 100644 --- a/opentrack/plugin-qt-api.hpp +++ b/opentrack/plugin-qt-api.hpp @@ -4,6 +4,20 @@ #include #include +#define OPENTRACK_DECLARE_PLUGIN_INTERNAL(ctor_class, ctor_ret_class, metadata_class, dialog_class, dialog_ret_class) \ + extern "C" OPENTRACK_EXPORT ctor_ret_class* GetConstructor() \ + { \ + return new ctor_class; \ + } \ + extern "C" OPENTRACK_EXPORT Metadata* GetMetadata() \ + { \ + return new metadata_class; \ + } \ + extern "C" OPENTRACK_EXPORT dialog_ret_class* GetDialog() \ + { \ + return new dialog_class; \ + } + // implement this in all plugins struct Metadata { @@ -91,3 +105,7 @@ struct ITrackerDialog : public QWidget // received tracker pointer is about to get deleted virtual void unregister_tracker() = 0; }; + +// 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) -- cgit v1.2.3 From 302bfdf7ce7fe73eaf5d0a40a988d3285f0bb1bb Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 16 Jul 2015 11:45:32 +0200 Subject: unused #define --- opentrack/plugin-api.hpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'opentrack') diff --git a/opentrack/plugin-api.hpp b/opentrack/plugin-api.hpp index a8996d63..c5a93e70 100644 --- a/opentrack/plugin-api.hpp +++ b/opentrack/plugin-api.hpp @@ -6,6 +6,4 @@ enum Axis { TX = 0, TY, TZ, Yaw, Pitch, Roll }; -#ifndef OPENTRACK_CROSS_ONLY -# include "plugin-qt-api.hpp" -#endif \ No newline at end of file +#include "plugin-qt-api.hpp" -- cgit v1.2.3 From 0bc5805c3430a3d2f05b0b7dd14704a21dfeb02b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 16 Jul 2015 12:40:14 +0200 Subject: unify plugin-api files --- opentrack/plugin-api.hpp | 109 ++++++++++++++++++++++++++++++++++++++++++- opentrack/plugin-qt-api.hpp | 111 -------------------------------------------- 2 files changed, 108 insertions(+), 112 deletions(-) delete mode 100644 opentrack/plugin-qt-api.hpp (limited to 'opentrack') diff --git a/opentrack/plugin-api.hpp b/opentrack/plugin-api.hpp index c5a93e70..714e69d9 100644 --- a/opentrack/plugin-api.hpp +++ b/opentrack/plugin-api.hpp @@ -1,9 +1,116 @@ #pragma once #include "export.hpp" +#include +#include +#include enum Axis { TX = 0, TY, TZ, Yaw, Pitch, Roll }; -#include "plugin-qt-api.hpp" +#define OPENTRACK_DECLARE_PLUGIN_INTERNAL(ctor_class, ctor_ret_class, metadata_class, dialog_class, dialog_ret_class) \ + extern "C" OPENTRACK_EXPORT ctor_ret_class* GetConstructor() \ + { \ + return new ctor_class; \ + } \ + extern "C" OPENTRACK_EXPORT Metadata* GetMetadata() \ + { \ + return new metadata_class; \ + } \ + extern "C" OPENTRACK_EXPORT dialog_ret_class* GetDialog() \ + { \ + return new dialog_class; \ + } + +// implement this in all plugins +struct Metadata +{ +public: + // plugin name to be displayed in the interface + virtual QString name() = 0; + // plugin icon, you can return an empty QIcon() + virtual QIcon icon() = 0; + // optional destructor + virtual ~Metadata() {} +}; + +// implement this in filters +struct IFilter +{ +public: + // optional destructor + virtual ~IFilter() {} + // perform filtering step. + // you have to take care of dt on your own, try "opentrack/timer.hpp" + virtual void filter(const double *input, double *output) = 0; +}; + +struct IFilterDialog : public QWidget +{ + // optional destructor + virtual ~IFilterDialog() {} + // receive a pointer to the filter from ui thread + virtual void register_filter(IFilter* filter) = 0; + // received filter pointer is about to get deleted + virtual void unregister_filter() = 0; +}; + +// call once with your chosen class names in the plugin +#define OPENTRACK_DECLARE_FILTER(filter_class, dialog_class, metadata_class) \ + OPENTRACK_DECLARE_PLUGIN_INTERNAL(filter_class, IFilter, metadata_class, dialog_class, IFilterDialog) + +// implement this in protocols +struct IProtocol +{ +public: + // optional destructor + virtual ~IProtocol() {} + // return true if protocol was properly initialized + virtual bool correct() = 0; + // called 250 times a second with XYZ yaw pitch roll pose + // try not to perform intense computation here. if you must, use a thread. + virtual void pose(const double* headpose) = 0; + // return game name or placeholder text + virtual QString game_name() = 0; +}; + +struct IProtocolDialog : public QWidget +{ + // optional destructor + virtual ~IProtocolDialog() {} + // receive a pointer to the protocol from ui thread + virtual void register_protocol(IProtocol *protocol) = 0; + // received protocol pointer is about to get deleted + virtual void unregister_protocol() = 0; +}; + +// call once with your chosen class names in the plugin +#define OPENTRACK_DECLARE_PROTOCOL(protocol_class, dialog_class, metadata_class) \ + OPENTRACK_DECLARE_PLUGIN_INTERNAL(protocol_class, IProtocol, metadata_class, dialog_class, IProtocolDialog) + +// implement this in trackers +struct ITracker +{ +public: + // optional destructor + virtual ~ITracker() {} + // start tracking, and grab a frame to display webcam video in, optionally + virtual void start_tracker(QFrame* frame) = 0; + // return XYZ yaw pitch roll data. don't block here, use a separate thread for computation. + virtual void data(double *data) = 0; +}; + +struct ITrackerDialog : public QWidget +{ + // optional destructor + virtual ~ITrackerDialog() {} + // receive a pointer to the tracker from ui thread + virtual void register_tracker(ITracker *tracker) = 0; + // received tracker pointer is about to get deleted + virtual void unregister_tracker() = 0; +}; + +// 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) diff --git a/opentrack/plugin-qt-api.hpp b/opentrack/plugin-qt-api.hpp deleted file mode 100644 index 2ccdad19..00000000 --- a/opentrack/plugin-qt-api.hpp +++ /dev/null @@ -1,111 +0,0 @@ -#pragma once - -#include -#include -#include - -#define OPENTRACK_DECLARE_PLUGIN_INTERNAL(ctor_class, ctor_ret_class, metadata_class, dialog_class, dialog_ret_class) \ - extern "C" OPENTRACK_EXPORT ctor_ret_class* GetConstructor() \ - { \ - return new ctor_class; \ - } \ - extern "C" OPENTRACK_EXPORT Metadata* GetMetadata() \ - { \ - return new metadata_class; \ - } \ - extern "C" OPENTRACK_EXPORT dialog_ret_class* GetDialog() \ - { \ - return new dialog_class; \ - } - -// implement this in all plugins -struct Metadata -{ -public: - // plugin name to be displayed in the interface - virtual QString name() = 0; - // plugin icon, you can return an empty QIcon() - virtual QIcon icon() = 0; - // optional destructor - virtual ~Metadata() {} -}; - -// implement this in filters -struct IFilter -{ -public: - // optional destructor - virtual ~IFilter() {} - // perform filtering step. - // you have to take care of dt on your own, try "opentrack/timer.hpp" - virtual void filter(const double *input, double *output) = 0; -}; - -struct IFilterDialog : public QWidget -{ - // optional destructor - virtual ~IFilterDialog() {} - // receive a pointer to thefilter from ui thread - virtual void register_filter(IFilter* filter) = 0; - // received filter pointer is about to get deleted - virtual void unregister_filter() = 0; -}; - -// call once with your chosen class names in the plugin -#define OPENTRACK_DECLARE_FILTER(filter_class, dialog_class, metadata_class) \ - OPENTRACK_DECLARE_PLUGIN_INTERNAL(filter_class, IFilter, metadata_class, dialog_class, IFilterDialog) - -// implement this in protocols -struct IProtocol -{ -public: - // optional destructor - virtual ~IProtocol() {} - // return true if protocol was properly initialized - virtual bool correct() = 0; - // called 250 times a second with XYZ yaw pitch roll pose - // try not to perform intense computation here. if you must, use a thread. - virtual void pose(const double* headpose) = 0; - // return game name or placeholder text - virtual QString game_name() = 0; -}; - -struct IProtocolDialog : public QWidget -{ - // optional destructor - virtual ~IProtocolDialog() {} - // receive a pointer to theprotocol from ui thread - virtual void register_protocol(IProtocol *protocol) = 0; - // received protocol pointer is about to get deleted - virtual void unregister_protocol() = 0; -}; - -// call once with your chosen class names in the plugin -#define OPENTRACK_DECLARE_PROTOCOL(protocol_class, dialog_class, metadata_class) \ - OPENTRACK_DECLARE_PLUGIN_INTERNAL(protocol_class, IProtocol, metadata_class, dialog_class, IProtocolDialog) - -// implement this in trackers -struct ITracker -{ -public: - // optional destructor - virtual ~ITracker() {} - // start tracking, and grab a frame to display webcam video in, optionally - virtual void start_tracker(QFrame* frame) = 0; - // return XYZ yaw pitch roll data. don't block here, use a separate thread for computation. - virtual void data(double *data) = 0; -}; - -struct ITrackerDialog : public QWidget -{ - // optional destructor - virtual ~ITrackerDialog() {} - // receive a pointer to thetracker from ui thread - virtual void register_tracker(ITracker *tracker) = 0; - // received tracker pointer is about to get deleted - virtual void unregister_tracker() = 0; -}; - -// 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) -- cgit v1.2.3