Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
asset.hpp
Go to the documentation of this file.
1/*
2 ASSET.hpp - Superinterface: bookkeeping view of "things" present in the session
3
4 Copyright (C)
5 2008, Hermann Vosseler <Ichthyostega@web.de>
6
7  **Lumiera** is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License as published by the
9  Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version. See the file COPYING for further details.
11
12*/
13
46#ifndef STEAM_INTERFACE_ASSET_H
47#define STEAM_INTERFACE_ASSET_H
48
49
50#include "lib/error.hpp"
51#include "lib/nocopy.hpp"
52#include "include/logging.h"
54#include "lib/hash-value.h"
55#include "lib/p.hpp"
56
57#include <type_traits>
58#include <compare>
59#include <string>
60#include <vector>
61#include <set>
62
63
64using std::string;
65using std::vector;
66using std::set;
67
68
69namespace steam {
70namespace asset {
71
72 namespace error = lumiera::error;
73
74 using std::size_t;
75 using std::shared_ptr;
76 using std::static_pointer_cast;
77
78 using lib::HashVal;
79
80
81
96 template<class KIND>
97 class ID
98 {
99 HashVal hash_;
100 public:
101 ID (HashVal id) : hash_(id) {}
102 ID (const KIND& asset) : hash_(asset.getID()) {}
103 operator HashVal() const { return hash_; }
104
105 static ID INVALID;
106 };
107
108 class DB;
109 class Asset;
110 class AssetManager;
111 typedef const ID<Asset>& IDA;
114
115
116
117
118
137 class Asset
139 {
140 public:
141
146 struct Ident
147 {
151 string name;
152
157
163 const string org;
164
172
173
174 Ident (string const& n
175 ,Category const& cat
176 ,string const& o = "lumi"
177 ,const uint ver=1);
178
179
183 auto operator<=>(Ident const& oi) const { return std::tie ( category, org, name)
184 <=> std::tie (oi.category,oi.org,oi.name); }
185 bool operator== (Ident const& oi) const { return 0 == *this <=> oi; }
186
187
188 operator string () const;
189
190 bool isValid() const;
191 };
192
193
194 /* ===== Asset ID and Datafields ===== */
195
196 public:
197 const Ident ident;
198
199 virtual const ID<Asset>& getID() const { return id; }
200
201
202 bool operator== (Asset const& oa) const { return ident == oa.ident; }
203 auto operator<=>(Asset const& oa) const { return ident <=> oa.ident; }
204
205 virtual operator string () const;
206
207
208
209 protected:
210 const ID<Asset> id;
211
215 set<string> groups;
216
218 const string shortDesc;
219
222 const string longDesc;
223
224 vector<PAsset> parents;
225 vector<PAsset> dependants;
226
228
229
230
231 protected:
236 Asset (const Ident& idi);
237 virtual ~Asset() = 0;
238
250 virtual void unlink ();
251
254 virtual void unlink (IDA target);
255
258 void defineDependency (PAsset parent);
259 void defineDependency (Asset& parent);
260
261 friend class AssetManager;
262 friend class DB;
263
264 private:
265 void unregister (PAsset& other);
266
267
268
269
270 public:
274 const vector<PAsset>& getParents () const { return parents; }
275
280 const vector<PAsset>& getDependant () const { return dependants; }
281
285 bool isActive () const;
286
293 bool enable (bool on=true);
294
295
296 };
297
298
299
300
302 template<class A>
303 inline const PcAsset
304 pAsset (shared_ptr<A> const& subPtr)
305 {
306 return static_pointer_cast<const Asset,A> (subPtr);
307 }
308
309
311 template <class X>
312 struct is_pAsset : std::false_type { };
313
314 template <class A>
315 struct is_pAsset<shared_ptr<A>>
316 : std::is_base_of<Asset, A> { };
317
318
320 template<class KIND>
322
323
324}} // namespace steam::asset
325
326
327
328namespace proc_interface {
329
332 using steam::asset::ID;
333 using steam::asset::IDA;
335}
336
337#endif
Definition of Asset categorisation.
Customised refcounting smart pointer template, built upon std::shared_ptr, but forwarding type relati...
Definition p.hpp:77
Facade for the Asset subsystem.
Superinterface describing especially bookkeeping properties.
Definition asset.hpp:139
const Ident ident
Asset identification tuple.
Definition asset.hpp:197
void defineDependency(PAsset parent)
establish a connection between this and the given parent asset, denoting we are in some way dependent...
Definition asset.cpp:183
bool operator==(Asset const &oa) const
Definition asset.hpp:202
const vector< PAsset > & getParents() const
List of entities this asset depends on or requires to be functional.
Definition asset.hpp:274
vector< PAsset > parents
Definition asset.hpp:224
void unregister(PAsset &other)
Definition asset.cpp:150
bool isActive() const
weather this asset is switched on and consequently included in the fixture and participates in render...
Definition asset.cpp:118
virtual const ID< Asset > & getID() const
Definition asset.hpp:199
bool enable(bool on=true)
change the enabled status of this asset.
Definition asset.cpp:133
const string longDesc
user visible qualification of the thing, unit or concept represented by this asset.
Definition asset.hpp:222
auto operator<=>(Asset const &oa) const
Definition asset.hpp:203
vector< PAsset > dependants
Definition asset.hpp:225
const vector< PAsset > & getDependant() const
All the other assets requiring this asset to be functional.
Definition asset.hpp:280
const ID< Asset > id
Asset primary key.
Definition asset.hpp:210
virtual ~Asset()=0
Definition asset.cpp:65
virtual void unlink()
release all links to other Asset objects held internally.
Definition asset.cpp:164
set< string > groups
additional classification, selections or departments this asset belongs to.
Definition asset.hpp:215
const string shortDesc
user visible Name-ID.
Definition asset.hpp:218
Tree like classification of Assets.
Definition category.hpp:68
Implementation of the registry holding all Asset instances known to the Asset Manager subsystem.
Definition db.hpp:90
thin wrapper around a size_t hash ID used as primary key for all Asset objects.
Definition asset.hpp:98
static ID INVALID
marker constant denoting a NIL asset
Definition asset.hpp:105
ID(const KIND &asset)
Definition asset.hpp:102
ID(HashVal id)
Definition asset.hpp:101
HashVal hash_
Definition asset.hpp:99
Any copy and copy construction prohibited.
Definition nocopy.hpp:38
Lumiera error handling (C++ interface).
Hash value types and utilities.
unsigned int uint
Definition integral.hpp:29
This header is for including and configuring NoBug.
size_t HashVal
a STL compatible hash value
Definition hash-value.h:52
The asset subsystem of the Steam-Layer.
lib::P< const Asset > PcAsset
Definition asset.hpp:113
lib::P< Asset > PAsset
Definition asset.hpp:112
const PcAsset pAsset(shared_ptr< A > const &subPtr)
promote subtype-ptr to PAsset, e.g.
Definition asset.hpp:304
const ID< Asset > & IDA
Definition asset.hpp:111
Steam-Layer implementation namespace root.
Mix-Ins to allow or prohibit various degrees of copying and cloning.
Customised refcounting smart pointer.
a POD comprised of all the information sufficiently identifying any given Asset.
Definition asset.hpp:147
auto operator<=>(Ident const &oi) const
ordering of Assets is based on the ordering of Ident tuples, descending from Category to origin and f...
Definition asset.hpp:183
asset::Category category
primary tree like classification of the asset.
Definition asset.hpp:156
string name
element ID, comprehensible but sanitised.
Definition asset.hpp:151
bool operator==(Ident const &oi) const
Definition asset.hpp:185
const uint version
version number of the thing or concept represented by this asset.
Definition asset.hpp:171
const string org
origin or authorship id.
Definition asset.hpp:163
type trait for detecting a shared-ptr-to-asset
Definition asset.hpp:312