Lumiera  0.pre.03
»edit your freedom«
assetmanager.hpp
Go to the documentation of this file.
1 /*
2  ASSETMANAGER.hpp - Facade for the Asset subsystem
3 
4  Copyright (C) Lumiera.org
5  2008, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 */
22 
43 #ifndef STEAM_INTERFACE_ASSETMANAGER_H
44 #define STEAM_INTERFACE_ASSETMANAGER_H
45 
46 
47 #include "steam/asset.hpp"
48 #include "lib/error.hpp"
49 #include "lib/depend.hpp"
50 
51 
52 #include <cstddef>
53 #include <string>
54 #include <list>
55 #include <boost/utility.hpp>
56 
57 using std::string;
58 using std::list;
59 
60 
61 namespace lumiera {
62 namespace error {
63  LUMIERA_ERROR_DECLARE (UNKNOWN_ASSET_ID);
64  LUMIERA_ERROR_DECLARE (WRONG_ASSET_KIND);
65 }}
66 
67 
68 namespace steam {
69 namespace asset {
70 
71  class DB;
72 
73 
79  {
80  asset::DB & registry;
81 
82 
83  public:
85 
87  static ID<Asset> getID (const Asset::Ident&);
88 
90  template<class KIND>
91  static lib::P<KIND> wrap (const KIND& asset);
92 
94  template<class KIND>
95  lib::P<KIND> getAsset (const ID<KIND>& id);
96 
97 
99  bool known (IDA id) ;
100 
102  bool known (IDA id, const Category& cat) ;
103 
106  void remove (IDA id) ;
107 
114  void clear() ;
115 
117  list<PcAsset> listContent() const;
118 
119 
120 
121  protected:
125  template<class KIND>
126  static ID<KIND>
127  reg (KIND* obj, const Asset::Ident& idi);
128 
130  static void destroy (Asset* aa) { delete aa; }
131 
132  friend Asset::Asset (Asset::Ident const& idi);
133 
134  AssetManager();
135 
136  friend class lib::DependencyFactory<AssetManager>;
137 
138  };
139 
140 
141 }} // namespace steam::asset
142 
143 
144 
145 namespace proc_interface
146  {
148 }
149 
150 #endif
Tree like classification of Assets.
Definition: category.hpp:75
Any copy and copy construction prohibited.
Definition: nocopy.hpp:46
Facade for the Asset subsystem.
#define LUMIERA_ERROR_DECLARE(err)
Forward declare an error constant.
Definition: error.h:71
Steam-Layer implementation namespace root.
Access point to singletons and other kinds of dependencies designated by type.
Definition: depend.hpp:289
static lib::Depend< AssetManager > instance
get at the system-wide asset manager instance.
Implementation of the registry holding all Asset instances known to the Asset Manager subsystem...
Definition: db.hpp:98
a POD comprised of all the information sufficiently identifying any given Asset.
Definition: asset.hpp:158
Superinterface describing especially bookkeeping properties.
Definition: asset.hpp:148
Steam-Layer Interface: Assets.
Singleton services and Dependency Injection.
Lumiera error handling (C++ interface).
Lumiera public interface.
Definition: advice.cpp:113
Helper to abstract creation and lifecycle of a dependency.
Definition: depend.hpp:134
Customised refcounting smart pointer template, built upon std::shared_ptr, but forwarding type relati...
Definition: trait.hpp:80
static void destroy(Asset *aa)
deleter function used by the Asset smart pointers to delete Asset objects
The asset subsystem of the Steam-Layer.
Definition: wrapperptr.hpp:44