neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
ui_element_library_plugin.hpp
Go to the documentation of this file.
1/*
2 ui_element_library_plugin.hpp
3
4 Copyright (c) 2019, 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>
30
31namespace neogfx::nrc
32{
33 template <typename ElementLibrary>
35 {
36 public:
37 typedef ElementLibrary library_type;
38 public:
40 neolib::i_application& aApplication,
41 const neolib::uuid& aId = library_type::library_id(),
42 std::string const& aName = library_type::library_name(),
43 std::string const& aDescription = library_type::library_description(),
44 const neolib::version& aVersion = library_type::library_version(),
45 std::string const& aCopyright = library_type::library_copyright()) :
46 iApplication{ aApplication },
47 iId{ aId },
48 iName{ aName },
49 iDescription{ aDescription },
50 iVersion{ aVersion },
51 iCopyright{ aCopyright },
52 iLoaded{ false }
53 {
54 }
55 public:
56 bool discover(const neolib::uuid& aId, void*& aObject) override
57 {
58 if (aId == i_ui_element_library::iid())
59 {
60 aObject = new library_type{ iApplication, "file:///" + boost::dll::this_line_location().string() };
61 return true;
62 }
63 return false;
64 }
65 public:
66 const neolib::uuid& id() const override
67 {
68 return iId;
69 }
70 const neolib::i_string& name() const override
71 {
72 return iName;
73 }
74 const neolib::i_string& description() const override
75 {
76 return iDescription;
77 }
78 const neolib::i_version& version() const override
79 {
80 return iVersion;
81 }
82 const neolib::i_string& copyright() const override
83 {
84 return iCopyright;
85 }
86 bool load() override
87 {
88 iLoaded = true;
89 return true;
90 }
91 bool unload() override
92 {
93 service<i_resource_manager>().clean();
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;
113 };
114}
static const neolib::uuid & iid()
const neolib::uuid & id() const override
const neolib::i_string & name() const override
const neolib::i_version & version() const override
const neolib::i_string & copyright() const override
const neolib::i_string & description() const override
bool open_uri(const neolib::i_string &aUri) override
ui_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())
bool discover(const neolib::uuid &aId, void *&aObject) override