Polyphase Game Engine
Loading...
Searching...
No Matches
AssetManager Class Reference

#include <AssetManager.h>

Public Member Functions

 ~AssetManager ()
 
void Initialize ()
 
void Update (float deltaTime)
 
void DiscoverDirectory (AssetDir *directory, bool engineDir)
 
void RefreshDirectory (AssetDir *directory)
 
void Discover (const char *directoryName, const char *directoryPath)
 
void DiscoverAssetRegistry (const char *registryPath)
 
void DiscoverEmbeddedAssets (struct EmbeddedFile *assets, uint32_t numAssets)
 
void Purge (bool purgeEngineAssets)
 
bool PurgeAsset (const char *name)
 
void RefSweep ()
 
void LoadAll ()
 
POLYPHASE_API void RegisterTransientAsset (Asset *asset)
 
AssetImportEngineAsset (TypeId assetType, AssetDir *dir, const std::string &filename, ImportOptions *options=nullptr)
 
void ImportEngineAssets ()
 
AssetStubGetAssetStub (const std::string &name)
 
AssetGetAsset (const std::string &name)
 
AssetStubGetSceneAsset (const std::string &name)
 
AssetLoadAsset (const std::string &name)
 
AssetLoadAsset (AssetStub &stub)
 
void AsyncLoadAsset (const std::string &name, AssetRef *targetRef)
 
AssetStubGetAssetStubByUuid (uint64_t uuid)
 
AssetGetAssetByUuid (uint64_t uuid)
 
AssetLoadAssetByUuid (uint64_t uuid)
 
void AsyncLoadAssetByUuid (uint64_t uuid, AssetRef *targetRef)
 
AssetStubGetAssetStubByPath (const std::string &path)
 
AssetLoadAssetByPath (const std::string &path)
 
void SaveAsset (const std::string &name)
 
void SaveAsset (AssetStub &stub)
 
bool UnloadAsset (const std::string &name)
 
bool UnloadAsset (AssetStub &stub)
 
bool DoesAssetExist (const std::string &name)
 
bool RenameAsset (Asset *asset, const std::string &newName)
 
std::string GetParentDirectory (const std::string &path)
 
bool RenameDirectory (AssetDir *dir, const std::string &newName)
 
void GatherScriptFilesRecursive (const std::string &dirPath, const std::string &relativePath, std::vector< std::string > &scriptFiles)
 
std::vector< std::string > GetAvailableScriptFiles ()
 
std::vector< std::string > GetAvailableFontFiles ()
 
AssetDirFindProjectDirectory ()
 
AssetDirFindProjectRootDirectory ()
 
AssetDirFindEngineDirectory ()
 
AssetDirFindPackagesDirectory ()
 
AssetDirGetRootDirectory ()
 
void DiscoverAddonPackages (const std::string &packagesDir)
 
std::string GetPolyphaseDirectory ()
 
void GatherScriptFiles (const std::string &dir, std::vector< std::string > &outFiles)
 
void GatherFontFiles (const std::string &dir, std::vector< std::string > &outFiles)
 
AssetStubFindDefaultScene ()
 
std::string FindDefaultScenePath ()
 
void UnloadProjectDirectory ()
 
std::unordered_map< std::string, AssetStub * > & GetAssetMap ()
 
std::vector< AssetStub * > GatherDirtyAssets ()
 
AssetStubRegisterAsset (const std::string &filename, TypeId type, AssetDir *directory, EmbeddedFile *embeddedAsset, bool engineAsset, uint64_t uuid=0)
 
AssetStubCreateAndRegisterAsset (TypeId assetType, AssetDir *directory, const std::string &filename, bool engineAsset)
 
AssetDirGetAssetDirFromPath (const std::string &dirPath)
 
bool IsPurging () const
 

Static Public Member Functions

static void Create ()
 
static void Destroy ()
 
static POLYPHASE_API AssetManagerGet ()
 

Protected Member Functions

 AssetManager ()
 
void UpdateEndLoadQueue ()
 

Static Protected Member Functions

static ThreadFuncRet AsyncLoadThreadFunc (void *in)
 

Protected Attributes

std::unordered_map< std::string, AssetStub * > mAssetMap
 
std::unordered_map< std::string, AssetStub * > mAssetPathMap
 
std::unordered_map< uint64_t, AssetStub * > mUuidMap
 
std::vector< Asset * > mTransientAssets
 
