blob: 25ccbb2dc441c9a88f879710222b5f9f2c6888b5 (
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
// Copyright (C) 2016-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#ifndef VSOMEIP_V3_PLUGIN_HPP_
#define VSOMEIP_V3_PLUGIN_HPP_
#include <memory>
#include <string>
#if _WIN32
#if VSOMEIP_DLL_COMPILATION_PLUGIN
#define VSOMEIP_IMPORT_EXPORT_PLUGIN __declspec(dllexport)
#else
#define VSOMEIP_IMPORT_EXPORT_PLUGIN __declspec(dllimport)
#endif
#else
#define VSOMEIP_IMPORT_EXPORT_PLUGIN
#endif
#define VSOMEIP_PLUGIN_INIT_SYMBOL "vsomeip_plugin_init"
namespace vsomeip_v3 {
enum class plugin_type_e : uint8_t {
APPLICATION_PLUGIN,
PRE_CONFIGURATION_PLUGIN,
CONFIGURATION_PLUGIN,
SD_RUNTIME_PLUGIN
};
class plugin;
typedef std::shared_ptr<plugin> (*create_plugin_func)();
typedef create_plugin_func (*plugin_init_func)();
/**
* Base class for all plug-ins
*/
class VSOMEIP_IMPORT_EXPORT_PLUGIN plugin {
public:
virtual ~plugin() {}
virtual uint32_t get_plugin_version() const = 0;
virtual const std::string &get_plugin_name() const = 0;
virtual plugin_type_e get_plugin_type() const = 0;
};
template<class Plugin_>
class plugin_impl : public plugin {
public:
static std::shared_ptr<plugin> get_plugin() {
return std::make_shared<Plugin_>();
}
plugin_impl(const std::string &_name, uint32_t _version,
plugin_type_e _type) {
name_ = _name;
version_ = _version;
type_ = _type;
}
const std::string &get_plugin_name() const {
return name_;
}
uint32_t get_plugin_version() const {
return version_;
}
plugin_type_e get_plugin_type() const {
return type_;
}
private:
uint32_t version_;
std::string name_;
plugin_type_e type_;
};
#define VSOMEIP_PLUGIN(class_name) \
extern "C" { \
VSOMEIP_EXPORT vsomeip_v3::create_plugin_func vsomeip_plugin_init() { \
return class_name::get_plugin; \
} \
}
} // namespace vsomeip_v3
#endif // VSOMEIP_V3_PLUGIN_HPP_
|