本文整理汇总了C++中Asset::IsDefaultTemplate方法的典型用法代码示例。如果您正苦于以下问题:C++ Asset::IsDefaultTemplate方法的具体用法?C++ Asset::IsDefaultTemplate怎么用?C++ Asset::IsDefaultTemplate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Asset
的用法示例。
在下文中一共展示了Asset::IsDefaultTemplate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TickPrecache
/// Update resource precaching for the given object load request.
///
/// @param[in] pRequest Load request to update.
///
/// @return True if resource precaching still requires processing, false if not.
bool AssetLoader::TickPrecache( LoadRequest* pRequest )
{
HELIUM_ASSERT( pRequest );
HELIUM_ASSERT( !( pRequest->stateFlags & LOAD_FLAG_LOADED ) );
Asset* pObject = pRequest->spObject;
if( pObject )
{
// TODO: SHouldn't this be in the linking phase?
if ( !pRequest->resolver.TryFinishPrecachingDependencies() )
{
return false;
}
pRequest->resolver.Clear();
// Perform any pre-precaching work (note that we don't precache anything for the default template object for
// a given type).
OnPrecacheReady( pObject, pRequest->pPackageLoader );
if( !pObject->GetAnyFlagSet( Asset::FLAG_BROKEN ) &&
!pObject->IsDefaultTemplate() &&
pObject->NeedsPrecacheResourceData() )
{
if( !( pRequest->stateFlags & LOAD_FLAG_PRECACHE_STARTED ) )
{
if( !pObject->BeginPrecacheResourceData() )
{
HELIUM_TRACE(
TraceLevels::Error,
TXT( "AssetLoader: Failed to begin precaching object \"%s\".\n" ),
*pObject->GetPath().ToString() );
pObject->SetFlags( Asset::FLAG_PRECACHED | Asset::FLAG_BROKEN );
AtomicOrRelease( pRequest->stateFlags, LOAD_FLAG_PRECACHED | LOAD_FLAG_ERROR );
return true;
}
AtomicOrRelease( pRequest->stateFlags, LOAD_FLAG_PRECACHE_STARTED );
}
if( !pObject->TryFinishPrecacheResourceData() )
{
return false;
}
}
pObject->SetFlags( Asset::FLAG_PRECACHED );
}
AtomicOrRelease( pRequest->stateFlags, LOAD_FLAG_PRECACHED );
return true;
}
示例2: TickDeserialize
/// Tick the object deserialization process for the given object load request.
///
/// @param[in] pRequest Load request.
///
/// @return True if the deserialization process has completed, false if it still needs time to process.
bool CachePackageLoader::TickDeserialize( LoadRequest* pRequest )
{
HELIUM_ASSERT( pRequest );
HELIUM_ASSERT( !( pRequest->flags & LOAD_FLAG_PRELOADED ) );
HELIUM_ASSERT( !pRequest->spObject );
const Cache::Entry* pCacheEntry = pRequest->pEntry;
HELIUM_ASSERT( pCacheEntry );
// Wait for the template and owner objects to load.
AssetLoader* pAssetLoader = AssetLoader::GetInstance();
HELIUM_ASSERT( pAssetLoader );
if( IsValid( pRequest->ownerLoadIndex ) )
{
size_t ownerLoadId = pRequest->ownerLoadIndex;
if( IsValid( ownerLoadId ) && !pAssetLoader->TryFinishLoad( ownerLoadId, pRequest->spOwner ) )
{
return false;
}
SetInvalid( pRequest->ownerLoadIndex );
if( !pRequest->spOwner )
{
HELIUM_TRACE(
TraceLevels::Error,
"CachePackageLoader: Failed to load owner object for \"%s\".\n",
*pCacheEntry->path.ToString() );
DefaultAllocator().Free( pRequest->pAsyncLoadBuffer );
pRequest->pAsyncLoadBuffer = NULL;
pRequest->flags |= LOAD_FLAG_PRELOADED | LOAD_FLAG_ERROR;
return true;
}
}
Asset* pOwner = pRequest->spOwner;
HELIUM_ASSERT( !pOwner || pOwner->IsFullyLoaded() );
Reflect::ObjectPtr cached_object = Cache::ReadCacheObjectFromBuffer(
pRequest->pPropertyDataBegin,
0,
pRequest->pPropertyDataEnd - pRequest->pPropertyDataBegin,
pRequest->pResolver);
AssetPtr assetPtr = Reflect::AssertCast<Asset>(cached_object);
Asset::RenameParameters params;
params.instanceIndex = -1;
params.name = pCacheEntry->path.GetName();
params.spOwner = pRequest->spOwner;
assetPtr->Rename(params);
pRequest->spObject = assetPtr;
Asset *pObject = assetPtr;
HELIUM_ASSERT( pObject );
if (!cached_object.ReferencesObject())
{
HELIUM_TRACE(
TraceLevels::Error,
"CachePackageLoader: Failed to deserialize object \"%s\".\n",
*pCacheEntry->path.ToString() );
pObject->SetFlags( Asset::FLAG_LINKED );
pObject->ConditionalFinalizeLoad();
pRequest->flags |= LOAD_FLAG_ERROR;
}
else
{
//cached_object->CopyTo(pObject);
if( !pObject->IsDefaultTemplate() )
{
// Load persistent resource data.
Resource* pResource = Reflect::SafeCast< Resource >( pObject );
if( pResource )
{
Reflect::ObjectPtr cached_prd = Cache::ReadCacheObjectFromBuffer(
pRequest->pPersistentResourceDataBegin,
0,
(pRequest->pPersistentResourceDataEnd - pRequest->pPersistentResourceDataBegin),
pRequest->pResolver);
if (!cached_prd.ReferencesObject())
{
HELIUM_TRACE(
TraceLevels::Error,
//.........这里部分代码省略.........
示例3: TickDeserialize
//.........这里部分代码省略.........
HELIUM_TRACE(
TraceLevels::Error,
TXT( "LoosePackageLoader: Failed to read the contents of object file \"%s\" in async load request \"%d\".\n" ),
object_file_path.c_str(),
pRequest->asyncFileLoadId );
}
else if( bytesRead != pRequest->asyncFileLoadBufferSize )
{
HELIUM_TRACE(
TraceLevels::Warning,
( TXT( "LoosePackageLoader: Attempted to read %" ) PRIuSZ TXT( " bytes from object file \"%s\", " )
TXT( "but only %" ) PRIuSZ TXT( " bytes were read.\n" ) ),
pRequest->asyncFileLoadBufferSize,
object_file_path.c_str(),
bytesRead );
}
else
{
StaticMemoryStream archiveStream ( pRequest->pAsyncFileLoadBuffer, pRequest->asyncFileLoadBufferSize );
HELIUM_TRACE(
TraceLevels::Info,
TXT( "LoosePackageLoader: Reading %s. pResolver = %x\n"),
object_file_path.c_str(),
pRequest->pResolver);
DynamicArray< Reflect::ObjectPtr > objects;
objects.Push( pRequest->spObject.Get() ); // use existing objects
Persist::ArchiveReaderJson::ReadFromStream( archiveStream, objects, pRequest->pResolver );
HELIUM_ASSERT( objects[0].Get() == pRequest->spObject.Get() );
}
}
if (load_properties_from_file)
{
DefaultAllocator().Free(pRequest->pAsyncFileLoadBuffer);
pRequest->pAsyncFileLoadBuffer = NULL;
pRequest->asyncFileLoadBufferSize = 0;
}
pRequest->flags |= LOAD_FLAG_PROPERTY_PRELOADED;
if( object_creation_failure )
{
HELIUM_TRACE(
TraceLevels::Error,
TXT( "LoosePackageLoader: Deserialization of object \"%s\" failed.\n" ),
*rObjectData.objectPath.ToString() );
pObject->SetFlags( Asset::FLAG_PRELOADED | Asset::FLAG_LINKED );
pObject->ConditionalFinalizeLoad();
pRequest->flags |= LOAD_FLAG_ERROR;
}
else if( !pObject->IsDefaultTemplate() )
{
// If the object is a resource (not including the default template object for resource types), attempt to begin
// loading any existing persistent resource data stored in the object cache.
Resource* pResource = Reflect::SafeCast< Resource >( pObject );
if( pResource )
{
Name objectCacheName = Name( HELIUM_ASSET_CACHE_NAME );
CacheManager& rCacheManager = CacheManager::GetStaticInstance();
Cache* pCache = rCacheManager.GetCache( objectCacheName );
HELIUM_ASSERT( pCache );
pCache->EnforceTocLoad();
const Cache::Entry* pEntry = pCache->FindEntry( rObjectData.objectPath, 0 );
if( pEntry && pEntry->size != 0 )
{
HELIUM_ASSERT( IsInvalid( pRequest->persistentResourceDataLoadId ) );
HELIUM_ASSERT( !pRequest->pCachedObjectDataBuffer );
pRequest->pCachedObjectDataBuffer =
static_cast< uint8_t* >( DefaultAllocator().Allocate( pEntry->size ) );
HELIUM_ASSERT( pRequest->pCachedObjectDataBuffer );
pRequest->cachedObjectDataBufferSize = pEntry->size;
AsyncLoader& rAsyncLoader = AsyncLoader::GetStaticInstance();
pRequest->persistentResourceDataLoadId = rAsyncLoader.QueueRequest(
pRequest->pCachedObjectDataBuffer,
pCache->GetCacheFileName(),
pEntry->offset,
pEntry->size );
HELIUM_ASSERT( IsValid( pRequest->persistentResourceDataLoadId ) );
}
}
}
if( IsInvalid( pRequest->persistentResourceDataLoadId ) )
{
// No persistent resource data needs to be loaded.
pObject->SetFlags( Asset::FLAG_PRELOADED );
pRequest->flags |= LOAD_FLAG_PERSISTENT_RESOURCE_PRELOADED;
}
// Asset is now preloaded.
return true;
}
示例4: ReplaceAsset
void Asset::ReplaceAsset( Asset* pNewAsset, const AssetPath &objectToReplace )
{
AssetAwareThreadSynchronizer::Lock assetLock;
// Acquire a write lock on the object list to prevent objects from being added and removed as well as keep
// objects from being renamed while this object is being renamed.
ScopeWriteLock scopeLock( sm_objectListLock );
Asset *pOldAsset = Asset::FindObject( objectToReplace );
HELIUM_ASSERT( pNewAsset->GetMetaClass()->IsType( pOldAsset->GetMetaClass() ) );
DynamicArray<AssetFixup> fixups;
// For every asset in existence
for ( SparseArray< AssetWPtr >::Iterator iter = sm_objects.Begin();
iter != sm_objects.End(); ++iter)
{
if ( !iter )
{
continue;
}
Asset* pPossibleFixupAsset = iter->Get();
if ( !pPossibleFixupAsset || pPossibleFixupAsset->IsDefaultTemplate() )
{
continue;
}
// Ignore it if it's the asset we're swapping
if ( pPossibleFixupAsset->m_id == pNewAsset->m_id || pPossibleFixupAsset->m_id == pOldAsset->m_id )
{
continue;
}
// If the asset has the old asset as a template (direct or indirect)
Asset *pTemplate = pPossibleFixupAsset->GetTemplateAsset().Get();
while ( pTemplate && !pTemplate->IsDefaultTemplate() )
{
if ( pTemplate == pOldAsset )
{
// Then save it off
// TODO: Does order matter? Right now we probably want bases first so that changes ripple down the template
// tree but in future we should probably have a flag of some sort to say if a field is set or not. Maybe in tools only.
AssetFixup &fixup = *fixups.New();
fixup.pAsset = pPossibleFixupAsset;
break;
}
pTemplate = pTemplate->GetTemplateAsset().Get();
}
}
const Reflect::MetaStruct *pStruct = pOldAsset->GetMetaClass();
// Get all the bases
// TODO: Declare a max depth for inheritance to save heap allocs -geoff
DynamicArray< const Reflect::MetaStruct* > bases;
for ( const Reflect::MetaStruct* current = pStruct; current != NULL; current = current->m_Base )
{
bases.Push( current );
}
// For all assets that depend on the changing asset
for ( DynamicArray<AssetFixup>::Iterator iter = fixups.Begin();
iter != fixups.End(); ++iter)
{
// Get the template (old) asset's type
Asset *pAsset = iter->pAsset;
// Get all the fields that should be modified due to the base template changing
// TODO: Declare a max count for fields to save heap allocs -geoff
DynamicArray< const Reflect::Field* > fields;
while ( !bases.IsEmpty() )
{
const Reflect::MetaStruct* current = bases.Pop();
DynamicArray< Reflect::Field >::ConstIterator itr = current->m_Fields.Begin();
DynamicArray< Reflect::Field >::ConstIterator end = current->m_Fields.End();
for ( ; itr != end; ++itr )
{
// Field is guaranteed to be in all objects of the template dependency chain
const Reflect::Field* field = &*itr;
// For every field
for ( uint32_t i = 0; i < field->m_Count; ++i )
{
bool isOverridden = false;
Reflect::Pointer assetPointer( field, pAsset, i );
// Is there anywhere in the template chain that the field gets overridden?
Asset *pTemplate = pAsset->GetTemplateAsset();
while ( pTemplate )
{
Reflect::Pointer templatePointer( field, pTemplate, i );
if ( !field->m_Translator->Equals( assetPointer, templatePointer ) )
{
// Yes, bail
isOverridden = true;
break;
//.........这里部分代码省略.........