39 lines
941 B
C++
39 lines
941 B
C++
// Copyright (c) 2022 Dominic Masters
|
|
//
|
|
// This software is released under the MIT License.
|
|
// https://opensource.org/licenses/MIT
|
|
|
|
#include "AssetLoader.hpp"
|
|
#include "assert/assert.hpp"
|
|
#include "asset/AssetManager.hpp"
|
|
|
|
using namespace Dawn;
|
|
|
|
const std::string AssetLoader::ASSET_TYPE = "unknown";
|
|
|
|
AssetLoader::AssetLoader(
|
|
const std::shared_ptr<AssetManager> assetManager,
|
|
const std::string name
|
|
) :
|
|
assetManager(assetManager),
|
|
name(name)
|
|
{
|
|
assertNotNull(assetManager, "AssetManager cannot be null");
|
|
assertTrue(name.size() > 0, "Name cannot be empty");
|
|
}
|
|
|
|
std::shared_ptr<AssetManager> AssetLoader::getAssetManager() {
|
|
auto am = this->assetManager.lock();
|
|
assertNotNull(am, "AssetManager is null");
|
|
return am;
|
|
}
|
|
|
|
void AssetLoader::loadImmediately() {
|
|
while(!this->loaded) {
|
|
this->getAssetManager()->update();
|
|
}
|
|
}
|
|
|
|
AssetLoader::~AssetLoader() {
|
|
this->loaded = false;
|
|
} |