-
Notifications
You must be signed in to change notification settings - Fork 97
Expand file tree
/
Copy pathplugin.h
More file actions
59 lines (48 loc) · 1.85 KB
/
plugin.h
File metadata and controls
59 lines (48 loc) · 1.85 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
58
59
// system includes
#include <map>
#include <string>
// library includes
#include <boost/filesystem.hpp>
#include <boost/regex.hpp>
// local includes
#include "linuxdeploy/core/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 boost::regex PLUGIN_EXPR(R"(^linuxdeploy-plugin-([^\s\.-]+)(?:-[^\.]+)?(?:\..+)?$)");
/*
* Plugin interface.
*/
class IPlugin {
// declare interface's constructors and destructor
protected:
explicit IPlugin(const boost::filesystem::path& path) {};
// deconstructor apparently needs to be defined, not just declared (with = 0)
virtual ~IPlugin() = default;
public:
virtual boost::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 boost::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 boost::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();
}
}