#include <Assets.h>
Description
Handles loading media.
When working with a multimedia project, you often will need to load in different kinds of media with varying filetypes and sources. Assets allows you to work with a common framework for all these types. In specifying the filename and kind of media, Dynacoe will find the media, load it, and let you start working with it right away.
Any Dynacoe build could have additional supported media types as well. The supported media types may always be queried using the SupportedLoadExtensions() function.
As well as loading, Dynacoe also supports exporting for some types. SupportedWriteExtensions() may be used for that purpose.
Public Types | |
enum | Type { Placeholder, Image, Font, Audio, Sequence, Particle, RawData, Model } |
Static Functions | |
static AssetID | Load (const std::string &fileType, const std::string &file, bool nameOnly=true) |
static AssetID | LoadFromBuffer (const std::string &filetype, const std::string &name, const std::vector< uint8_t > &data) |
static std::vector< std::string > | SupportedLoadExtensions (Assets::Type type) |
static AssetID | Query (Assets::Type type, const std::string &name) |
static AssetID | New (Assets::Type type, const std::string &name="") |
template<typename T > | |
static T & | Get (AssetID id) |
static bool | Remove (AssetID id) |
static bool | Write (AssetID id, const std::string &encoderExtension, const std::string &outputName) |
static std::vector< std::string > | SupportedWriteExtensions (Assets::Type type) |
static std::string | Name (AssetID type) |
Member Enumeration Documentation
|
strong |
A classification of individual Assets.
Enumerator | |
---|---|
Placeholder |
Not an action Type. |
Image |
An Image. |
Font |
A FontAsset. |
Audio |
An AudioBlock. |
Sequence |
A Sequence. |
Particle |
A Particle. |
RawData |
A data buffer. |
Model |
Collection of meshes, animations, and/or materials. |
Member Function Documentation
|
static |
Loads the specifed asset into memory.
The first argument refers to what kind of file Dynacoe should attempt to load it as. This also determines its type. For example, If the "png" format is supported, loading it will associate a Dynaoce::Image with the asset Load() will also compare the path with known saved Asset paths. If the path is already known, the id to the already saved duplicate is returned. if there is no match, the asset is added to the list. If unsuccessful, an invalid AssetID will be returned.
- Parameters
-
fileType The registered file type. See output from SupportedLoadExtensions() to see which strings are valid. file The path to the file to be loaded. nameOnly If true, Dynacoe treats the file argument as a name of a file and recursively searches for the file in the current working directory. Else, the file argument is treated as a full path to the file.
|
static |
Loads the specified asset from memory into, err, memory.
Once run, LoadFromMemory will load the asset as if it were called from Load().
- Parameters
-
fileType The registered file type. See output from SupportedLoadExtensions() to see which strings are valid. name The unique identifier of the asset, allowing for use with Query() calls. data The bytes consisting of the Asset's data.
|
static |
Returns a list of supported file types that Dynacoe can load.
These extensions should be passed as the fileType argument to Assets::Load()
- Parameters
-
type The type of asset to ask available extensions for.
|
static |
Returns the AssetID associated with the name and type.
For the query to be successful, both the type and name must match.
- Parameters
-
type The type of asset to ask about. name The name of the asset to check.
|
static |
Generates a new instance of the specified Asset type and returns its ID.
An invalid AssetID is returned if unsuccessful.
- Parameters
-
type The type of the new asset. name The unique identifier of the new asset.
|
static |
Returns the Asset reference associated with the given ID.
- Parameters
-
id The asset to retrieve.
|
static |
Removes the specified Asset.
After removal, all remaining AssetID copies are made invalid.
- Parameters
-
id The asset to remove.
|
static |
Attempts to dump the asset to a file.
The encoder extension specifies which encoder should handle writing the file. If the extension is not supported, the write will fail and false will be returned. True is returned if the dump was reported as successful by the encoder.
- Parameters
-
id The asset to write. enconderExtension The type to write the asset as. outputName The namem of the file.
|
static |
Returns a vector of strings containing the currently supported types that can be written to.
- Parameters
-
type The type of asset to ask about.
|
static |
Returns the name associated with the Asset.
- Parameters
-
type The asset to ask about.
The documentation for this class was generated from the following file:
- /home/jc/git/Dynacoe/DynacoeSrc/includes/Dynacoe/Modules/Assets.h