summaryrefslogtreecommitdiffhomepage
path: root/opentrack/selected-libraries.cpp
diff options
context:
space:
mode:
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;
+}