本文整理汇总了C++中Package::SetLoader方法的典型用法代码示例。如果您正苦于以下问题:C++ Package::SetLoader方法的具体用法?C++ Package::SetLoader怎么用?C++ Package::SetLoader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Package
的用法示例。
在下文中一共展示了Package::SetLoader方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Shutdown
/// @copydoc PackageLoader::Shutdown()
void LoosePackageLoader::Shutdown()
{
// Sync with any in-flight async load requests.
if( m_startPreloadCounter )
{
while( !TryFinishPreload() )
{
Tick();
}
}
HELIUM_ASSERT( IsInvalid( m_parentPackageLoadId ) );
// Unset the reference back to this loader in the package.
Package* pPackage = m_spPackage;
if( pPackage )
{
pPackage->SetLoader( NULL );
}
m_spPackage.Release();
m_packagePath.Clear();
AtomicExchangeRelease( m_startPreloadCounter, 0 );
AtomicExchangeRelease( m_preloadedCounter, 0 );
m_objects.Clear();
size_t loadRequestCount = m_loadRequests.GetSize();
for( size_t requestIndex = 0; requestIndex < loadRequestCount; ++requestIndex )
{
if( m_loadRequests.IsElementValid( requestIndex ) )
{
LoadRequest* pRequest = m_loadRequests[ requestIndex ];
HELIUM_ASSERT( pRequest );
m_loadRequestPool.Release( pRequest );
}
}
m_loadRequests.Clear();
m_packageDirPath.Clear();
}
示例2: TickPreload
//.........这里部分代码省略.........
}
// Wait for the parent package to finish loading.
AssetPtr spParentPackage;
if( IsValid( m_parentPackageLoadId ) )
{
AssetLoader* pAssetLoader = AssetLoader::GetStaticInstance();
HELIUM_ASSERT( pAssetLoader );
if( !pAssetLoader->TryFinishLoad( m_parentPackageLoadId, spParentPackage ) )
{
return;
}
SetInvalid( m_parentPackageLoadId );
// Package loading should not fail. If it does, this is a sign of a potentially serious issue.
HELIUM_ASSERT( spParentPackage );
}
// Everything beyond this point "finalizes" the package preload, so stop here if we aren't ready to go
if (!bAllFileRequestsDone)
{
return;
}
// Create the package object if it does not yet exist.
Package* pPackage = m_spPackage;
if( !pPackage )
{
HELIUM_ASSERT( spParentPackage ? !m_packagePath.GetParent().IsEmpty() : m_packagePath.GetParent().IsEmpty() );
HELIUM_VERIFY( Asset::Create< Package >( m_spPackage, m_packagePath.GetName(), spParentPackage ) );
pPackage = m_spPackage;
HELIUM_ASSERT( pPackage );
pPackage->SetLoader( this );
}
HELIUM_ASSERT( pPackage->GetLoader() == this );
FilePath packageDirectoryPath;
if ( !FileLocations::GetDataDirectory( packageDirectoryPath ) )
{
HELIUM_TRACE( TraceLevels::Error, TXT( "LoosePackageLoader::TickPreload(): Could not get data directory.\n" ) );
return;
}
packageDirectoryPath += m_packagePath.ToFilePathString().GetData();
packageDirectoryPath += TXT("/");
DirectoryIterator packageDirectory( packageDirectoryPath );
for( ; !packageDirectory.IsDone(); packageDirectory.Next() )
{
const DirectoryIteratorItem& item = packageDirectory.GetItem();
if ( !item.m_Path.IsFile() )
{
continue;
}
Name objectName( item.m_Path.Filename().c_str() );
String objectNameString( item.m_Path.Filename().c_str() );
size_t objectIndex = FindObjectByName( objectName );
if( objectIndex != Invalid< size_t >() )
{
示例3: Initialize
/// Initialize this package loader.
///
/// @param[in] packagePath Asset path of the package to load.
///
/// @return True if this loader was initialized successfully, false if not.
///
/// @see Shutdown()
bool LoosePackageLoader::Initialize( AssetPath packagePath )
{
Shutdown();
// Make sure the path represents a package.
if( packagePath.IsEmpty() )
{
HELIUM_TRACE( TraceLevels::Error, TXT( "LoosePackageLoader::Initialize(): Empty package path specified.\n" ) );
return false;
}
HELIUM_TRACE(
TraceLevels::Debug,
TXT( "LoosePackageLoader::Initialize(): Initializing loader for package \"%s\".\n" ),
*packagePath.ToString() );
if( !packagePath.IsPackage() )
{
HELIUM_TRACE(
TraceLevels::Error,
TXT( "LoosePackageLoader::Initialize(): \"%s\" does not represent a package path.\n" ),
*packagePath.ToString() );
return false;
}
// Store the package path.
m_packagePath = packagePath;
// Attempt to locate the specified package if it already happens to exist.
m_spPackage = Asset::Find< Package >( packagePath );
Package* pPackage = m_spPackage;
if( pPackage )
{
if( pPackage->GetLoader() )
{
HELIUM_TRACE(
TraceLevels::Error,
TXT( "LoosePackageLoader::Initialize(): Package \"%s\" already has a loader.\n" ),
*packagePath.ToString() );
m_spPackage.Release();
return false;
}
pPackage->SetLoader( this );
}
else
{
// Make sure we don't have a name clash with a non-package object.
AssetPtr spObject( Asset::FindObject( packagePath ) );
if( spObject )
{
HELIUM_ASSERT( !spObject->IsPackage() );
HELIUM_TRACE(
TraceLevels::Error,
( TXT( "PackageLoader::Initialize(): Package loader cannot be initialized for \"%s\", as an " )
TXT( "object with the same name exists that is not a package.\n" ) ),
*packagePath.ToString() );
return false;
}
}
// Build the package file path. If the package is a user configuration package, use the user data directory,
// otherwise use the global data directory.
Config& rConfig = Config::GetStaticInstance();
FilePath dataDirectory;
if ( !FileLocations::GetDataDirectory( dataDirectory ) )
{
HELIUM_TRACE(
TraceLevels::Error,
TXT( "PackageLoader::Initialize(): Could not obtain user data directory." ) );
return false;
}
// Set up to read the TOC (which may not exist)
//SetInvalid( m_packageTocFileSize );
// First do this check without a trailing "/" so that FilePath has to actually look at the file system
FilePath package_dir = dataDirectory + packagePath.ToFilePathString().GetData();
if (!package_dir.Exists())
{
// Some packages like types or uninitialized user config packages may not exist on file system
m_packageDirPath = package_dir + TXT("/");
return true;
}
//.........这里部分代码省略.........
示例4: TryFinishLoadObject
/// @copydoc PackageLoader::TryFinishLoadObject()
bool CachePackageLoader::TryFinishLoadObject( size_t requestId, AssetPtr& rspObject )
{
HELIUM_ASSERT( requestId < m_loadRequests.GetSize() );
HELIUM_ASSERT( m_loadRequests.IsElementValid( requestId ) );
LoadRequest* pRequest = m_loadRequests[ requestId ];
HELIUM_ASSERT( pRequest );
if( !( pRequest->flags & LOAD_FLAG_PRELOADED ) )
{
return false;
}
// Sync on template and owner dependencies.
AssetLoader* pAssetLoader = AssetLoader::GetInstance();
HELIUM_ASSERT( pAssetLoader );
if( IsValid( pRequest->ownerLoadIndex ) )
{
size_t linkLoadId = pRequest->ownerLoadIndex;
if( IsValid( linkLoadId ) && !pAssetLoader->TryFinishLoad( linkLoadId, pRequest->spOwner ) )
{
return false;
}
SetInvalid( pRequest->ownerLoadIndex );
}
rspObject = pRequest->spObject;
Asset* pObject = rspObject;
if( pObject && ( pRequest->flags & LOAD_FLAG_ERROR ) )
{
pObject->SetFlags( Asset::FLAG_BROKEN );
}
if ( pObject->IsPackage() )
{
Package *pPackage = Reflect::AssertCast<Package>( pObject );
pPackage->SetLoader( this );
}
pRequest->spObject.Release();
HELIUM_ASSERT( IsInvalid( pRequest->asyncLoadId ) );
HELIUM_ASSERT( !pRequest->pAsyncLoadBuffer );
//pRequest->spTemplate.Release();
pRequest->spOwner.Release();
HELIUM_ASSERT( IsInvalid( pRequest->ownerLoadIndex ) );
//HELIUM_ASSERT( IsInvalid( pRequest->templateLoadIndex ) );
HELIUM_ASSERT( pObject || pRequest->pEntry );
HELIUM_TRACE(
TraceLevels::Debug,
"CachePackageLoader::TryFinishLoadObject(): Load request for \"%s\" (ID: %" PRIuSZ ") synced.\n",
*( pObject ? pObject->GetPath() : pRequest->pEntry->path ).ToString(),
requestId );
m_loadRequests.Remove( requestId );
m_loadRequestPool.Release( pRequest );
return true;
}