Assets Class Reference

#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

enum Type
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 AssetID Load ( const std::string &  fileType,
const std::string &  file,
bool  nameOnly = true 
)
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
fileTypeThe registered file type. See output from SupportedLoadExtensions() to see which strings are valid.
fileThe path to the file to be loaded.
nameOnlyIf 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 AssetID LoadFromBuffer ( const std::string &  filetype,
const std::string &  name,
const std::vector< uint8_t > &  data 
)
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
fileTypeThe registered file type. See output from SupportedLoadExtensions() to see which strings are valid.
nameThe unique identifier of the asset, allowing for use with Query() calls.
dataThe bytes consisting of the Asset's data.
static std::vector<std::string> SupportedLoadExtensions ( Assets::Type  type)
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
typeThe type of asset to ask available extensions for.
static AssetID Query ( Assets::Type  type,
const std::string &  name 
)
static

Returns the AssetID associated with the name and type.

For the query to be successful, both the type and name must match.

Parameters
typeThe type of asset to ask about.
nameThe name of the asset to check.
static AssetID New ( Assets::Type  type,
const std::string &  name = "" 
)
static

Generates a new instance of the specified Asset type and returns its ID.

An invalid AssetID is returned if unsuccessful.

Parameters
typeThe type of the new asset.
nameThe unique identifier of the new asset.
T & Get ( AssetID  id)
static

Returns the Asset reference associated with the given ID.

Parameters
idThe asset to retrieve.
static bool Remove ( AssetID  id)
static

Removes the specified Asset.

After removal, all remaining AssetID copies are made invalid.

Parameters
idThe asset to remove.
static bool Write ( AssetID  id,
const std::string &  encoderExtension,
const std::string &  outputName 
)
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
idThe asset to write.
enconderExtensionThe type to write the asset as.
outputNameThe namem of the file.
static std::vector<std::string> SupportedWriteExtensions ( Assets::Type  type)
static

Returns a vector of strings containing the currently supported types that can be written to.

Parameters
typeThe type of asset to ask about.
static std::string Name ( AssetID  type)
static

Returns the name associated with the Asset.

Parameters
typeThe 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