-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathPlugin.h
More file actions
59 lines (42 loc) · 1.5 KB
/
Plugin.h
File metadata and controls
59 lines (42 loc) · 1.5 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
#pragma once
#include <expected>
#include "PluginProtocol.h"
#include "llvm/ADT/StringRef.h"
// clang-format off
/// Run `python scripts/plugin-def.py update` to update the hash.
#define CLICE_PLUGIN_DEF_HASH "sha256:e7f911c923f9cdcec6c0edea328292bd48771f7139d4489ed694a72e9af33fc1"
// clang-format on
namespace clice {
/// The hash of the definitions exposed to server plugins.
constexpr std::string_view plugin_definition_hash = CLICE_PLUGIN_DEF_HASH;
class Server;
struct ServerPluginBuilder;
/// A loaded server plugin.
///
/// An instance of this class wraps a loaded server plugin and gives access to its interface.
class Plugin {
public:
/// Attempts to load a server plugin from a given file.
///
/// Returns an error if either the library cannot be found or loaded,
/// there is no public entry point, or the plugin implements the wrong API
/// version.
static std::expected<Plugin, std::string> load(const std::string& file_path);
/// Gets the file path of the loaded plugin.
llvm::StringRef file_path() const;
/// Gets the name of the loaded plugin.
llvm::StringRef name() const;
/// Gets the version of the loaded plugin.
llvm::StringRef version() const;
/// Registers the server callbacks for the loaded plugin.
void register_server_callbacks(ServerPluginBuilder& builder) const;
public:
struct Self;
Plugin(Self* self) : self(self) {}
Self* operator->() {
return self;
}
protected:
Self* self;
};
} // namespace clice