summaryrefslogtreecommitdiffhomepage
path: root/opentrack/selected-libraries.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-06-07 07:24:06 +0200
committerStanislaw Halik <sthalik@misaki.pl>2015-06-07 08:09:31 +0200
commit71856701c8bedad3d992cb63620e695df8727812 (patch)
treefd84ea540955df1510aa0cfd24b599008ad13219 /opentrack/selected-libraries.cpp
parentaa2de50523257778474c9c2ec8da8edbcb31cd8b (diff)
plugin-support: make header-only, expose as public API
Issue: #151 Some global namespace macros are now prefixed with "OPENTRACK_" to avoid namespace clashes. This header is now safe to include in third-party projects.
Diffstat (limited to 'opentrack/selected-libraries.cpp')
-rw-r--r--opentrack/selected-libraries.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/opentrack/selected-libraries.cpp b/opentrack/selected-libraries.cpp
new file mode 100644
index 00000000..8cb226c8
--- /dev/null
+++ b/opentrack/selected-libraries.cpp
@@ -0,0 +1,42 @@
+#include "opentrack/selected-libraries.hpp"
+#include <QDebug>
+
+SelectedLibraries::~SelectedLibraries()
+{
+}
+
+template<typename t>
+static mem<t> make_instance(mem<dylib> lib)
+{
+ mem<t> ret;
+ if (lib != nullptr && lib->Constructor)
+ ret = mem<t>(reinterpret_cast<t*>(reinterpret_cast<OPENTRACK_CTOR_FUNPTR>(lib->Constructor)()));
+ return ret;
+}
+
+SelectedLibraries::SelectedLibraries(QFrame* frame, dylibptr t, dylibptr p, dylibptr f) :
+ pTracker(nullptr),
+ pFilter(nullptr),
+ pProtocol(nullptr),
+ correct(false)
+{
+ pTracker = make_instance<ITracker>(t);
+ pProtocol = make_instance<IProtocol>(p);
+ pFilter = make_instance<IFilter>(f);
+
+ if (!pTracker || !pProtocol)
+ {
+ qDebug() << "dylib load failure";
+ return;
+ }
+
+ if(!pProtocol->correct())
+ {
+ qDebug() << "protocol load failure";
+ return;
+ }
+
+ pTracker->start_tracker(frame);
+
+ correct = true;
+}