AssetDirmRootDirectory = nullptr
 
bool mPurging = false
 
bool mDestructing = false
 
std::deque< AsyncLoadRequest * > mBeginLoadQueue
 
std::deque< AsyncLoadRequest * > mEndLoadQueue
 
ThreadObject * mAsyncLoadThread = {}
 
MutexObject * mMutex = {}
 

Static Protected Attributes

static AssetManagersInstance = nullptr
 

Constructor & Destructor Documentation

◆ ~AssetManager()

AssetManager::~AssetManager ( )

◆ AssetManager()

AssetManager::AssetManager ( )
protected

Member Function Documentation

◆ AsyncLoadAsset()

void AssetManager::AsyncLoadAsset ( const std::string &  name,
AssetRef targetRef 
)

◆ AsyncLoadAssetByUuid()

void AssetManager::AsyncLoadAssetByUuid ( uint64_t  uuid,
AssetRef targetRef 
)

◆ AsyncLoadThreadFunc()

ThreadFuncRet AssetManager::AsyncLoadThreadFunc ( void *  in)
staticprotected

◆ Create()

void AssetManager::Create ( )
static

◆ CreateAndRegisterAsset()

AssetStub * AssetManager::CreateAndRegisterAsset ( TypeId  assetType,
AssetDir directory,
const std::string &  filename,
bool  engineAsset 
)

◆ Destroy()

void AssetManager::Destroy ( )
static

◆ Discover()

void AssetManager::Discover ( const char *  directoryName,
const char *  directoryPath 
)

◆ DiscoverAddonPackages()

void AssetManager::DiscoverAddonPackages ( const std::string &  packagesDir)

◆ DiscoverAssetRegistry()

void AssetManager::DiscoverAssetRegistry ( const char *  registryPath)

◆ DiscoverDirectory()

void AssetManager::DiscoverDirectory ( AssetDir directory,
bool  engineDir 
)

◆ DiscoverEmbeddedAssets()

void AssetManager::DiscoverEmbeddedAssets ( struct EmbeddedFile assets,
uint32_t  numAssets 
)

◆ DoesAssetExist()

bool AssetManager::DoesAssetExist ( const std::string &  name)

◆ FindDefaultScene()

AssetStub * AssetManager::FindDefaultScene ( )

◆ FindDefaultScenePath()

std::string AssetManager::FindDefaultScenePath ( )

◆ FindEngineDirectory()

AssetDir * AssetManager::FindEngineDirectory ( )

◆ FindPackagesDirectory()

AssetDir * AssetManager::FindPackagesDirectory ( )

◆ FindProjectDirectory()

AssetDir * AssetManager::FindProjectDirectory ( )

◆ FindProjectRootDirectory()

AssetDir * AssetManager::FindProjectRootDirectory ( )

◆ GatherDirtyAssets()

std::vector< AssetStub * > AssetManager::GatherDirtyAssets ( )

◆ GatherFontFiles()

void AssetManager::GatherFontFiles ( const std::string &  dir,
std::vector< std::string > &  outFiles 
)

◆ GatherScriptFiles()

void AssetManager::GatherScriptFiles ( const std::string &  dir,
std::vector< std::string > &  outFiles 
)

◆ GatherScriptFilesRecursive()

void AssetManager::GatherScriptFilesRecursive ( const std::string &  dirPath,
const std::string &  relativePath,
std::vector< std::string > &  scriptFiles 
)

◆ Get()

AssetManager * AssetManager::Get ( )
static

◆ GetAsset()

Asset * AssetManager::GetAsset ( const std::string &  name)

◆ GetAssetByUuid()

Asset * AssetManager::GetAssetByUuid ( uint64_t  uuid)

◆ GetAssetDirFromPath()

AssetDir * AssetManager::GetAssetDirFromPath ( const std::string &  dirPath)

◆ GetAssetMap()

std::unordered_map< std::string, AssetStub * > & AssetManager::GetAssetMap ( )

◆ GetAssetStub()

AssetStub * AssetManager::GetAssetStub ( const std::string &  name)

◆ GetAssetStubByPath()

AssetStub * AssetManager::GetAssetStubByPath ( const std::string &  path)

◆ GetAssetStubByUuid()

AssetStub * AssetManager::GetAssetStubByUuid ( uint64_t  uuid)

◆ GetAvailableFontFiles()

std::vector< std::string > AssetManager::GetAvailableFontFiles ( )

