.. index:: pair: class; EE::Graphics::ResourceCatalog .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog: class EE::Graphics::ResourceCatalog =================================== .. toctree:: :hidden: Overview ~~~~~~~~ Thread-safe, strongly owning collection of named graphics resources. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include class ResourceCatalog { public: // methods static :ref:`ResourceCatalogPtr` :ref:`New`(); void :ref:`publish`(:ref:`ResourceKey` key, :ref:`TexturePtr` texture); void :ref:`publish`(std::string key, :ref:`TexturePtr` texture); void :ref:`publishDrawable`(:ref:`ResourceKey` key, :ref:`DrawablePtr` drawable); void :ref:`publishDrawable`(std::string key, :ref:`DrawablePtr` drawable); void :ref:`publishAtlas`(:ref:`ResourceKey` key, :ref:`TextureAtlasPtr` atlas); void :ref:`publishAtlas`(std::string key, :ref:`TextureAtlasPtr` atlas); void :ref:`publishFont`(:ref:`ResourceKey` key, :ref:`FontPtr` font); void :ref:`publishFont`(std::string key, :ref:`FontPtr` font); void :ref:`publishShaderProgram`(:ref:`ResourceKey` key, :ref:`ShaderProgramPtr` program); void :ref:`publishShaderProgram`(std::string key, :ref:`ShaderProgramPtr` program); :ref:`TexturePtr` :ref:`findTexture`(const :ref:`ResourceKey`& key) const; :ref:`TexturePtr` :ref:`findTexture`(const std::string& key) const; :ref:`DrawablePtr` :ref:`findDrawable`(const :ref:`ResourceKey`& key) const; :ref:`DrawablePtr` :ref:`findDrawable`(const std::string& key) const; :ref:`DrawablePtr` :ref:`findDrawable`(:ref:`ResourceNameHash` hash) const; :ref:`DrawablePtr` :ref:`findDrawable`(:ref:`String::HashType` legacyHash) const; :ref:`TextureAtlasPtr` :ref:`findAtlas`(const :ref:`ResourceKey`& key) const; :ref:`TextureAtlasPtr` :ref:`findAtlas`(const std::string& key) const; std::vector<:ref:`TextureAtlasPtr`> :ref:`getAtlases`() const; :ref:`FontPtr` :ref:`findFont`(const :ref:`ResourceKey`& key) const; :ref:`FontPtr` :ref:`findFont`(const std::string& key) const; :ref:`FontPtr` :ref:`findFont`(:ref:`ResourceNameHash` hash) const; std::vector<:ref:`FontPtr`> :ref:`getFonts`() const; :ref:`ShaderProgramPtr` :ref:`findShaderProgram`(const :ref:`ResourceKey`& key) const; :ref:`ShaderProgramPtr` :ref:`findShaderProgram`(const std::string& key) const; std::vector<:ref:`ShaderProgramPtr`> :ref:`getShaderPrograms`() const; bool :ref:`erase`(const :ref:`ResourceKey`& key); bool :ref:`erase`(const std::string& key); bool :ref:`eraseDrawable`(const :ref:`ResourceKey`& key); bool :ref:`eraseDrawable`(const std::string& key); bool :ref:`eraseAtlas`(const :ref:`ResourceKey`& key); bool :ref:`eraseAtlas`(const std::string& key); bool :ref:`eraseFont`(const :ref:`ResourceKey`& key); bool :ref:`eraseFont`(const std::string& key); bool :ref:`eraseFont`(:ref:`Font`* font); bool :ref:`eraseShaderProgram`(const :ref:`ResourceKey`& key); bool :ref:`eraseShaderProgram`(const std::string& key); void :ref:`clear`(); std::size_t :ref:`size`() const; }; .. _details-class_e_e_1_1_graphics_1_1_resource_catalog: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ Thread-safe, strongly owning collection of named graphics resources. A catalog maps semantic string keys to textures, drawable sources, texture atlases, and fonts. Publishing a resource gives the catalog shared ownership of it. Publishing another resource of the same kind under the same key replaces that binding; the key and resource name are never changed automatically. Publishing a null handle is equivalent to erasing the corresponding key, while an empty key is ignored. Lookups return owning handles. A resource obtained from a catalog therefore remains alive even if its binding is subsequently replaced, erased, or the catalog is cleared. Final handles are released after dropping the catalog mutex so resource destruction and callbacks never execute while the catalog is locked. :ref:`Drawable ` and font hash lookups use :ref:`resourceNameHash() ` as a direct secondary index. The dedicated 64-bit hash provides a cheap expected-O(1) convenience lookup for trusted names without changing the repository-wide 32-bit :ref:`String::HashType `. A hash is not mathematically collision-free, so complete :ref:`ResourceKey ` lookup remains authoritative and must be used for attacker-controlled names or persistent identity. :ref:`ResourceNameHash ` values are process-local conveniences and must not be serialized. :ref:`ResourceCatalog ` performs no parent, scene, live-registry, filesystem, or fallback search. A :ref:`ResourceScope ` defines lookup precedence by searching its local catalog and then explicitly imported catalogs. Importing a catalog shares this object and its live contents; it does not copy any resource. All public operations are safe to call concurrently. Enumeration methods return snapshots and allocate vectors containing owning handles. Methods ------- .. index:: pair: function; New .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog_1a4d983451118ba8e7cfb9fa1b0855ab93: .. ref-code-block:: cpp :class: doxyrest-title-code-block static :ref:`ResourceCatalogPtr` New() .. rubric:: Returns: A new empty catalog using eepp resource allocation and deletion. .. index:: pair: function; publish .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog_1aa91361a61a9ef40020cd995bb3990cbb: .. ref-code-block:: cpp :class: doxyrest-title-code-block void publish(:ref:`ResourceKey` key, :ref:`TexturePtr` texture) Publishes or replaces a texture binding. A null texture erases ``key``. .. index:: pair: function; publish .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog_1a9933fede1ad55e7eef060464644951d5: .. ref-code-block:: cpp :class: doxyrest-title-code-block void publish(std::string key, :ref:`TexturePtr` texture) Publishes or replaces a texture binding. A null texture erases ``key``. .. index:: pair: function; publishDrawable .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog_1aa88789a0519abd33dfc1bad6257220e4: .. ref-code-block:: cpp :class: doxyrest-title-code-block void publishDrawable(:ref:`ResourceKey` key, :ref:`DrawablePtr` drawable) Publishes or replaces a drawable-source binding. A null drawable erases ``key``. .. index:: pair: function; publishDrawable .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog_1af8cbc20b9a492697402e3069401c80b9: .. ref-code-block:: cpp :class: doxyrest-title-code-block void publishDrawable(std::string key, :ref:`DrawablePtr` drawable) Publishes or replaces a drawable-source binding. A null drawable erases ``key``. .. index:: pair: function; publishAtlas .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog_1a4b9943f8e29ad87cd0dd309d703ebe80: .. ref-code-block:: cpp :class: doxyrest-title-code-block void publishAtlas(:ref:`ResourceKey` key, :ref:`TextureAtlasPtr` atlas) Publishes or replaces a texture-atlas binding. A null atlas erases ``key``. .. index:: pair: function; publishAtlas .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog_1a483c6174891f8211f6aeab8bfeeab028: .. ref-code-block:: cpp :class: doxyrest-title-code-block void publishAtlas(std::string key, :ref:`TextureAtlasPtr` atlas) Publishes or replaces a texture-atlas binding. A null atlas erases ``key``. .. index:: pair: function; publishFont .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog_1ae3ccb4835b0c0fd799d57ef5ede909e3: .. ref-code-block:: cpp :class: doxyrest-title-code-block void publishFont(:ref:`ResourceKey` key, :ref:`FontPtr` font) Publishes or replaces a font binding. A null font erases ``key``. .. index:: pair: function; publishFont .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog_1a244c201c7b4fca81e152d4c5f8da1df0: .. ref-code-block:: cpp :class: doxyrest-title-code-block void publishFont(std::string key, :ref:`FontPtr` font) Publishes or replaces a font binding. A null font erases ``key``. .. index:: pair: function; publishShaderProgram .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog_1a249afbb9a53271495c7516111e668271: .. ref-code-block:: cpp :class: doxyrest-title-code-block void publishShaderProgram(:ref:`ResourceKey` key, :ref:`ShaderProgramPtr` program) Publishes or replaces a shader-program binding. A null program erases ``key``. .. index:: pair: function; publishShaderProgram .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog_1a04afb64b3eee433eab0917ae99d1e3b6: .. ref-code-block:: cpp :class: doxyrest-title-code-block void publishShaderProgram(std::string key, :ref:`ShaderProgramPtr` program) Publishes or replaces a shader-program binding. A null program erases ``key``. .. index:: pair: function; findTexture .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog_1a829c93ef3c9b7ba5f943b3ee73448bb8: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`TexturePtr` findTexture(const :ref:`ResourceKey`& key) const .. rubric:: Returns: The texture bound to ``key``, or an empty handle when it is not present. .. index:: pair: function; findTexture .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog_1a7ee0446b383c77b9215f2610c8224f52: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`TexturePtr` findTexture(const std::string& key) const .. rubric:: Returns: The texture bound to ``key``, or an empty handle when it is not present. .. index:: pair: function; findDrawable .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog_1a9c22a852f6a1c3e1cee293e7b39f690e: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`DrawablePtr` findDrawable(const :ref:`ResourceKey`& key) const .. rubric:: Returns: The drawable source bound to ``key``, or an empty handle when it is not present. .. index:: pair: function; findDrawable .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog_1af127112f064524fa919742bebf81485f: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`DrawablePtr` findDrawable(const std::string& key) const .. rubric:: Returns: The drawable source bound to ``key``, or an empty handle when it is not present. .. index:: pair: function; findDrawable .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog_1aa338ce0b5aa63e2f0cb18b01749e8f61: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`DrawablePtr` findDrawable(:ref:`ResourceNameHash` hash) const Looks up a drawable through the resourceNameHash(key) convenience index. .. index:: pair: function; findDrawable .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog_1a072cefd0c7d512f793bef8d4d4d0a07c: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`DrawablePtr` findDrawable(:ref:`String::HashType` legacyHash) const Legacy lookup for persisted 32-bit drawable hashes. This compatibility path scans full bindings and should not be used by new code. Persistent formats should migrate to complete :ref:`ResourceKey ` values rather than serializing another hash. If several names share ``legacyHash``, which matching drawable is returned is unspecified. .. index:: pair: function; findAtlas .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog_1a26856b2ce9a361ecff8a61421b6420d3: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`TextureAtlasPtr` findAtlas(const :ref:`ResourceKey`& key) const .. rubric:: Returns: The texture atlas bound to ``key``, or an empty handle when it is not present. .. index:: pair: function; findAtlas .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog_1a645a31b215f36f801f0f68f3578dfc29: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`TextureAtlasPtr` findAtlas(const std::string& key) const .. rubric:: Returns: The texture atlas bound to ``key``, or an empty handle when it is not present. .. index:: pair: function; getAtlases .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog_1a57dd43f34804c8c0fc0b4b73c25ad93f: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::vector<:ref:`TextureAtlasPtr`> getAtlases() const .. rubric:: Returns: An owning snapshot of all texture atlases currently published in this catalog. .. index:: pair: function; findFont .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog_1a0d85fac0431371d82b6cc0fceff87498: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`FontPtr` findFont(const :ref:`ResourceKey`& key) const .. rubric:: Returns: The font bound to ``key``, or an empty handle when it is not present. .. index:: pair: function; findFont .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog_1a8a01d635a2c8e1b31b99e65253288b61: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`FontPtr` findFont(const std::string& key) const .. rubric:: Returns: The font bound to ``key``, or an empty handle when it is not present. .. index:: pair: function; findFont .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog_1ad7ea3dcbd6408942ca64fa2ee466f25e: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`FontPtr` findFont(:ref:`ResourceNameHash` hash) const Looks up a font through the resourceNameHash(key) convenience index. .. index:: pair: function; getFonts .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog_1aaa20c36062a9f811475b15b39dae7d0f: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::vector<:ref:`FontPtr`> getFonts() const .. rubric:: Returns: An owning snapshot of all fonts currently published in this catalog. .. index:: pair: function; findShaderProgram .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog_1ae1442aa400a7167aea45eb89d5fd7cd4: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`ShaderProgramPtr` findShaderProgram(const :ref:`ResourceKey`& key) const .. rubric:: Returns: The shader program bound to ``key``, or an empty handle when absent. .. index:: pair: function; findShaderProgram .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog_1abcd25280f2dd18fb90b6f042e65603e0: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`ShaderProgramPtr` findShaderProgram(const std::string& key) const .. rubric:: Returns: The shader program bound to ``key``, or an empty handle when absent. .. index:: pair: function; getShaderPrograms .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog_1a7bcc7bee9ab02c6f6a3bf9636405b6bc: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::vector<:ref:`ShaderProgramPtr`> getShaderPrograms() const .. rubric:: Returns: An owning snapshot of all shader programs published in this catalog. .. index:: pair: function; erase .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog_1a6e19008cd0b6f6f3470d5c0cfdf8fa6d: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool erase(const :ref:`ResourceKey`& key) Removes the texture binding for ``key``. .. rubric:: Returns: Whether a binding was removed. .. index:: pair: function; erase .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog_1a759415b89cdbe95117a7e242ae80f041: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool erase(const std::string& key) Removes the texture binding for ``key``. .. rubric:: Returns: Whether a binding was removed. .. index:: pair: function; eraseDrawable .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog_1a292a581d82faf86545ea5eb316c6228a: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool eraseDrawable(const :ref:`ResourceKey`& key) Removes the drawable binding for ``key``. .. rubric:: Returns: Whether a binding was removed. .. index:: pair: function; eraseDrawable .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog_1aee36a892e0d4e85abcdf856cfcca6a3f: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool eraseDrawable(const std::string& key) Removes the drawable binding for ``key``. .. rubric:: Returns: Whether a binding was removed. .. index:: pair: function; eraseAtlas .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog_1abda7bcbc3eb923560bfa413185056bcc: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool eraseAtlas(const :ref:`ResourceKey`& key) Removes the texture-atlas binding for ``key``. .. rubric:: Returns: Whether a binding was removed. .. index:: pair: function; eraseAtlas .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog_1ac6dfb3b578d5a068342cb38f3da84064: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool eraseAtlas(const std::string& key) Removes the texture-atlas binding for ``key``. .. rubric:: Returns: Whether a binding was removed. .. index:: pair: function; eraseFont .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog_1a44986167edd2ab551c93062a0cd44030: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool eraseFont(const :ref:`ResourceKey`& key) Removes the font binding for ``key``. .. rubric:: Returns: Whether a binding was removed. .. index:: pair: function; eraseFont .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog_1a063a122eecafdac949cfaa0e14aeefe6: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool eraseFont(const std::string& key) Removes the font binding for ``key``. .. rubric:: Returns: Whether a binding was removed. .. index:: pair: function; eraseFont .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog_1abdac0e3fa87cadd995c9dc13fae36aaa: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool eraseFont(:ref:`Font`* font) Removes ``font`` only when its current name maps to that exact font in this catalog. .. rubric:: Returns: Whether the matching binding was removed. .. index:: pair: function; eraseShaderProgram .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog_1af9cff6396cbed30f634a2b7995e91895: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool eraseShaderProgram(const :ref:`ResourceKey`& key) Removes the shader-program binding for ``key``. .. index:: pair: function; eraseShaderProgram .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog_1afd4ce6a86790bdd57473d8e9381db422: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool eraseShaderProgram(const std::string& key) Removes the shader-program binding for ``key``. .. index:: pair: function; clear .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog_1a4f5379062583db9b62ae25ec225cc7ab: .. ref-code-block:: cpp :class: doxyrest-title-code-block void clear() Removes every binding while allowing previously returned handles to remain valid. .. index:: pair: function; size .. _doxid-class_e_e_1_1_graphics_1_1_resource_catalog_1a153e012086a8730de6771ac32faae87a: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::size_t size() const .. rubric:: Returns: The total number of bindings of every supported resource kind.