neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
i_resource_manager.hpp
Go to the documentation of this file.
1// i_resource_manager.hpp
2/*
3 neogfx C++ App/Game Engine
4 Copyright (c) 2015, 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>
24
25namespace neogfx
26{
27 struct embedded_resource_not_found : std::runtime_error { embedded_resource_not_found(std::string const& aResource) : std::runtime_error{ "neogfx::embedded_resource_not_found: " + aResource } {} };
28
30 {
31 public:
32 virtual void merge(i_resource_manager& aResourceManager) = 0;
33 public:
34 virtual void add_resource(i_string const& aUri, const void* aResourceData, std::size_t aResourceSize) = 0;
35 virtual void add_module_resource(i_string const& aUri, const void* aResourceData, std::size_t aResourceSize) = 0;
36 virtual void load_resource(i_string const& aUri, i_ref_ptr<i_resource>& aResult) = 0;
37 public:
38 virtual void cleanup() = 0;
39 virtual void clean() = 0;
40 public:
43 public:
44 void add_resource(std::string const& aUri, const void* aResourceData, std::size_t aResourceSize)
45 {
46 add_resource(string{ aUri }, aResourceData, aResourceSize);
47 }
48 void add_module_resource(std::string const& aUri, const void* aResourceData, std::size_t aResourceSize)
49 {
50 add_module_resource(string{ aUri }, aResourceData, aResourceSize);
51 }
52 ref_ptr<i_resource> load_resource(std::string const& aUri)
53 {
55 load_resource(string{ aUri }, result);
56 return result;
57 }
58 public:
59 static uuid const& iid() { static uuid const sIid{ 0xe5f11ade, 0x7596, 0x4179, 0x8d77, { 0x1e, 0xb9, 0x9d, 0x6f, 0x3b, 0x96 } }; return sIid; }
60 };
61}
virtual void load_resource(i_string const &aUri, i_ref_ptr< i_resource > &aResult)=0
ref_ptr< i_resource > load_resource(std::string const &aUri)
virtual neolib::i_map< i_string, neolib::i_variant< i_ref_ptr< i_resource >, i_weak_ref_ptr< i_resource > > > const & resource_archives()=0
virtual neolib::i_map< i_string, neolib::i_variant< i_ref_ptr< i_resource >, i_weak_ref_ptr< i_resource > > > const & resources()=0
void add_resource(std::string const &aUri, const void *aResourceData, std::size_t aResourceSize)
virtual void cleanup()=0
virtual void clean()=0
virtual void add_module_resource(i_string const &aUri, const void *aResourceData, std::size_t aResourceSize)=0
void add_module_resource(std::string const &aUri, const void *aResourceData, std::size_t aResourceSize)
virtual void add_resource(i_string const &aUri, const void *aResourceData, std::size_t aResourceSize)=0
virtual void merge(i_resource_manager &aResourceManager)=0
embedded_resource_not_found(std::string const &aResource)