/
resources.h
121 lines (98 loc) · 3.57 KB
/
resources.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/** @file resource/resources.h
*
* @authors Copyright © 2013-2015 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2013-2015 Daniel Swanson <danij@dengine.net>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details. You should have received a copy of the GNU
* General Public License along with this program; if not, see:
* http://www.gnu.org/licenses</small>
*/
#ifndef LIBDOOMSDAY_RESOURCES_H
#define LIBDOOMSDAY_RESOURCES_H
#include "resourceclass.h"
#include "mapmanifest.h"
#include <de/NativePath>
#include <de/PathTree>
#include <de/System>
#include <de/Info>
/**
* Base class for the resource management subsystem.
*
* Singleton: there can only be one instance of the resource system at a time.
*/
class LIBDOOMSDAY_PUBLIC Resources : public de::System
{
public:
/// An unknown resource class identifier was specified. @ingroup errors
DENG2_ERROR(UnknownResourceClassError);
/// The referenced manifest was not found. @ingroup errors
DENG2_ERROR(MissingResourceManifestError);
static Resources &get();
typedef de::PathTreeT<res::MapManifest> MapManifests;
public:
Resources();
// Systems observe the passage of time.
void timeChanged(de::Clock const &) override;
/**
* Lookup a ResourceClass by symbolic @a name.
*/
ResourceClass &resClass(de::String name);
/**
* Lookup a ResourceClass by @a id.
* @todo Refactor away.
*/
ResourceClass &resClass(resourceclassid_t id);
/**
* Gets the path from "Config.resource.iwadFolder" and makes it the sole override
* path for the Packages scheme.
*/
void updateOverrideIWADPathFromConfig();
/**
* Returns the native path of the root of the saved session repository.
*/
de::NativePath nativeSavePath() const;
public: // Resource manifests: ------------------------------------------------------
/**
* Note that the existence of a manifest does not automatically mean the associated
* resource data is actually loadable.
*/
/**
* Locate the map resource manifest associated with the given, unique @a mapUri.
*/
res::MapManifest &findMapManifest(de::Uri const &mapUri) const;
/**
* Lookup the map resource manifest associated with the given, unique @a mapUri.
*
* @return MapManifest associated with @a mapUri if found; otherwise @c nullptr.
*/
res::MapManifest *tryFindMapManifest(de::Uri const &mapUri) const;
/**
* Returns the total number of map resource manifests in the system.
*/
de::dint mapManifestCount() const;
/// @todo make private.
void initMapManifests();
void clearMapManifests();
MapManifests const &allMapManifests() const;
private:
DENG2_PRIVATE(d)
};
/**
* Convenient method of returning a resource class from the application's global
* resource system.
*
* @param className Resource class name.
*/
LIBDOOMSDAY_PUBLIC ResourceClass &App_ResourceClass(de::String className);
/// @overload
LIBDOOMSDAY_PUBLIC ResourceClass &App_ResourceClass(resourceclassid_t classId);
#endif // LIBDOOMSDAY_RESOURCES_H