neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
i_ui_element_library.hpp
Go to the documentation of this file.
1// i_ui_element_library.hpp
2/*
3neoGFX Resource Compiler
4Copyright(C) 2019 Leigh Johnston
5
6This program is free software: you can redistribute it and / or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation, either version 3 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#pragma once
21
22#include <neogfx/neogfx.hpp>
24#include <neolib/core/i_set.hpp>
28
29namespace neogfx::nrc
30{
31 class i_ui_element_parser;
32
34 {
35 // types
36 public:
39 // exceptions
40 public:
41 struct unknown_element_type : std::logic_error { unknown_element_type() : std::logic_error{ "neogfx::nrc::i_ui_element_library::unknown_element_type" } {} };
42 // meta
43 public:
44 virtual bool handles_element(const neolib::i_string& aElementType) const = 0;
45 virtual bool handles_element(i_ui_element& aParent, const neolib::i_string& aElementType) const = 0;
46 // factory
47 public:
49 {
50 return neolib::ref_ptr<i_ui_element>{ do_create_element(aParser, aElementType) };
51 }
52 neolib::ref_ptr<i_ui_element> create_element(const i_ui_element_parser& aParser, i_ui_element& aParent, const neolib::i_string& aElementType)
53 {
54 return neolib::ref_ptr<i_ui_element>{ do_create_element(aParser, aParent, aElementType) };
55 }
56 // implementation
57 private:
58 virtual i_ui_element* do_create_element(const i_ui_element_parser& aParser, const neolib::i_string& aElementType) = 0;
59 virtual i_ui_element* do_create_element(const i_ui_element_parser& aParser, i_ui_element& aParent, const neolib::i_string& aElementType) = 0;
60 // interface
61 public:
62 static const neolib::uuid& iid() { static const neolib::uuid sId = neolib::make_uuid("3D10EA2F-5110-419C-BFF9-93263C618792"); return sId; }
63 };
64}
neolib::ref_ptr< i_ui_element > create_element(const i_ui_element_parser &aParser, i_ui_element &aParent, const neolib::i_string &aElementType)
static const neolib::uuid & iid()
neolib::ref_ptr< i_ui_element > create_element(const i_ui_element_parser &aParser, const neolib::i_string &aElementType)
virtual bool handles_element(i_ui_element &aParent, const neolib::i_string &aElementType) const =0
virtual bool handles_element(const neolib::i_string &aElementType) const =0
neolib::i_set< neolib::i_string > elements_t
uuid make_uuid(const std::string &aHyphenatedHexString)
Definition uuid.hpp:62