hx3d  1
2D/3D Simple Game Framework
assets.hpp
1 /*
2  Asset management.
3  Copyright (C) 2015 Denis BOURGE
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
18  USA
19 */
20 
21 #ifndef HX3D_UTILS_ASSETS
22 #define HX3D_UTILS_ASSETS
23 
24 #include "hx3d/utils/ptr.hpp"
25 #include "hx3d/utils/resource.hpp"
26 #include "hx3d/utils/log.hpp"
27 
28 #include <typeindex>
29 #include <map>
30 
31 namespace hx3d {
32 
36 class AssetManager {
37 
38 public:
39 
46  template <class Asset, class... Args>
47  void create(std::string name, Args... args);
48 
55  template <class Asset>
56  void add(std::string name, Ptr<Asset> asset);
57 
65  template <class Asset>
66  Ptr<Asset> get(std::string name);
67 
68 private:
70  std::map<std::type_index, std::map<std::string, Ptr<Resource>>> _assets;
71 };
72 
73 #include "hx3d/utils/_inline/assets.inl.hpp"
74 
75 } /* hx3d */
76 
77 #endif
void add(std::string name, Ptr< Asset > asset)
Add an asset.
Definition: assets.hpp:33
hx3d framework namespace
Definition: audio.hpp:26
void create(std::string name, Args...args)
Create an asset with arguments.
Definition: assets.hpp:23
Asset management.
Definition: assets.hpp:36
std::shared_ptr< T > Ptr
Quick-typing shared ptr.
Definition: ptr.hpp:34