Lumiera  0.pre.03
»edityourfreedom«
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 PROC_INTERFACE_ASSETMANAGER_H
44 #define PROC_INTERFACE_ASSETMANAGER_H
45 
46 
47 #include "proc/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 proc {
62 namespace asset {
63 
64  class DB;
65 
66 
70  class AssetManager
72  {
74 
75 
76  public:
78 
80  static ID<Asset> getID (const Asset::Ident&);
81 
83  template<class KIND>
84  static lib::P<KIND> wrap (const KIND& asset);
85 
87  template<class KIND>
88  lib::P<KIND> getAsset (const ID<KIND>& id);
89 
90 
92  bool known (IDA id) ;
93 
95  bool known (IDA id, const Category& cat) ;
96 
99  void remove (IDA id) ;
100 
107  void clear() ;
108 
110  list<PcAsset> listContent() const;
111 
112 
113 
114  protected:
118  template<class KIND>
119  static ID<KIND>
120  reg (KIND* obj, const Asset::Ident& idi);
121 
123  static void destroy (Asset* aa) { delete aa; }
124 
125  friend Asset::Asset (Asset::Ident const& idi);
126 
127  AssetManager();
128 
130 
131  };
132 
133 
134  LUMIERA_ERROR_DECLARE (UNKNOWN_ASSET_ID);
135  LUMIERA_ERROR_DECLARE (WRONG_ASSET_KIND);
136 
137 }} // namespace proc::asset
138 
139 
140 
141 namespace proc_interface
142  {
144 }
145 
146 #endif
static ID< Asset > getID(const Asset::Ident &)
provide the unique ID for given Asset::Ident tuple
Facade for the Asset subsystem.
lib::P< KIND > getAsset(const ID< KIND > &id)
find and return corresponding object
The asset subsystem of the Proc-Layer.
Definition: id-scheme.hpp:64
Any copy and copy construction prohibited.
Definition: nocopy.hpp:46
LUMIERA_ERROR_DECLARE(PART_OF_COMPOUND)
Access point to singletons and other kinds of dependencies designated by type.
Definition: depend.hpp:289
Superinterface describing especially bookkeeping properties.
Definition: asset.hpp:148
static lib::P< KIND > wrap(const KIND &asset)
retrieve the registered smart-ptr for any asset
a POD comprised of all the information sufficiently identifying any given Asset.
Definition: asset.hpp:158
static lib::Depend< AssetManager > instance
get at the system-wide asset manager instance.
Proc-Layer Interface: Assets.
static ID< KIND > reg(KIND *obj, const Asset::Ident &idi)
registers an asset object in the internal DB, providing its unique key.
Tree like classification of Assets.
Definition: category.hpp:75
Singleton services and Dependency Injection.
Lumiera error handling (C++ interface).
static void destroy(Asset *aa)
deleter function used by the Asset smart pointers to delete Asset objects
void clear()
deregister and evict all known Assets.
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:76
Asset(const Ident &idi)
Asset is a Interface class; usually, objects of concrete subclasses are created via specialised Facto...
Definition: asset.cpp:67
Proc-Layer implementation namespace root.
Definition: id-scheme.hpp:63
Implementation of the registry holding all Asset instances known to the Asset Manager subsystem...
Definition: db.hpp:98
list< PcAsset > listContent() const
extract a sorted list of all registered Assets