ScummVM API documentation
elf-provider.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef BACKENDS_PLUGINS_ELF_PROVIDER_H
23#define BACKENDS_PLUGINS_ELF_PROVIDER_H
24
25#include "common/scummsys.h"
26
27#if defined(DYNAMIC_MODULES) && defined(USE_ELF_LOADER)
28
29#include "backends/plugins/elf/elf-loader.h"
30
31#include "common/fs.h"
32
42class ELFPlugin : public DynamicPlugin {
43protected:
44 typedef const char *(*CharFunc)();
45
46 DLObject *_dlHandle;
47 VoidFunc _finalizeFunc;
48
49 virtual VoidFunc findSymbol(const char *symbol);
50
51public:
52 ELFPlugin(const Common::Path &filename) :
53 DynamicPlugin(filename),
54 _dlHandle(0),
55 _finalizeFunc(0) {
56 }
57
58 virtual ~ELFPlugin() {
59 if (_dlHandle)
60 unloadPlugin();
61 }
62
63 virtual DLObject *makeDLObject() = 0;
64
65 virtual bool loadPlugin();
66 virtual void unloadPlugin();
67 void trackSize();
68};
69
70template<class T>
71class TemplatedELFPlugin : public ELFPlugin {
72public:
73 TemplatedELFPlugin(const Common::Path &filename) :
74 ELFPlugin(filename) {
75 }
76
77 virtual DLObject *makeDLObject() {
78 return new T();
79 }
80};
81
82
83class ELFPluginProvider : public FilePluginProvider {
84protected:
85 virtual Plugin *createPlugin(const Common::FSNode &node) const = 0;
86 virtual PluginList getPlugins();
87
88 bool isPluginFilename(const Common::FSNode &node) const;
89};
90
91#endif // defined(DYNAMIC_MODULES) && defined(USE_ELF_LOADER)
92
93#endif /* BACKENDS_PLUGINS_ELF_PROVIDER_H */
Definition: fs.h:69
Definition: path.h:52
Definition: dcloader.h:29
Definition: dynamic-plugin.h:29
Definition: plugins.h:157