neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
plugin_manager.hpp
Go to the documentation of this file.
1// plugin_manager.hpp
2/*
3 * Copyright (c) 2007 Leigh Johnston.
4 *
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are
9 * met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 *
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 *
18 * * Neither the name of Leigh Johnston nor the names of any
19 * other contributors to this software may be used to endorse or
20 * promote products derived from this software without specific prior
21 * written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
24 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
25 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
27 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34*/
35
36#pragma once
37
38#include <neolib/neolib.hpp>
39#include <map>
40#include <memory>
41#include <filesystem>
44#include <neolib/app/module.hpp>
45#include <neolib/task/event.hpp>
48
49namespace neolib
50{
51 class NEOLIB_EXPORT plugin_manager : public reference_counted<i_plugin_manager>
52 {
53 // events
54 public:
55 define_declared_event(PluginLoaded, plugin_loaded, i_plugin&)
56 define_declared_event(PluginUnloaded, plugin_unloaded, i_plugin&)
57 // types
58 private:
59 typedef vector<string> plugin_file_extensions_t;
60 typedef vector<string> plugin_folders_t;
61 typedef std::map<uuid, std::unique_ptr<module>> modules_t;
63 // construction
64 public:
67 // implementation
68 public:
69 // from i_discoverable
70 bool discover(const uuid& aId, void*& aObject) override;
71 // from i_plugin_manager
72 const plugin_file_extensions_t& plugin_file_extensions() const override;
73 plugin_file_extensions_t& plugin_file_extensions() override;
74 const plugin_folders_t& plugin_folders() const override;
75 plugin_folders_t& plugin_folders() override;
76 bool load_plugins() override;
77 bool load_plugin(const i_string& aPluginPath) override;
78 void enable_plugin(i_plugin& aPlugin, bool aEnable) override;
79 bool plugin_enabled(const i_plugin& aPlugin) const override;
80 void unload_plugins() override;
81 const plugins_t& plugins() const override;
82 const i_ref_ptr<i_plugin>& find_plugin(const uuid& aId) const override;
83 i_ref_ptr<i_plugin>& find_plugin(const uuid& aId) override;
84 bool open_uri(const i_string& aUri) override;
85 // implementation
86 private:
87 // own
88 i_ref_ptr<i_plugin>& create_plugin(const i_string& aPluginPath);
89 // attributes
90 private:
91 i_application& iApplication;
92 plugin_file_extensions_t iPluginFileExtensions;
93 plugin_folders_t iPluginFolders;
94 modules_t iModules;
95 plugins_t iPlugins;
96 bool iInitializing;
97 };
98}
define_declared_event(PluginLoaded, plugin_loaded, i_plugin &) define_declared_event(PluginUnloaded
Definition plf_hive.h:79
#define define_declared_event(name, declName,...)
Definition event.hpp:195