.. index:: pair: class; EE::System::ResourceManager .. _doxid-class_e_e_1_1_system_1_1_resource_manager: template class EE::System::ResourceManager ========================================== .. toctree:: :hidden: Overview ~~~~~~~~ A simple resource manager. It keeps a list of the resources, and free the instances of the resources when the manager is closed. Resources must implement getId() and getName() properties getId() is the string hash of getName(). :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include template class ResourceManager { public: // construction virtual :ref:`~ResourceManager`(); // methods virtual T* :ref:`add`(T* resource); bool :ref:`remove`(T* resource, bool remove = true); bool :ref:`removeById`(const :ref:`String::HashType`& id, bool remove = true); bool :ref:`removeByName`(const std::string& name, bool remove = true); T* :ref:`getByName`(const std::string& name); T* :ref:`getById`(const :ref:`String::HashType`& id); :ref:`Uint32` :ref:`getCount`(); :ref:`Uint32` :ref:`getCount`(const std::string& name); :ref:`Uint32` :ref:`getCount`(const :ref:`String::HashType`& id); bool :ref:`exists`(const std::string& name); bool :ref:`existsId`(const :ref:`String::HashType`& id); void :ref:`destroy`(); void :ref:`printNames`(); :ref:`UnorderedMap`<:ref:`String::HashType`, T*>& :ref:`getResources`(); const bool& :ref:`isDestroying`() const; template void :target:`each`(Predicate pred) const; template void :target:`each`(Predicate pred); template T* :target:`findIf`(Predicate pred) const; template T* :target:`findIf`(Predicate pred); }; .. _details-class_e_e_1_1_system_1_1_resource_manager: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ A simple resource manager. It keeps a list of the resources, and free the instances of the resources when the manager is closed. Resources must implement getId() and getName() properties getId() is the string hash of getName(). Construction ------------ .. _doxid-class_e_e_1_1_system_1_1_resource_manager_1aed59bf925f440d784f2f998bdb1c05fa: .. ref-code-block:: cpp :class: doxyrest-title-code-block virtual ~ResourceManager() The destructor will call :ref:`destroy() ` and destroy all the resources added to the manager. Methods ------- .. index:: pair: function; add .. _doxid-class_e_e_1_1_system_1_1_resource_manager_1a3f725f6c223d45eeecfa843ed3ae0d77: .. ref-code-block:: cpp :class: doxyrest-title-code-block virtual T* add(T* resource) Add the resource to the resource manager. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - resource - The resource to be managed by the manager .. index:: pair: function; remove .. _doxid-class_e_e_1_1_system_1_1_resource_manager_1abe56bebac23f6c1dc0328e2754a2324f: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool remove(T* resource, bool remove = true) Removes the resource from the manager. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - resource - The resource to remove * - remove - Indicates if the resource must be destroyed after being removed from the manager .. index:: pair: function; removeById .. _doxid-class_e_e_1_1_system_1_1_resource_manager_1a40035a5c98256f4691135ff8608dd72c: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool removeById(const :ref:`String::HashType`& id, bool remove = true) Removes the resource by its id. .. rubric:: See also: :ref:`remove ` .. index:: pair: function; removeByName .. _doxid-class_e_e_1_1_system_1_1_resource_manager_1a7f73388539bfa79a0950dfce01eaa821: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool removeByName(const std::string& name, bool remove = true) Removes the resource by its name. .. rubric:: See also: :ref:`remove ` .. index:: pair: function; getByName .. _doxid-class_e_e_1_1_system_1_1_resource_manager_1a3515ab6990e118018cedff6a815faab0: .. ref-code-block:: cpp :class: doxyrest-title-code-block T* getByName(const std::string& name) .. rubric:: Returns: A resource by its name. If not found returns NULL. .. index:: pair: function; getById .. _doxid-class_e_e_1_1_system_1_1_resource_manager_1a5749033e0f05c50d9bb7d0e6b67f2ef9: .. ref-code-block:: cpp :class: doxyrest-title-code-block T* getById(const :ref:`String::HashType`& id) .. rubric:: Returns: A resource by its id. If not found returns NULL. .. index:: pair: function; getCount .. _doxid-class_e_e_1_1_system_1_1_resource_manager_1aa642647ef4519d73664b989b5c30bb0b: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`Uint32` getCount() .. rubric:: Returns: The number of resources added .. index:: pair: function; getCount .. _doxid-class_e_e_1_1_system_1_1_resource_manager_1ad38e495cd5ffb6fb00e6f3e969a751d0: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`Uint32` getCount(const std::string& name) .. rubric:: Returns: The number of resources that where added with the indicated name. .. index:: pair: function; getCount .. _doxid-class_e_e_1_1_system_1_1_resource_manager_1aa3e0bc0861e0e8228d8332bda953b882: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`Uint32` getCount(const :ref:`String::HashType`& id) .. rubric:: Returns: The number of resources that where added with the indicated id. .. index:: pair: function; exists .. _doxid-class_e_e_1_1_system_1_1_resource_manager_1a998fccccb42e1cccf52580f26ec47c5e: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool exists(const std::string& name) .. rubric:: Returns: If the resource name exists in the resources list. .. index:: pair: function; existsId .. _doxid-class_e_e_1_1_system_1_1_resource_manager_1a25820e2ef8710084e9c33c07ef2b274f: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool existsId(const :ref:`String::HashType`& id) .. rubric:: Returns: If the resource id exists in the resources list. .. index:: pair: function; destroy .. _doxid-class_e_e_1_1_system_1_1_resource_manager_1a783109ce25aeb4b23aab0d49c58302a2: .. ref-code-block:: cpp :class: doxyrest-title-code-block void destroy() Destroy all the resources added ( delete the instances of the resources ) .. index:: pair: function; printNames .. _doxid-class_e_e_1_1_system_1_1_resource_manager_1af5501acc4cbb5eb825b1bc1bf31e4f73: .. ref-code-block:: cpp :class: doxyrest-title-code-block void printNames() Prints all the resources names added to the manager. .. index:: pair: function; getResources .. _doxid-class_e_e_1_1_system_1_1_resource_manager_1a0e5e88684214cd8d56f3f7fbcddd6b8e: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`UnorderedMap`<:ref:`String::HashType`, T*>& getResources() .. rubric:: Returns: A reference to the resources list of the manager. .. index:: pair: function; isDestroying .. _doxid-class_e_e_1_1_system_1_1_resource_manager_1a70647301320b909ddad4b40600e6e3f8: .. ref-code-block:: cpp :class: doxyrest-title-code-block const bool& isDestroying() const Indicates if the resource manager is destroy the resources.