-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathCacheAssetLoader.cpp
More file actions
83 lines (68 loc) · 1.98 KB
/
Copy pathCacheAssetLoader.cpp
File metadata and controls
83 lines (68 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include "Precompile.h"
#include "Engine/CacheAssetLoader.h"
#include "Engine/CachePackageLoader.h"
#include "Engine/Config.h"
using namespace Helium;
static uint32_t g_InitCount = 0;
/// Constructor.
CacheAssetLoader::CacheAssetLoader()
{
m_pAssetPackageLoader = new CachePackageLoader;
HELIUM_ASSERT( m_pAssetPackageLoader );
HELIUM_VERIFY( m_pAssetPackageLoader->Initialize( Name( "Asset" ) ) );
HELIUM_VERIFY( m_pAssetPackageLoader->BeginPreload() );
m_pConfigPackageLoader = new CachePackageLoader;
HELIUM_ASSERT( m_pConfigPackageLoader );
HELIUM_VERIFY( m_pConfigPackageLoader->Initialize( Name( "Config" ) ) );
HELIUM_VERIFY( m_pConfigPackageLoader->BeginPreload() );
}
/// Destructor.
CacheAssetLoader::~CacheAssetLoader()
{
delete m_pAssetPackageLoader;
m_pAssetPackageLoader = NULL;
delete m_pConfigPackageLoader;
m_pConfigPackageLoader = NULL;
}
/// Initialize the static object loader instance as a CacheAssetLoader.
///
/// @return True if the loader was initialized successfully, false if not or another object loader instance already
/// exists.
void CacheAssetLoader::Startup()
{
if ( ++g_InitCount == 1 )
{
AssetLoader::Startup();
HELIUM_ASSERT( !sm_pInstance )
sm_pInstance = new CacheAssetLoader;
HELIUM_ASSERT( sm_pInstance );
}
}
/// Destroy the global object loader instance if one exists.
///
/// @see GetInstance()
void CacheAssetLoader::Shutdown()
{
if ( --g_InitCount == 0 )
{
HELIUM_ASSERT( sm_pInstance );
delete sm_pInstance;
sm_pInstance = NULL;
AssetLoader::Shutdown();
}
}
/// @copydoc AssetLoader::GetPackageLoader()
PackageLoader* CacheAssetLoader::GetPackageLoader( AssetPath path )
{
if ( HELIUM_VERIFY( Config::GetInstance() ) && Config::GetInstance()->IsAssetPathInConfigContainerPackage( path ) )
{
return m_pConfigPackageLoader;
}
return m_pAssetPackageLoader;
}
/// @copydoc AssetLoader::TickPackageLoaders()
void CacheAssetLoader::TickPackageLoaders()
{
m_pAssetPackageLoader->Tick();
m_pConfigPackageLoader->Tick();
}