|
typedef std::function< void()> | AssetFinalizedCallback |
| A function pointer to an asset loaded callback function.
|
|
fplbase::AsyncAsset::AsyncAsset |
( |
const char * |
filename | ) |
|
|
inlineexplicit |
Construct an AsyncAsset with a given file name.
- Parameters
-
[in] | filename | A C-string corresponding to the name of the asset file. |
Adds a callback to be called when the asset is finalized.
Add a callback so logic can be executed when an asset is done loading.
- Parameters
-
callback | The function to be called. |
void fplbase::AsyncAsset::CallFinalizeCallback |
( |
| ) |
|
|
inlineprotected |
Calls app callbacks when an asset is ready to be used.
This should be called by descendants as soon as they are finalized.
const std::string& fplbase::AsyncAsset::filename |
( |
| ) |
const |
|
inline |
The name of the file associated with the resource.
- Returns
- Returns the filename.
virtual bool fplbase::AsyncAsset::Finalize |
( |
| ) |
|
|
pure virtual |
Override with converting the data into the resource.
This should implement the behavior of turning data_ into the actual desired resource. Called on the main thread only. Should check if data_ is null.
Implemented in fplbase::Texture, fplbase::Mesh, and fplbase::Shader.
virtual void fplbase::AsyncAsset::Load |
( |
| ) |
|
|
pure virtual |
Override with the actual loading behavior.
Load should perform the actual loading of filename_, and store the result in data_, or nullptr upon failure. It is called on the loader thread, so should not access any program state outside of this object. Since there will be only one loader thread, any libraries called by Load need not be MT-safe as long as they're not also called by the main thread.
Implemented in fplbase::Texture, fplbase::Mesh, and fplbase::Shader.
bool fplbase::AsyncAsset::LoadNow |
( |
| ) |
|
|
inline |
Performs a synchronous load by calling Load & Finalize.
Not used by the loader thread, should be called on the main thread.
- Returns
- Returns false on failure.
void fplbase::AsyncAsset::set_filename |
( |
const std::string & |
filename | ) |
|
|
inline |
Sets the filename that should be loaded.
Set the the filename in situations where it can't be initialized in the constructor. Must be called before AsyncLoader::QueueJob().
- Parameters
-
filename | The name of the file to load. |
The documentation for this class was generated from the following file: