From bd084ed212677b4efff8438600cca25a2ee0c09d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20Ker=C3=A4nen?= Date: Sun, 10 Jan 2016 11:24:36 +0200 Subject: [PATCH] Cleanup|libdoomsday: Renamed res::System to Resources Continuing the de-System-ification of the classes. Subsystems should be named according to their domain: World, Resources, etc. Also, the primary class of a domain should not be in the domain's namespace, but in the top-level/global namespace. (FileSystem and WindowSystem have "system" in the name because those are the commonly used terms for the domains.) --- .../client/include/resource/resourcesystem.h | 6 +- doomsday/apps/client/src/dd_main.cpp | 2 +- doomsday/apps/client/src/def_main.cpp | 28 ++++----- doomsday/apps/client/src/render/r_main.cpp | 2 +- doomsday/apps/client/src/render/r_things.cpp | 2 +- doomsday/apps/client/src/render/rend_font.cpp | 4 +- .../apps/client/src/resource/api_material.cpp | 10 +-- .../apps/client/src/resource/api_resource.cpp | 4 +- .../apps/client/src/resource/material.cpp | 4 +- .../client/src/resource/materialanimator.cpp | 2 +- .../client/src/resource/materialarchive.cpp | 2 +- .../client/src/resource/resourcesystem.cpp | 2 +- doomsday/apps/client/src/resource/texture.cpp | 2 +- .../src/ui/infine/finaleinterpreter.cpp | 2 +- doomsday/apps/client/src/ui/ui_main.cpp | 2 +- .../apps/client/src/world/api_mapedit.cpp | 4 +- doomsday/apps/client/src/world/map.cpp | 2 +- .../resource/{system.h => resources.h} | 24 +++----- doomsday/apps/libdoomsday/src/game.cpp | 4 +- .../libdoomsday/src/resource/manifest.cpp | 6 +- .../resource/{system.cpp => resources.cpp} | 61 +++++++++---------- 21 files changed, 83 insertions(+), 92 deletions(-) rename doomsday/apps/libdoomsday/include/doomsday/resource/{system.h => resources.h} (87%) rename doomsday/apps/libdoomsday/src/resource/{system.cpp => resources.cpp} (76%) diff --git a/doomsday/apps/client/include/resource/resourcesystem.h b/doomsday/apps/client/include/resource/resourcesystem.h index 337a1306cd..f8655478d3 100644 --- a/doomsday/apps/client/include/resource/resourcesystem.h +++ b/doomsday/apps/client/include/resource/resourcesystem.h @@ -14,7 +14,7 @@ * 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 + * http://www.gnu.org/licenses */ #ifndef RESOURCESYSTEM_H @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include "resource/animgroup.h" #include "resource/colorpalette.h" @@ -84,7 +84,7 @@ * * @ingroup resource */ -class ResourceSystem : public res::System +class ResourceSystem : public Resources { public: /// An unknown resource scheme was referenced. @ingroup errors diff --git a/doomsday/apps/client/src/dd_main.cpp b/doomsday/apps/client/src/dd_main.cpp index b8d34dd7ed..d10baa47c4 100644 --- a/doomsday/apps/client/src/dd_main.cpp +++ b/doomsday/apps/client/src/dd_main.cpp @@ -587,7 +587,7 @@ ::audio::System &App_AudioSystem() ResourceSystem &App_ResourceSystem() { - return static_cast(res::System::get()); + return static_cast(Resources::get()); } ClientServerWorld &App_World() diff --git a/doomsday/apps/client/src/def_main.cpp b/doomsday/apps/client/src/def_main.cpp index 786517a8d7..344a00d11a 100644 --- a/doomsday/apps/client/src/def_main.cpp +++ b/doomsday/apps/client/src/def_main.cpp @@ -106,7 +106,7 @@ void Def_Init() // Make the definitions visible in the global namespace. App::app().scriptSystem().addNativeModule("Defs", defs.names); - + // Constants for definitions. DENG2_ADD_NUMBER_CONSTANT(defs.names, SN_SPAWN); DENG2_ADD_NUMBER_CONSTANT(defs.names, SN_SEE); @@ -822,7 +822,7 @@ static void redecorateMaterial(Material &material, Record const &def) } } } - catch(res::System::MissingResourceManifestError const &) + catch(Resources::MissingResourceManifestError const &) {} // Ignore this error } @@ -1015,7 +1015,7 @@ static void configureMaterial(Material &mat, Record const &definition) dstage0.variance = stage0.variance; } } - catch(res::System::MissingResourceManifestError const &) + catch(Resources::MissingResourceManifestError const &) {} // Ignore this error. } } @@ -1053,7 +1053,7 @@ static void configureMaterial(Material &mat, Record const &definition) maskTexture = &resSys().textureScheme("Masks") .findByResourceUri(*shineDef->stage.maskTexture); } - catch(res::System::MissingResourceManifestError const &) + catch(Resources::MissingResourceManifestError const &) {} // Ignore this error. } @@ -1073,7 +1073,7 @@ static void configureMaterial(Material &mat, Record const &definition) sstage0.variance = stage0.variance; } } - catch(res::System::MissingResourceManifestError const &) + catch(Resources::MissingResourceManifestError const &) {} // Ignore this error. } } @@ -1115,7 +1115,7 @@ static void interpretMaterialDef(Record const &definition) manifest->setFlags(MaterialManifest::Custom); } } - catch(res::System::MissingResourceManifestError const &er) + catch(Resources::MissingResourceManifestError const &er) { // Log but otherwise ignore this error. LOG_RES_WARNING("Ignoring unknown texture \"%s\" in Material \"%s\" (layer 0 stage 0): %s") @@ -1244,7 +1244,7 @@ void Def_Read() for(dint i = 0; i < runtimeDefs.mobjInfo.size(); ++i) { Record *dmo = &defs.things[i]; - + // Make sure duplicate defs overwrite the earliest. mobjinfo_t *mo = &runtimeDefs.mobjInfo[defs.getMobjNum(dmo->gets("id"))]; @@ -1264,18 +1264,18 @@ void Def_Read() auto const &states = dmo->geta("states"); auto const &sounds = dmo->geta("sounds"); - + for(dint k = 0; k < STATENAMES_COUNT; ++k) { mo->states[k] = Def_StateForMobj(states[k].asText()); } - + mo->seeSound = defs.getSoundNum(sounds[SDN_SEE].asText()); mo->attackSound = defs.getSoundNum(sounds[SDN_ATTACK].asText()); mo->painSound = defs.getSoundNum(sounds[SDN_PAIN].asText()); mo->deathSound = defs.getSoundNum(sounds[SDN_DEATH].asText()); mo->activeSound = defs.getSoundNum(sounds[SDN_ACTIVE].asText()); - + for(dint k = 0; k < NUM_MOBJ_MISC; ++k) { mo->misc[k] = dmo->geta("misc")[k].asInt(); @@ -1576,7 +1576,7 @@ static void initMaterialGroup(ded_group_t &def) } #endif } - catch(res::System::MissingResourceManifestError const &er) + catch(Resources::MissingResourceManifestError const &er) { // Log but otherwise ignore this error. LOG_RES_WARNING("Unknown material \"%s\" in group def %i: %s") @@ -1730,7 +1730,7 @@ void Def_CopyLineType(linetype_t *l, ded_linetype_t *def) { l->actMaterial = resSys().materialManifest(*def->actMaterial).id(); } - catch(res::System::MissingResourceManifestError const &) + catch(Resources::MissingResourceManifestError const &) {} // Ignore this error. } @@ -1740,7 +1740,7 @@ void Def_CopyLineType(linetype_t *l, ded_linetype_t *def) { l->deactMaterial = resSys().materialManifest(*def->deactMaterial).id(); } - catch(res::System::MissingResourceManifestError const &) + catch(Resources::MissingResourceManifestError const &) {} // Ignore this error. } @@ -1779,7 +1779,7 @@ void Def_CopyLineType(linetype_t *l, ded_linetype_t *def) { l->iparm[k] = resSys().materialManifest(de::Uri(def->iparmStr[k], RC_NULL)).id(); } - catch(res::System::MissingResourceManifestError const &) + catch(Resources::MissingResourceManifestError const &) {} // Ignore this error. } } diff --git a/doomsday/apps/client/src/render/r_main.cpp b/doomsday/apps/client/src/render/r_main.cpp index de09b118a8..c0465cf478 100644 --- a/doomsday/apps/client/src/render/r_main.cpp +++ b/doomsday/apps/client/src/render/r_main.cpp @@ -187,7 +187,7 @@ void Rend_Draw2DPlayerSprites() rendpspriteparams_t parm; setupPSpriteParams(parm, vs); Rend_DrawPSprite(parm); } - catch(res::System::MissingResourceManifestError const &er) + catch(Resources::MissingResourceManifestError const &er) { // Log but otherwise ignore this error. state_t const &state = *vs.psp->statePtr; diff --git a/doomsday/apps/client/src/render/r_things.cpp b/doomsday/apps/client/src/render/r_things.cpp index 0d2f8f43b1..5da01e00f8 100644 --- a/doomsday/apps/client/src/render/r_things.cpp +++ b/doomsday/apps/client/src/render/r_things.cpp @@ -556,7 +556,7 @@ void R_ProjectSprite(mobj_t &mob) LOG_GL_WARNING("Projecting flare source for sprite '%i' frame '%i': %s") << mob.sprite << mob.frame << er.asText(); } - catch(res::System::MissingResourceManifestError const &er) + catch(Resources::MissingResourceManifestError const &er) { // Log but otherwise ignore this error. LOG_GL_WARNING("Projecting flare source for sprite '%i' frame '%i': %s") diff --git a/doomsday/apps/client/src/render/rend_font.cpp b/doomsday/apps/client/src/render/rend_font.cpp index 8c45d5645b..21af37dcee 100644 --- a/doomsday/apps/client/src/render/rend_font.cpp +++ b/doomsday/apps/client/src/render/rend_font.cpp @@ -1038,7 +1038,7 @@ static void parseParamaterBlock(char** strPtr, drawtextstate_t* state, int* numB state->fontNum = App_ResourceSystem().fontManifest(de::Uri(buf, RC_NULL)).uniqueId(); continue; } - catch(res::System::MissingResourceManifestError const &) + catch(Resources::MissingResourceManifestError const &) {} } @@ -1556,7 +1556,7 @@ DENG_EXTERN_C fontid_t Fonts_ResolveUri(uri_s const *uri) { return App_ResourceSystem().fontManifest(*reinterpret_cast(uri)).uniqueId(); } - catch(res::System::MissingResourceManifestError const &) + catch(Resources::MissingResourceManifestError const &) {} return NOFONTID; } diff --git a/doomsday/apps/client/src/resource/api_material.cpp b/doomsday/apps/client/src/resource/api_material.cpp index 7ceb64c917..4cb166e5f2 100644 --- a/doomsday/apps/client/src/resource/api_material.cpp +++ b/doomsday/apps/client/src/resource/api_material.cpp @@ -1,7 +1,7 @@ /** @file api_material.cpp Material API. * - * @authors Copyright © 2014 Jaakko Keränen - * @authors Copyright © 2015 Daniel Swanson + * @authors Copyright © 2014 Jaakko Keränen + * @authors Copyright © 2015 Daniel Swanson * * @par License * GPL: http://www.gnu.org/licenses/gpl.html @@ -45,7 +45,7 @@ DENG_EXTERN_C Material *DD_MaterialForTextureUri(uri_s const *textureUri) // Log but otherwise ignore this error. LOG_RES_WARNING(er.asText() + ", ignoring."); } - catch(res::System::MissingResourceManifestError const &) + catch(Resources::MissingResourceManifestError const &) {} // Ignore this error. return nullptr; // Not found. @@ -65,7 +65,7 @@ DENG_EXTERN_C materialid_t Materials_ResolveUri(struct uri_s const *uri) { return App_ResourceSystem().materialManifest(*reinterpret_cast(uri)).id(); } - catch(res::System::MissingResourceManifestError const &) + catch(Resources::MissingResourceManifestError const &) {} // Ignore this error. return NOMATERIALID; } @@ -79,7 +79,7 @@ DENG_EXTERN_C materialid_t Materials_ResolveUriCString(char const *uriCString) { return App_ResourceSystem().materialManifest(de::Uri(uriCString, RC_NULL)).id(); } - catch(res::System::MissingResourceManifestError const &) + catch(Resources::MissingResourceManifestError const &) {} // Ignore this error. } return NOMATERIALID; diff --git a/doomsday/apps/client/src/resource/api_resource.cpp b/doomsday/apps/client/src/resource/api_resource.cpp index 6f4e07cc36..545aaada00 100644 --- a/doomsday/apps/client/src/resource/api_resource.cpp +++ b/doomsday/apps/client/src/resource/api_resource.cpp @@ -40,7 +40,7 @@ DENG_EXTERN_C int Textures_UniqueId2(uri_s const *_uri, dd_bool quiet) { return App_ResourceSystem().textureManifest(uri).uniqueId(); } - catch(res::System::MissingResourceManifestError const &) + catch(Resources::MissingResourceManifestError const &) { // Log but otherwise ignore this error. if(!quiet) @@ -82,7 +82,7 @@ DENG_EXTERN_C void R_AddAnimGroupFrame(int groupId, uri_s const *textureUri_, in LOG_DEBUG("Unknown anim group #%i, ignoring.") << groupId; } } - catch(res::System::MissingResourceManifestError const &er) + catch(Resources::MissingResourceManifestError const &er) { // Log but otherwise ignore this error. LOG_RES_WARNING(er.asText() + ". Failed adding texture \"%s\" to group #%i, ignoring.") diff --git a/doomsday/apps/client/src/resource/material.cpp b/doomsday/apps/client/src/resource/material.cpp index 6f40da7c5d..4b32376643 100644 --- a/doomsday/apps/client/src/resource/material.cpp +++ b/doomsday/apps/client/src/resource/material.cpp @@ -240,7 +240,7 @@ DENG2_PIMPL(Material) } catch(TextureManifest::MissingTextureError &) {} - catch(res::System::MissingResourceManifestError &) + catch(Resources::MissingResourceManifestError &) {} } } @@ -597,7 +597,7 @@ D_CMD(InspectMaterial) } return true; } - catch(res::System::MissingResourceManifestError const &er) + catch(Resources::MissingResourceManifestError const &er) { LOG_SCR_WARNING("%s") << er.asText(); } diff --git a/doomsday/apps/client/src/resource/materialanimator.cpp b/doomsday/apps/client/src/resource/materialanimator.cpp index 191d20848f..c6f43cb2b9 100644 --- a/doomsday/apps/client/src/resource/materialanimator.cpp +++ b/doomsday/apps/client/src/resource/materialanimator.cpp @@ -260,7 +260,7 @@ static Texture *findTextureForAnimationStage(MaterialTextureLayer::AnimationStag } catch(TextureManifest::MissingTextureError &) {} - catch(res::System::MissingResourceManifestError &) + catch(Resources::MissingResourceManifestError &) {} return nullptr; } diff --git a/doomsday/apps/client/src/resource/materialarchive.cpp b/doomsday/apps/client/src/resource/materialarchive.cpp index d8cf6b267e..1dfff2c202 100644 --- a/doomsday/apps/client/src/resource/materialarchive.cpp +++ b/doomsday/apps/client/src/resource/materialarchive.cpp @@ -99,7 +99,7 @@ static Material *findRecordMaterial(Records &records, SerialId id) { material = &App_ResourceSystem().material(Uri(records.stringRef(id), RC_NULL)); } - catch(res::System::MissingResourceManifestError const &) + catch(Resources::MissingResourceManifestError const &) {} // Ignore this error. records.setUserPointer(id, material); diff --git a/doomsday/apps/client/src/resource/resourcesystem.cpp b/doomsday/apps/client/src/resource/resourcesystem.cpp index f814c14cd8..8e5281af4f 100644 --- a/doomsday/apps/client/src/resource/resourcesystem.cpp +++ b/doomsday/apps/client/src/resource/resourcesystem.cpp @@ -3939,7 +3939,7 @@ static bool comparePathTreeNodePathsAscending(PathTreeNodeType const *a, PathTre */ static dint printMapsIndex2(Path const &like, de::Uri::ComposeAsTextFlags composeUriFlags) { - res::System::MapManifests::FoundNodes found; + Resources::MapManifests::FoundNodes found; App_ResourceSystem().allMapManifests().findAll(found, pathBeginsWithComparator, const_cast(&like)); if(found.isEmpty()) return 0; diff --git a/doomsday/apps/client/src/resource/texture.cpp b/doomsday/apps/client/src/resource/texture.cpp index 80e2426407..0980f524bc 100644 --- a/doomsday/apps/client/src/resource/texture.cpp +++ b/doomsday/apps/client/src/resource/texture.cpp @@ -401,7 +401,7 @@ D_CMD(InspectTexture) } return true; } - catch(res::System::MissingResourceManifestError const &er) + catch(Resources::MissingResourceManifestError const &er) { LOG_RES_WARNING("%s.") << er.asText(); } diff --git a/doomsday/apps/client/src/ui/infine/finaleinterpreter.cpp b/doomsday/apps/client/src/ui/infine/finaleinterpreter.cpp index f7cb5f5ce2..deae75b04a 100644 --- a/doomsday/apps/client/src/ui/infine/finaleinterpreter.cpp +++ b/doomsday/apps/client/src/ui/infine/finaleinterpreter.cpp @@ -1376,7 +1376,7 @@ DEFFC(BGMaterial) } catch(MaterialManifest::MissingMaterialError const &) {} // Ignore this error. - catch(res::System::MissingResourceManifestError const &) + catch(Resources::MissingResourceManifestError const &) {} // Ignore this error. changePageBackground(fi.page(FinaleInterpreter::Anims), material); diff --git a/doomsday/apps/client/src/ui/ui_main.cpp b/doomsday/apps/client/src/ui/ui_main.cpp index 1a035df840..04e7fe0b35 100644 --- a/doomsday/apps/client/src/ui/ui_main.cpp +++ b/doomsday/apps/client/src/ui/ui_main.cpp @@ -141,7 +141,7 @@ static void loadFontIfNeeded(char const *uri, fontid_t *fid) *fid = fontid_t(manifest.uniqueId()); } } - catch(res::System::MissingResourceManifestError const &) + catch(Resources::MissingResourceManifestError const &) {} } diff --git a/doomsday/apps/client/src/world/api_mapedit.cpp b/doomsday/apps/client/src/world/api_mapedit.cpp index 2c8be1a207..a4ec7e904e 100644 --- a/doomsday/apps/client/src/world/api_mapedit.cpp +++ b/doomsday/apps/client/src/world/api_mapedit.cpp @@ -133,7 +133,7 @@ static Material *findMaterialInDict(String const &materialUriStr) { material = &App_ResourceSystem().material(materialUri); } - catch(res::System::MissingResourceManifestError const &) + catch(Resources::MissingResourceManifestError const &) { // Try any scheme. try @@ -141,7 +141,7 @@ static Material *findMaterialInDict(String const &materialUriStr) materialUri.setScheme(""); material = &App_ResourceSystem().material(materialUri); } - catch(res::System::MissingResourceManifestError const &) + catch(Resources::MissingResourceManifestError const &) {} } diff --git a/doomsday/apps/client/src/world/map.cpp b/doomsday/apps/client/src/world/map.cpp index db2a2f7735..07ac377f4c 100644 --- a/doomsday/apps/client/src/world/map.cpp +++ b/doomsday/apps/client/src/world/map.cpp @@ -1411,7 +1411,7 @@ DENG2_PIMPL(Map) } catch(MaterialManifest::MissingMaterialError const &) {} // Ignore this error. - catch(res::System::MissingResourceManifestError const &) + catch(Resources::MissingResourceManifestError const &) {} // Ignore this error. } diff --git a/doomsday/apps/libdoomsday/include/doomsday/resource/system.h b/doomsday/apps/libdoomsday/include/doomsday/resource/resources.h similarity index 87% rename from doomsday/apps/libdoomsday/include/doomsday/resource/system.h rename to doomsday/apps/libdoomsday/include/doomsday/resource/resources.h index b3548bfb0e..6fcc916b6e 100644 --- a/doomsday/apps/libdoomsday/include/doomsday/resource/system.h +++ b/doomsday/apps/libdoomsday/include/doomsday/resource/resources.h @@ -1,4 +1,4 @@ -/** @file resource/system.h +/** @file resource/resources.h * * @authors Copyright © 2013-2015 Jaakko Keränen * @authors Copyright © 2013-2015 Daniel Swanson @@ -17,8 +17,8 @@ * http://www.gnu.org/licenses */ -#ifndef LIBDOOMSDAY_RESOURCE_SYSTEM_H -#define LIBDOOMSDAY_RESOURCE_SYSTEM_H +#ifndef LIBDOOMSDAY_RESOURCES_H +#define LIBDOOMSDAY_RESOURCES_H #include "resourceclass.h" #include "mapmanifest.h" @@ -27,14 +27,12 @@ #include #include -namespace res { - /** * Base class for the resource management subsystem. * * Singleton: there can only be one instance of the resource system at a time. */ -class LIBDOOMSDAY_PUBLIC System : public de::System +class LIBDOOMSDAY_PUBLIC Resources : public de::System { public: /// An unknown resource class identifier was specified. @ingroup errors @@ -43,12 +41,12 @@ class LIBDOOMSDAY_PUBLIC System : public de::System /// The referenced manifest was not found. @ingroup errors DENG2_ERROR(MissingResourceManifestError); - static System &get(); + static Resources &get(); - typedef de::PathTreeT MapManifests; + typedef de::PathTreeT MapManifests; public: - System(); + Resources(); // Systems observe the passage of time. void timeChanged(de::Clock const &) override; @@ -85,14 +83,14 @@ class LIBDOOMSDAY_PUBLIC System : public de::System /** * Locate the map resource manifest associated with the given, unique @a mapUri. */ - MapManifest &findMapManifest(de::Uri const &mapUri) const; + 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. */ - MapManifest *tryFindMapManifest(de::Uri const &mapUri) const; + res::MapManifest *tryFindMapManifest(de::Uri const &mapUri) const; /** * Returns the total number of map resource manifests in the system. @@ -108,8 +106,6 @@ class LIBDOOMSDAY_PUBLIC System : public de::System DENG2_PRIVATE(d) }; -} // namespace res - /** * Convenient method of returning a resource class from the application's global * resource system. @@ -121,5 +117,5 @@ LIBDOOMSDAY_PUBLIC ResourceClass &App_ResourceClass(de::String className); /// @overload LIBDOOMSDAY_PUBLIC ResourceClass &App_ResourceClass(resourceclassid_t classId); -#endif // LIBDOOMSDAY_RESOURCE_SYSTEM_H +#endif // LIBDOOMSDAY_RESOURCES_H diff --git a/doomsday/apps/libdoomsday/src/game.cpp b/doomsday/apps/libdoomsday/src/game.cpp index e2d00e67a1..bb36925dc2 100644 --- a/doomsday/apps/libdoomsday/src/game.cpp +++ b/doomsday/apps/libdoomsday/src/game.cpp @@ -22,7 +22,7 @@ #include "doomsday/console/cmd.h" #include "doomsday/filesys/file.h" #include "doomsday/resource/manifest.h" -#include "doomsday/resource/system.h" +#include "doomsday/resource/resources.h" #include "doomsday/doomsdayapp.h" #include @@ -186,7 +186,7 @@ String Game::legacySavegameNameExp() const String Game::legacySavegamePath() const { - NativePath nativeSavePath = res::System::get().nativeSavePath(); + NativePath nativeSavePath = Resources::get().nativeSavePath(); if(nativeSavePath.isEmpty()) return ""; if(isNull()) return ""; diff --git a/doomsday/apps/libdoomsday/src/resource/manifest.cpp b/doomsday/apps/libdoomsday/src/resource/manifest.cpp index 46f525d4b0..5e3f744fde 100644 --- a/doomsday/apps/libdoomsday/src/resource/manifest.cpp +++ b/doomsday/apps/libdoomsday/src/resource/manifest.cpp @@ -19,7 +19,7 @@ */ #include "doomsday/resource/manifest.h" -#include "doomsday/resource/system.h" +#include "doomsday/resource/resources.h" #include "doomsday/filesys/fs_main.h" #include "doomsday/filesys/lumpindex.h" #include "doomsday/filesys/wad.h" @@ -259,7 +259,7 @@ void ResourceManifest::locateFile() for(QStringList::const_iterator i = d->names.constBegin(); i != d->names.constEnd(); ++i, ++nameIndex) { StringList candidates; - + // Attempt to resolve a path to the named resource using FS1. try { @@ -282,7 +282,7 @@ void ResourceManifest::locateFile() } return LoopContinue; }); - + for(String foundPath : candidates) { // Perform identity validation. diff --git a/doomsday/apps/libdoomsday/src/resource/system.cpp b/doomsday/apps/libdoomsday/src/resource/resources.cpp similarity index 76% rename from doomsday/apps/libdoomsday/src/resource/system.cpp rename to doomsday/apps/libdoomsday/src/resource/resources.cpp index c2d86ce12b..21ec89b6b6 100644 --- a/doomsday/apps/libdoomsday/src/resource/system.cpp +++ b/doomsday/apps/libdoomsday/src/resource/resources.cpp @@ -1,4 +1,4 @@ -/** @file resource/system.cpp +/** @file resource/resources.cpp * * @authors Copyright (c) 2015 Jaakko Keränen * @@ -16,32 +16,28 @@ * http://www.gnu.org/licenses */ -#include "doomsday/resource/system.h" +#include "doomsday/resource/resources.h" #include "doomsday/filesys/fs_main.h" #include using namespace de; -namespace res { +static Resources *theResources = nullptr; -static res::System *theResSystem = nullptr; - -DENG2_PIMPL(System) +DENG2_PIMPL(Resources) { typedef QList ResourceClasses; ResourceClasses resClasses; NullResourceClass nullResourceClass; - NativePath nativeSavePath; - MapManifests mapManifests; Instance(Public *i) : Base(i) , nativeSavePath(App::app().nativeHomePath() / "savegames") // default { - theResSystem = thisPublic; + theResources = thisPublic; resClasses.append(new ResourceClass("RC_PACKAGE", "Packages")); resClasses.append(new ResourceClass("RC_DEFINITION", "Defs")); @@ -65,25 +61,25 @@ DENG2_PIMPL(System) self.clearMapManifests(); qDeleteAll(resClasses); - theResSystem = nullptr; + theResources = nullptr; } }; -System::System() : d(new Instance(this)) +Resources::Resources() : d(new Instance(this)) {} -void System::timeChanged(Clock const &) +void Resources::timeChanged(Clock const &) { // Nothing to do. } -res::System &System::get() +Resources &Resources::get() { - DENG2_ASSERT(theResSystem); - return *theResSystem; + DENG2_ASSERT(theResources); + return *theResources; } -ResourceClass &System::resClass(String name) +ResourceClass &Resources::resClass(String name) { if(!name.isEmpty()) { @@ -96,7 +92,7 @@ ResourceClass &System::resClass(String name) return d->nullResourceClass; // Not found. } -ResourceClass &System::resClass(resourceclassid_t id) +ResourceClass &Resources::resClass(resourceclassid_t id) { if(id == RC_NULL) return d->nullResourceClass; if(VALID_RESOURCECLASSID(id)) @@ -104,10 +100,10 @@ ResourceClass &System::resClass(resourceclassid_t id) return *d->resClasses.at(uint(id)); } /// @throw UnknownResourceClass Attempted with an unknown id. - throw UnknownResourceClassError("ResourceSystem::toClass", QString("Invalid id '%1'").arg(int(id))); + throw UnknownResourceClassError("ResourceResources::toClass", QString("Invalid id '%1'").arg(int(id))); } -void System::updateOverrideIWADPathFromConfig() +void Resources::updateOverrideIWADPathFromConfig() { String path = App::config().gets("resource.iwadFolder", ""); if(!path.isEmpty()) @@ -121,36 +117,37 @@ void System::updateOverrideIWADPathFromConfig() } } -NativePath System::nativeSavePath() const +NativePath Resources::nativeSavePath() const { return d->nativeSavePath; } -MapManifest &System::findMapManifest(de::Uri const &mapUri) const +res::MapManifest &Resources::findMapManifest(de::Uri const &mapUri) const { // Only one resource scheme is known for maps. if(!mapUri.scheme().compareWithoutCase("Maps")) { - if(MapManifest *found = d->mapManifests.tryFind(mapUri.path(), PathTree::MatchFull | PathTree::NoBranch)) + if(res::MapManifest *found = d->mapManifests.tryFind( + mapUri.path(), PathTree::MatchFull | PathTree::NoBranch)) return *found; } /// @throw MissingResourceManifestError An unknown map URI was specified. - throw MissingResourceManifestError("res::System::findMapManifest", "Failed to locate a manifest for \"" + mapUri.asText() + "\""); + throw MissingResourceManifestError("Resources::findMapManifest", "Failed to locate a manifest for \"" + mapUri.asText() + "\""); } -MapManifest *System::tryFindMapManifest(de::Uri const &mapUri) const +res::MapManifest *Resources::tryFindMapManifest(de::Uri const &mapUri) const { // Only one resource scheme is known for maps. if(mapUri.scheme().compareWithoutCase("Maps")) return nullptr; return d->mapManifests.tryFind(mapUri.path(), PathTree::MatchFull | PathTree::NoBranch); } -dint System::mapManifestCount() const +dint Resources::mapManifestCount() const { return d->mapManifests.count(); } -void System::initMapManifests() +void Resources::initMapManifests() { clearMapManifests(); @@ -168,7 +165,7 @@ void System::initMapManifests() File1 *sourceFile = recognizer->sourceFile(); String const mapId = recognizer->id(); - MapManifest &manifest = d->mapManifests.insert(mapId); + res::MapManifest &manifest = d->mapManifests.insert(mapId); manifest.set("id", mapId); manifest.setSourceFile(sourceFile) .setRecognizer(recognizer.release()); @@ -176,25 +173,23 @@ void System::initMapManifests() } } -void System::clearMapManifests() +void Resources::clearMapManifests() { d->mapManifests.clear(); } -System::MapManifests const &System::allMapManifests() const +Resources::MapManifests const &Resources::allMapManifests() const { return d->mapManifests; } -} // namespace res - ResourceClass &App_ResourceClass(String className) { - return res::System::get().resClass(className); + return Resources::get().resClass(className); } ResourceClass &App_ResourceClass(resourceclassid_t classId) { - return res::System::get().resClass(classId); + return Resources::get().resClass(classId); }