neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
i_element_library.hpp
Go to the documentation of this file.
1// i_element_library.hpp
2/*
3 neoGFX Design Studio
4 Copyright(C) 2020 Leigh Johnston
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>
25#include <neolib/core/i_set.hpp>
32
34{
35 class i_project;
36
38 {
39 // types
40 public:
44 // exceptions
45 public:
46 struct unknown_element_type : std::logic_error { unknown_element_type() : std::logic_error{ "neogfx::DesignStudio::i_element_library::unknown_element_type" } {} };
47 //initialisation
48 public:
49 virtual neolib::i_application& application() const = 0;
50 virtual void ide_ready(i_ide& aIde) = 0;
51 // meta
52 public:
53 virtual const elements_t& elements() const = 0;
54 virtual const elements_ordered_t& elements_ordered() const = 0;
55 // factory
56 public:
57 virtual void create_element(i_project& aProject, const neolib::i_string& aElementType, const neolib::i_string& aElementId, neolib::i_ref_ptr<i_element>& aResult) = 0;
58 virtual void create_element(i_element& aParent, const neolib::i_string& aElementType, const neolib::i_string& aElementId, neolib::i_ref_ptr<i_element>& aResult) = 0;
59 virtual DesignStudio::element_group element_group(const neolib::i_string& aElementType) const = 0;
60 virtual i_texture const& element_icon(const neolib::i_string& aElementType) const = 0;
61 // helpers
62 public:
63 neolib::ref_ptr<i_element> create_element(i_project& aProject, std::string const& aElementType, std::string const& aElementId)
64 {
66 create_element(aProject, string{ aElementType }, string{ aElementId }, result);
67 return result;
68 }
69 neolib::ref_ptr<i_element> create_element(i_element& aParent, std::string const& aElementType, std::string const& aElementId)
70 {
72 create_element(aParent, string{ aElementType }, string{ aElementId }, result);
73 return result;
74 }
75 // interface
76 public:
77 static const neolib::uuid& iid() { static const neolib::uuid sId = neolib::make_uuid("0FAFD88D-DE88-4473-A70F-DCBC53BA8CB9"); return sId; }
78 };
79}
virtual i_texture const & element_icon(const neolib::i_string &aElementType) const =0
virtual void ide_ready(i_ide &aIde)=0
virtual DesignStudio::element_group element_group(const neolib::i_string &aElementType) const =0
virtual void create_element(i_project &aProject, const neolib::i_string &aElementType, const neolib::i_string &aElementId, neolib::i_ref_ptr< i_element > &aResult)=0
virtual const elements_t & elements() const =0
neolib::i_set< neolib::i_string > elements_t
neolib::ref_ptr< i_element > create_element(i_project &aProject, std::string const &aElementType, std::string const &aElementId)
virtual neolib::i_application & application() const =0
virtual const elements_ordered_t & elements_ordered() const =0
neolib::ref_ptr< i_element > create_element(i_element &aParent, std::string const &aElementType, std::string const &aElementId)
virtual void create_element(i_element &aParent, const neolib::i_string &aElementType, const neolib::i_string &aElementId, neolib::i_ref_ptr< i_element > &aResult)=0
neolib::i_vector< neolib::i_string > elements_ordered_t
uuid make_uuid(const std::string &aHyphenatedHexString)
Definition uuid.hpp:62