summaryrefslogtreecommitdiffhomepage
path: root/logic/runtime-libraries.cpp
blob: eb5f02cc841dfc0813fb5d3ef990587e3d969096 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "runtime-libraries.hpp"
#include "options/scoped.hpp"
#include <QDebug>

runtime_libraries::runtime_libraries(QFrame* frame, dylibptr t, dylibptr p, dylibptr f) :
    pTracker(nullptr),
    pFilter(nullptr),
    pProtocol(nullptr),
    correct(false)
{
    using namespace options;

    const bool prev_teardown_flag = opts::is_tracker_teardown();

    opts::set_teardown_flag(true);

    pProtocol = make_dylib_instance<IProtocol>(p);

    if (!pProtocol)
    {
        qDebug() << "protocol dylib load failure";
        goto end;
    }

    if(!pProtocol->correct())
    {
        qDebug() << "protocol load failure";
        pProtocol = nullptr;
        goto end;
    }

    pTracker = make_dylib_instance<ITracker>(t);
    pFilter = make_dylib_instance<IFilter>(f);

    if (!pTracker)
    {
        qDebug() << "tracker dylib load failure";
        goto end;
    }

    pTracker->start_tracker(frame);

    correct = true;
end:
    opts::set_teardown_flag(prev_teardown_flag);
}