summaryrefslogtreecommitdiffhomepage
path: root/opentrack/plugin-support.h
blob: 238aeb5390b4f75aa8beff2849e36c4ba8889f39 (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
48
49
50
51
#pragma once

#include "plugin-api.hpp"

#include <QWidget>
#include <QDebug>
#include <QString>
#include <QLibrary>
#include <QFrame>
#include <QList>

#include <memory>
template<typename t> using ptr = std::shared_ptr<t>;

extern "C" typedef void* (*CTOR_FUNPTR)(void);
extern "C" typedef Metadata* (*METADATA_FUNPTR)(void);

struct dylib {
    enum Type { Filter, Tracker, Protocol };
    
    dylib(const QString& filename, Type t);
    ~dylib();
    static QList<ptr<dylib>> enum_libraries();
    
    Type type;
    QString filename;
    
    QIcon icon;
    QString name;
    
    CTOR_FUNPTR Dialog;
    CTOR_FUNPTR Constructor;
    METADATA_FUNPTR Meta;
private:
#if defined(_WIN32)
    QLibrary* handle;
#else
    void* handle;
#endif
};

struct SelectedLibraries {
    using dylibtr = ptr<dylib>;
    ptr<ITracker> pTracker;
    ptr<IFilter> pFilter;
    ptr<IProtocol> pProtocol;
    SelectedLibraries(QFrame* frame, dylibtr t, dylibtr p, dylibtr f);
    SelectedLibraries() : pTracker(nullptr), pFilter(nullptr), pProtocol(nullptr), correct(false) {}
    ~SelectedLibraries();
    bool correct;
};