-
Notifications
You must be signed in to change notification settings - Fork 94
Expand file tree
/
Copy pathplugin.h
More file actions
57 lines (47 loc) · 1.8 KB
/
plugin.h
File metadata and controls
57 lines (47 loc) · 1.8 KB
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
52
53
54
55
56
57
// system includes
#include <filesystem>
#include <map>
#include <regex>
#include <string>
// local includes
#include "linuxdeploy/log/log.h"
#include "linuxdeploy/plugin/exceptions.h"
#pragma once
namespace linuxdeploy {
namespace plugin {
enum PLUGIN_TYPE {
INPUT_TYPE = 0,
OUTPUT_TYPE,
};
/*
* Official regular expression to check filenames for plugins
*/
static const std::regex PLUGIN_EXPR(R"(^linuxdeploy-plugin-([^\s\.-]+)(?:-[^\.]+)?(?:\..+)?$)");
/*
* Plugin interface.
*/
class IPlugin {
// declare interface's constructors and destructor
protected:
explicit IPlugin(const std::filesystem::path& path) {};
// deconstructor apparently needs to be defined, not just declared (with = 0)
virtual ~IPlugin() = default;
public:
virtual std::filesystem::path path() const = 0;
virtual int apiLevel() const = 0;
virtual PLUGIN_TYPE pluginType() const = 0;
virtual std::string pluginTypeString() const = 0;
virtual int run(const std::filesystem::path& appDirPath) = 0;
};
/// Implementations are not public, see source directory for those headers ///
/*
* Factory function to create plugin from given executable.
* This function automatically selects the correct subclass implementing the right API level, and
*/
IPlugin* createPluginInstance(const std::filesystem::path& path);
/*
* Finds all linuxdeploy plugins in $PATH and the current executable's directory and returns IPlugin instances for them.
*/
std::map<std::string, IPlugin*> findPlugins();
}
}