◆ GetAvailableScriptFiles()

std::vector< std::string > AssetManager::GetAvailableScriptFiles ( )

◆ GetParentDirectory()

std::string AssetManager::GetParentDirectory ( const std::string &  path)

◆ GetPolyphaseDirectory()

std::string AssetManager::GetPolyphaseDirectory ( )

◆ GetRootDirectory()

AssetDir * AssetManager::GetRootDirectory ( )

◆ GetSceneAsset()

AssetStub * AssetManager::GetSceneAsset ( const std::string &  name)

◆ ImportEngineAsset()

Asset * AssetManager::ImportEngineAsset ( TypeId  assetType,
AssetDir dir,
const std::string &  filename,
ImportOptions options = nullptr 
)

◆ ImportEngineAssets()

void AssetManager::ImportEngineAssets ( )

◆ Initialize()

void AssetManager::Initialize ( )

◆ IsPurging()

bool AssetManager::IsPurging ( ) const

◆ LoadAll()

void AssetManager::LoadAll ( )

◆ LoadAsset() [1/2]

Asset * AssetManager::LoadAsset ( AssetStub stub)

◆ LoadAsset() [2/2]

Asset * AssetManager::LoadAsset ( const std::string &  name)

◆ LoadAssetByPath()

Asset * AssetManager::LoadAssetByPath ( const std::string &  path)

◆ LoadAssetByUuid()

Asset * AssetManager::LoadAssetByUuid ( uint64_t  uuid)

◆ Purge()

void AssetManager::Purge ( bool  purgeEngineAssets)

◆ PurgeAsset()

bool AssetManager::PurgeAsset ( const char *  name)

◆ RefreshDirectory()

void AssetManager::RefreshDirectory ( AssetDir directory)

◆ RefSweep()

void AssetManager::RefSweep ( )

◆ RegisterAsset()

AssetStub * AssetManager::RegisterAsset ( const std::string &  filename,
TypeId  type,
AssetDir directory,
EmbeddedFile embeddedAsset,
bool  engineAsset,
uint64_t  uuid = 0 
)

◆ RegisterTransientAsset()

void AssetManager::RegisterTransientAsset ( Asset asset)

◆ RenameAsset()

bool AssetManager::RenameAsset ( Asset asset,
const std::string &  newName 
)

◆ RenameDirectory()

bool AssetManager::RenameDirectory ( AssetDir dir,
const std::string &  newName 
)

◆ SaveAsset() [1/2]

void AssetManager::SaveAsset ( AssetStub stub)

◆ SaveAsset() [2/2]

void AssetManager::SaveAsset ( const std::string &  name)

◆ UnloadAsset() [1/2]

bool AssetManager::UnloadAsset ( AssetStub stub)

◆ UnloadAsset() [2/2]

bool AssetManager::UnloadAsset ( const std::string &  name)

◆ UnloadProjectDirectory()

void AssetManager::UnloadProjectDirectory ( )

◆ Update()

void AssetManager::Update ( float  deltaTime)

◆ UpdateEndLoadQueue()

void AssetManager::UpdateEndLoadQueue ( )
protected

Member Data Documentation

◆ mAssetMap

std::unordered_map<std::string, AssetStub*> AssetManager::mAssetMap
protected

◆ mAssetPathMap

std::unordered_map<std::string, AssetStub*> AssetManager::mAssetPathMap
protected

◆ mAsyncLoadThread

ThreadObject* AssetManager::mAsyncLoadThread = {}
protected

◆ mBeginLoadQueue

std::deque<AsyncLoadRequest*> AssetManager::mBeginLoadQueue
protected

◆ mDestructing

bool AssetManager::mDestructing = false
protected

◆ mEndLoadQueue

std::deque<AsyncLoadRequest*> AssetManager::mEndLoadQueue
protected

◆ mMutex

MutexObject* AssetManager::mMutex = {}
protected

◆ mPurging

bool AssetManager::mPurging = false
protected

◆ mRootDirectory

AssetDir* AssetManager::mRootDirectory = nullptr
protected

◆ mTransientAssets

std::vector<Asset*> AssetManager::mTransientAssets
protected

◆ mUuidMap

std::unordered_map<uint64_t, AssetStub*> AssetManager::mUuidMap
protected

◆ sInstance

AssetManager * AssetManager::sInstance = nullptr
staticprotected

The documentation for this class was generated from the following files: