neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
element_library_plugin.hpp
Go to the documentation of this file.
1/*
2 element_library_plugin.hpp
3
4 Copyright (c) 2020 Leigh Johnston. All Rights Reserved.
5
6 This program is free software: you can redistribute it and / or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#pragma once
21
22#include <neogfx/neogfx.hpp>
23#include <boost/dll.hpp>
29
31{
32 template <typename ElementLibrary>
33 class element_library_plugin : public neolib::reference_counted<neolib::i_plugin>
34 {
35 public:
36 typedef ElementLibrary library_type;
37 public:
39 neolib::i_application& aApplication,
40 const neolib::uuid& aId = library_type::library_id(),
41 std::string const& aName = library_type::library_name(),
42 std::string const& aDescription = library_type::library_description(),
43 const neolib::version& aVersion = library_type::library_version(),
44 std::string const& aCopyright = library_type::library_copyright()) :
45 iApplication{ aApplication },
46 iId{ aId },
47 iName{ aName },
48 iDescription{ aDescription },
49 iVersion{ aVersion },
50 iCopyright{ aCopyright },
51 iLoaded{ false }
52 {
53 }
54 public:
55 bool discover(const neolib::uuid& aId, void*& aObject) override
56 {
57 if (aId == i_element_library::iid())
58 {
59 if (!iLibrary)
60 iLibrary = neolib::make_ref<library_type>(iApplication, "file:///" + boost::dll::this_line_location().string());
61 aObject = &*iLibrary;
62 return true;
63 }
64 return false;
65 }
66 public:
67 const neolib::uuid& id() const override
68 {
69 return iId;
70 }
71 const neolib::i_string& name() const override
72 {
73 return iName;
74 }
75 const neolib::i_string& description() const override
76 {
77 return iDescription;
78 }
79 const neolib::i_version& version() const override
80 {
81 return iVersion;
82 }
83 const neolib::i_string& copyright() const override
84 {
85 return iCopyright;
86 }
87 bool load() override
88 {
89 iLoaded = true;
90 return true;
91 }
92 bool unload() override
93 {
94 iLoaded = false;
95 return true;
96 }
97 bool loaded() const override
98 {
99 return iLoaded;
100 }
101 bool open_uri(const neolib::i_string& aUri) override
102 {
103 return false;
104 }
105 private:
106 neolib::i_application& iApplication;
107 neolib::uuid iId;
108 neolib::string iName;
109 neolib::string iDescription;
110 neolib::version iVersion;
111 neolib::string iCopyright;
112 bool iLoaded;
114 };
115}
element_library_plugin(neolib::i_application &aApplication, const neolib::uuid &aId=library_type::library_id(), std::string const &aName=library_type::library_name(), std::string const &aDescription=library_type::library_description(), const neolib::version &aVersion=library_type::library_version(), std::string const &aCopyright=library_type::library_copyright())
const neolib::i_string & copyright() const override
const neolib::i_string & description() const override
bool discover(const neolib::uuid &aId, void *&aObject) override
const neolib::i_string & name() const override
const neolib::i_version & version() const override
bool open_uri(const neolib::i_string &aUri) override
ref_ptr< ConcreteType > make_ref(Args &&... args)