From 71856701c8bedad3d992cb63620e695df8727812 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 7 Jun 2015 07:24:06 +0200 Subject: 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. --- opentrack/selected-libraries.cpp | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 opentrack/selected-libraries.cpp (limited to 'opentrack/selected-libraries.cpp') 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 + +SelectedLibraries::~SelectedLibraries() +{ +} + +template +static mem make_instance(mem lib) +{ + mem ret; + if (lib != nullptr && lib->Constructor) + ret = mem(reinterpret_cast(reinterpret_cast(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(t); + pProtocol = make_instance(p); + pFilter = make_instance(f); + + if (!pTracker || !pProtocol) + { + qDebug() << "dylib load failure"; + return; + } + + if(!pProtocol->correct()) + { + qDebug() << "protocol load failure"; + return; + } + + pTracker->start_tracker(frame); + + correct = true; +} -- cgit v1.2.3