.. index:: pair: class; EE::Graphics::ResourceScope .. _doxid-class_e_e_1_1_graphics_1_1_resource_scope: class EE::Graphics::ResourceScope ================================= .. toctree:: :hidden: Overview ~~~~~~~~ :ref:`Graphics ` resource lookup boundary with local ownership and explicit catalog visibility. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include class ResourceScope { public: // construction :target:`~ResourceScope`(); // methods static :ref:`ResourceScopePtr` :target:`New`(); :ref:`FontService`& :target:`getFontService`(); const :ref:`FontService`& :target:`getFontService`() const; :ref:`TexturePtr` :target:`findTexture`(const :ref:`ResourceKey`& key) const; :ref:`TexturePtr` :target:`findTexture`(const std::string& key) const; :ref:`DrawablePtr` :target:`findDrawableSource`(const :ref:`ResourceKey`& key) const; :ref:`DrawablePtr` :target:`findDrawableSource`(const std::string& key) const; :ref:`DrawablePtr` :target:`findDrawable`(const std::string& name, bool firstSearchSprite = false) const; :ref:`DrawablePtr` :target:`findDrawable`(:ref:`ResourceNameHash` hash) const; :ref:`DrawablePtr` :target:`findDrawable`(:ref:`String::HashType` legacyHash) const; :ref:`TextureAtlasPtr` :target:`findAtlas`(const :ref:`ResourceKey`& key) const; :ref:`TextureAtlasPtr` :target:`findAtlas`(const std::string& key) const; std::vector<:ref:`TextureAtlasPtr`> :target:`getAtlases`() const; :ref:`FontPtr` :target:`findFont`(const :ref:`ResourceKey`& key) const; :ref:`FontPtr` :target:`findFont`(const std::string& key) const; :ref:`FontPtr` :target:`findFont`(:ref:`ResourceNameHash` hash) const; std::vector<:ref:`FontPtr`> :target:`getFonts`() const; :ref:`ShaderProgramPtr` :target:`findShaderProgram`(const :ref:`ResourceKey`& key) const; :ref:`ShaderProgramPtr` :target:`findShaderProgram`(const std::string& key) const; std::vector<:ref:`ShaderProgramPtr`> :target:`getShaderPrograms`() const; std::vector<:ref:`TextureRegionPtr`> :target:`findTextureRegionsByPattern`(const std::string& name, const std::string& extension = "", :ref:`TextureAtlas`* searchInTextureAtlas = nullptr) const; std::vector<:ref:`TextureRegionPtr`> :target:`findTextureRegionsByPatternId`(const :ref:`String::HashType`& id, const std::string& extension = "", :ref:`TextureAtlas`* searchInTextureAtlas = nullptr) const; void :target:`publishLocal`(:ref:`ResourceKey` key, :ref:`TexturePtr` texture); void :target:`publishLocal`(std::string key, :ref:`TexturePtr` texture); void :target:`publishLocalDrawable`(:ref:`ResourceKey` key, :ref:`DrawablePtr` drawable); void :target:`publishLocalDrawable`(std::string key, :ref:`DrawablePtr` drawable); void :target:`publishLocalAtlas`(:ref:`ResourceKey` key, :ref:`TextureAtlasPtr` atlas); void :target:`publishLocalAtlas`(std::string key, :ref:`TextureAtlasPtr` atlas); void :ref:`publishLocalFont`(:ref:`ResourceKey` key, :ref:`FontPtr` font); void :target:`publishLocalFont`(std::string key, :ref:`FontPtr` font); void :target:`publishLocalShaderProgram`(:ref:`ResourceKey` key, :ref:`ShaderProgramPtr` program); void :target:`publishLocalShaderProgram`(std::string key, :ref:`ShaderProgramPtr` program); bool :target:`eraseLocal`(const :ref:`ResourceKey`& key); bool :target:`eraseLocal`(const std::string& key); bool :target:`eraseLocalDrawable`(const :ref:`ResourceKey`& key); bool :target:`eraseLocalDrawable`(const std::string& key); bool :target:`eraseLocalAtlas`(const :ref:`ResourceKey`& key); bool :target:`eraseLocalAtlas`(const std::string& key); bool :target:`eraseLocalFont`(const :ref:`ResourceKey`& key); bool :target:`eraseLocalFont`(const std::string& key); bool :target:`eraseLocalFont`(:ref:`Font`* font); bool :target:`eraseLocalShaderProgram`(const :ref:`ResourceKey`& key); bool :target:`eraseLocalShaderProgram`(const std::string& key); void :target:`clearLocal`(); void :ref:`importCatalog`(:ref:`ResourceCatalogPtr` catalog); bool :ref:`removeCatalog`(const :ref:`ResourceCatalogPtr`& catalog); void :ref:`clearImports`(); :ref:`ResourceCatalogPtr` :target:`getLocalCatalog`() const; }; .. _details-class_e_e_1_1_graphics_1_1_resource_scope: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ :ref:`Graphics ` resource lookup boundary with local ownership and explicit catalog visibility. A scope owns resources published into its local catalog. Lookups search that local catalog first, followed by imported catalogs in import order. Importing a catalog retains the catalog and makes its resources visible; it does not copy resources and does not transfer them into the local catalog. Consequently, removing an import only removes lookup visibility and releases the scope's catalog reference. Use :ref:`importCatalog() ` when resources owned by another lifetime boundary must be visible in this scope, such as application assets shared with a scene or a theme catalog used by :ref:`UI ` widgets. Avoid importing unrelated scene or document catalogs: keeping imports explicit prevents name collisions and resource leakage between independent documents. UISceneNode imports the default resource catalog automatically unless that behavior is disabled at construction time. Methods ------- .. index:: pair: function; publishLocalFont .. _doxid-class_e_e_1_1_graphics_1_1_resource_scope_1a88a889d7e397cfd27c59abe674a59159: .. ref-code-block:: cpp :class: doxyrest-title-code-block void publishLocalFont(:ref:`ResourceKey` key, :ref:`FontPtr` font) Publishes a font under ``key``, replacing any existing local binding for that key. The requested semantic key is preserved. Fonts are never renamed to avoid a collision. A :ref:`FontTrueType ` instance can belong locally to only one :ref:`ResourceScope ` because it has one :ref:`FontService ` association. To expose the same font to another scope, import this scope's local catalog instead of publishing the same handle locally again. .. index:: pair: function; importCatalog .. _doxid-class_e_e_1_1_graphics_1_1_resource_scope_1a180e46ab540afa317c085533da3d94af: .. ref-code-block:: cpp :class: doxyrest-title-code-block void importCatalog(:ref:`ResourceCatalogPtr` catalog) Makes resources from ``catalog`` visible after this scope's local resources. Importing the same catalog more than once has no effect. The catalog is retained strongly for as long as it remains imported. Catalog contents stay live: resources published after this call become visible without importing the catalog again. .. index:: pair: function; removeCatalog .. _doxid-class_e_e_1_1_graphics_1_1_resource_scope_1a5227b428ad747e8e864850bdc4a7af9c: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool removeCatalog(const :ref:`ResourceCatalogPtr`& catalog) Removes an imported catalog without modifying the catalog or its resources. .. index:: pair: function; clearImports .. _doxid-class_e_e_1_1_graphics_1_1_resource_scope_1a8f0a3f1de9694104eb5e4192469cd599: .. ref-code-block:: cpp :class: doxyrest-title-code-block void clearImports() Removes every imported catalog while preserving this scope's local resources.