.. index:: pair: class; EE::System::ResourceLoader .. _doxid-class_e_e_1_1_system_1_1_resource_loader: class EE::System::ResourceLoader ================================ .. toctree:: :hidden: Overview ~~~~~~~~ A simple resource loader that can load a batch of resources synchronously or asynchronously. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include class ResourceLoader { public: // typedefs typedef std::function :target:`ResLoadCallback`; typedef std::function :target:`ObjectLoaderTask`; // construction :ref:`ResourceLoader`(const :ref:`Uint32`& MaxThreads = :ref:`THREADS_AUTO`); virtual :target:`~ResourceLoader`(); // methods void :ref:`add`(const :ref:`ObjectLoaderTask`& objectLoaderTask); void :ref:`load`(const :ref:`ResLoadCallback`& callback); void :ref:`load`(); virtual bool :ref:`isLoaded`(); virtual bool :ref:`isLoading`(); bool :ref:`isThreaded`() const; void :ref:`setThreaded`(const bool& setThreaded); bool :ref:`clear`(); :ref:`Float` :ref:`getProgress`(); :ref:`Uint32` :ref:`getCount`() const; }; .. _details-class_e_e_1_1_system_1_1_resource_loader: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ A simple resource loader that can load a batch of resources synchronously or asynchronously. Construction ------------ .. index:: pair: function; ResourceLoader .. _doxid-class_e_e_1_1_system_1_1_resource_loader_1a9e1316c69c694c1900fac708bc51623e: .. ref-code-block:: cpp :class: doxyrest-title-code-block ResourceLoader(const :ref:`Uint32`& MaxThreads = :ref:`THREADS_AUTO`) .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - MaxThreads - Set the maximun simultaneous threads to load resources, THREADS_AUTO will use the cpu number of cores. Methods ------- .. index:: pair: function; add .. _doxid-class_e_e_1_1_system_1_1_resource_loader_1a500edaec9fc2074391d67485e9fb4feb: .. ref-code-block:: cpp :class: doxyrest-title-code-block void add(const :ref:`ObjectLoaderTask`& objectLoaderTask) Adds a resource to load. Must be called before the loading starts. Once an object loader is added to the resource loader, the instance of that object will be managed and released by the loader. \*. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - objectLoaderTask - The function callback of the load process .. index:: pair: function; load .. _doxid-class_e_e_1_1_system_1_1_resource_loader_1a2475e6872cc0dc37ed73ea187328024c: .. ref-code-block:: cpp :class: doxyrest-title-code-block void load(const :ref:`ResLoadCallback`& callback) Starts loading the resources. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - callback - A callback that is called when the resources finished loading. .. index:: pair: function; load .. _doxid-class_e_e_1_1_system_1_1_resource_loader_1a88c7d471e2172bffe08edb613d27e99e: .. ref-code-block:: cpp :class: doxyrest-title-code-block void load() Starts loading the resources. .. index:: pair: function; isLoaded .. _doxid-class_e_e_1_1_system_1_1_resource_loader_1a5cbdbec875ae9ababb0f247b98f04135: .. ref-code-block:: cpp :class: doxyrest-title-code-block virtual bool isLoaded() .. rubric:: Returns: If the resources were loaded. .. index:: pair: function; isLoading .. _doxid-class_e_e_1_1_system_1_1_resource_loader_1ad5df571891a7f340bb15f8a6c4d9e572: .. ref-code-block:: cpp :class: doxyrest-title-code-block virtual bool isLoading() .. rubric:: Returns: If the resources are still loading. .. index:: pair: function; isThreaded .. _doxid-class_e_e_1_1_system_1_1_resource_loader_1a94d6b8c635b16e9031c8bdb6f2a1d774: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool isThreaded() const .. rubric:: Returns: If the resource loader is asynchronous .. index:: pair: function; setThreaded .. _doxid-class_e_e_1_1_system_1_1_resource_loader_1aad2899db0b3bbb0b684e4850bf37debe: .. ref-code-block:: cpp :class: doxyrest-title-code-block void setThreaded(const bool& setThreaded) Sets if the resource loader is asynchronous. This must be called before the load starts. .. index:: pair: function; clear .. _doxid-class_e_e_1_1_system_1_1_resource_loader_1abdb78a18202c2c09bcd132731c1b7577: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool clear() Clears the resources added to load that werent loaded, and delete the instances of the loaders. .. index:: pair: function; getProgress .. _doxid-class_e_e_1_1_system_1_1_resource_loader_1a1c598a5e2f0b87ac6872670f294908bb: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`Float` getProgress() .. rubric:: Returns: The aproximate percent of progress ( between 0 and 100 ) .. index:: pair: function; getCount .. _doxid-class_e_e_1_1_system_1_1_resource_loader_1ab085948cdbb50b14f7c7ccf19e66077e: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`Uint32` getCount() const .. rubric:: Returns: The number of resources added to load.