Cornell Cocos
Cornell Extensions to Cocos2d
|
#include <CUGenericLoader.h>
Public Member Functions | |
void | start () override |
void | stop () override |
size_t | waitCount () const override |
size_t | loadCount () const override |
bool | contains (std::string key) const override |
T * | get (std::string key) const override |
T * | load (std::string key, std::string source) override |
void | loadAsync (std::string key, std::string source) override |
void | unload (std::string key) override |
void | unloadAll () override |
GenericLoader () | |
virtual | ~GenericLoader () |
Public Member Functions inherited from Loader< T > | |
T * | operator[] (std::string key) const |
Public Member Functions inherited from BaseLoader | |
bool | isActive () const |
bool | isComplete () const |
float | progress () const |
CC_CONSTRUCTOR_ACCESS | _active (false) |
virtual | ~BaseLoader () |
Static Public Member Functions | |
static GenericLoader< T > * | create () |
Protected Attributes | |
GenericBaseLoader * | _internal |
Protected Attributes inherited from Loader< T > | |
std::unordered_map< std::string, T * > | _assets |
Protected Attributes inherited from BaseLoader | |
bool | _active |
Additional Inherited Members | |
Public Attributes inherited from BaseLoader | |
CC_CONSTRUCTOR_ACCESS | __pad0__: BaseLoader() : Ref() |
Class is a implementation of Loader<T> where T is a subclass of Asset.
This asset loader allows us to allocate generic from the associated source files. Instances of this loader wrap GenericBaseLoader, giving us access to the static coordinator for assets. It decides When an asset is truly ready to be unloaded. We assume that all instances are run only in the Director thread.
|
inline |
Creates a new, uninitialized asset loader
|
inlinevirtual |
Disposes of the asset loader.
This destructor will stop the asset loader if not done so already.
|
inlineoverridevirtual |
Returns true if the key maps to a loaded asset.
This method is useful in case the asset fails to load.
key | the key associated with the asset |
Reimplemented from Loader< T >.
|
inlinestatic |
Creates a new GenericLoader.
This constructor does not start the generic loader. It simply creates an object for the generic loader so that it can be attached to the asset manager. Call start() when you are ready to start using it.
|
inlineoverridevirtual |
Returns the asset for the given key.
If the key is valid, the asset is guaranteed not to be null. Otherwise, this method returns nullptr
key | the key associated with the asset |
Reimplemented from Loader< T >.
|
inlineoverridevirtual |
Loads a asset and assigns it to the given key.
The asset will be loaded synchronously. It will be available immediately. This method should be limited to those times in which an asset is really necessary immediately, such as for a loading screen.
key | The key to access the asset after loading |
source | The pathname to the asset file |
the loaded asset
Reimplemented from Loader< T >.
|
inlineoverridevirtual |
Adds a new asset to the loading queue.
The asset will be loaded asynchronously. When it is finished loading, it will be added to this loader, and accessible under the given key. This method will mark the loading process as not complete, even if it was completed previously. It is not safe to access the loaded asset until it is complete again.
key | The key to access the asset after loading |
source | The pathname to the asset file |
the asset upon loading
Reimplemented from BaseLoader.
|
inlineoverridevirtual |
Returns the number of assets currently loaded.
This is a rough way to determine how many assets have been loaded so far. This method counts each asset equally regardless of the memory requirements of each asset.
Reimplemented from Loader< T >.
|
inlineoverridevirtual |
Starts this GenericLoader.
Any assets loaded by this loader will be immediately released by the loader. However, an asset may still be available if it is attached to another loader. The asset manager is backed by a central coordinator that allows the sharing of assets.
Once the loader is stopped, any attempts to load a new asset will fail. You must call start() to begin loading assets again.
Reimplemented from BaseLoader.
|
inlineoverridevirtual |
Stops this GenericLoader, removing all assets.
Any assets loaded by this loader will be immediately released by the loader. However, an asset may still be available if it is attached to another loader. Once the loader is stopped, any attempts to load a new asset will fail. You must call start() to begin loading assets again.
Reimplemented from BaseLoader.
|
inlineoverridevirtual |
Unloads the asset for the given key.
This method simply unloads the asset for the scene associated with this loader. The asset will not be deleted or removed from memory until it is removed from all instances of GenericLoader.
key | the key referencing the asset |
the asset for the given key
Reimplemented from BaseLoader.
|
inlineoverridevirtual |
Unloads all assets present in this loader.
This method simply unloads the assets for the scene associated with this loader. The assets will not be deleted or removed from memory until they are removed from all instances of GenericLoader.
all loaded assets
Reimplemented from BaseLoader.
|
inlineoverridevirtual |
Returns the number of assets waiting to load.
This is a rough way to determine how many assets are still pending. An asset is pending if it has been loaded asychronously, and the loading process has not yet finished. This method counts each asset equally regardless of the memory requirements of the format.
Reimplemented from BaseLoader.
|
protected |
Wrapped reference to the base loader