当前位置: 首页>>代码示例>>C++>>正文


C++ Asset::ConditionalFinalizeLoad方法代码示例

本文整理汇总了C++中Asset::ConditionalFinalizeLoad方法的典型用法代码示例。如果您正苦于以下问题:C++ Asset::ConditionalFinalizeLoad方法的具体用法?C++ Asset::ConditionalFinalizeLoad怎么用?C++ Asset::ConditionalFinalizeLoad使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Asset的用法示例。


在下文中一共展示了Asset::ConditionalFinalizeLoad方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: TickCacheLoad

/// Tick the async loading of binary serialized data from the object cache for the given load request.
///
/// @param[in] pRequest  Load request.
///
/// @return  True if the cache load process has completed, false if it still requires processing.
bool CachePackageLoader::TickCacheLoad( LoadRequest* pRequest )
{
	HELIUM_ASSERT( pRequest );
	HELIUM_ASSERT( !( pRequest->flags & LOAD_FLAG_PRELOADED ) );

	AsyncLoader* pAsyncLoader = AsyncLoader::GetInstance();
	HELIUM_ASSERT( pAsyncLoader );

	size_t bytesRead = 0;
	if( !pAsyncLoader->TrySyncRequest( pRequest->asyncLoadId, bytesRead ) )
	{
		return false;
	}

	SetInvalid( pRequest->asyncLoadId );

	if( bytesRead == 0 || IsInvalid( bytesRead ) )
	{
		HELIUM_ASSERT( pRequest->pEntry );

		HELIUM_TRACE(
			TraceLevels::Error,
			"CachePackageLoader: Failed to read cache data for object \"%s\".\n",
			*pRequest->pEntry->path.ToString() );
	}
	else
	{
		uint8_t* pBufferEnd = pRequest->pAsyncLoadBuffer + bytesRead;
		pRequest->pPropertyDataEnd = pBufferEnd;
		pRequest->pPersistentResourceDataEnd = pBufferEnd;

		if( ReadCacheData( pRequest ) )
		{
			return true;
		}
	}

	// An error occurred attempting to load the property data, so mark any existing object as fully loaded (nothing
	// else will be done with the object itself from here on out).
	DefaultAllocator().Free( pRequest->pAsyncLoadBuffer );
	pRequest->pAsyncLoadBuffer = NULL;

	Asset* pObject = pRequest->spObject;
	if( pObject )
	{
		pObject->SetFlags( Asset::FLAG_PRELOADED | Asset::FLAG_LINKED );
		pObject->ConditionalFinalizeLoad();
	}

	pRequest->flags |= LOAD_FLAG_PRELOADED | LOAD_FLAG_ERROR;

	return true;
}
开发者ID:HeliumProject,项目名称:Helium,代码行数:58,代码来源:CachePackageLoader.cpp

示例2: TickFinalizeLoad

/// Update loading finalization for the given object load request.
///
/// @param[in] pRequest  Load request to update.
///
/// @return  True if load finalization has completed, false if not.
bool AssetLoader::TickFinalizeLoad( LoadRequest* pRequest )
{
	HELIUM_ASSERT( pRequest );

	Asset* pObject = pRequest->spObject;
	if( pObject )
	{
		pObject->ConditionalFinalizeLoad();
	}

	// Loading now complete.
	OnLoadComplete( pRequest->path, pObject, pRequest->pPackageLoader );
	AtomicOrRelease( pRequest->stateFlags, LOAD_FLAG_LOADED );

	return true;
}
开发者ID:kevindqc,项目名称:Helium,代码行数:21,代码来源:AssetLoader.cpp

示例3: TickDeserialize

/// Update processing of object property preloading for a given load request.
///
/// @param[in] pRequest  Load request to process.
///
/// @return  True if object property preloading for the given load request has completed, false if not.
bool LoosePackageLoader::TickDeserialize( LoadRequest* pRequest )
{
	HELIUM_ASSERT( pRequest );
	HELIUM_ASSERT( !( pRequest->flags & LOAD_FLAG_PROPERTY_PRELOADED ) );

	Asset* pObject = pRequest->spObject;

	HELIUM_ASSERT( pRequest->index < m_objects.GetSize() );
	SerializedObjectData& rObjectData = m_objects[ pRequest->index ];

	// Wait for the template and owner objects to load.
	AssetLoader* pAssetLoader = AssetLoader::GetStaticInstance();
	HELIUM_ASSERT( pAssetLoader );

	if( !rObjectData.templatePath.IsEmpty() )
	{
		if( IsValid( pRequest->templateLoadId ) )
		{
			if( !pAssetLoader->TryFinishLoad( pRequest->templateLoadId, pRequest->spTemplate ) )
			{
				return false;
			}

			SetInvalid( pRequest->templateLoadId );
		}

		if( !pRequest->spTemplate )
		{
			HELIUM_TRACE(
				TraceLevels::Error,
				TXT( "LoosePackageLoader: Failed to load template object for \"%s\".\n" ),
				*rObjectData.objectPath.ToString() );

			if( pObject )
			{
				pObject->SetFlags( Asset::FLAG_PRELOADED | Asset::FLAG_LINKED );
				pObject->ConditionalFinalizeLoad();
			}

			pRequest->flags |= LOAD_FLAG_PRELOADED | LOAD_FLAG_ERROR;

			return true;
		}
	}

	HELIUM_ASSERT( IsInvalid( pRequest->templateLoadId ) );
	Asset* pTemplate = pRequest->spTemplate;

	AssetPath ownerPath = rObjectData.objectPath.GetParent();
	if( !ownerPath.IsEmpty() )
	{
		if( IsValid( pRequest->ownerLoadId ) )
		{
			if( !pAssetLoader->TryFinishLoad( pRequest->ownerLoadId, pRequest->spOwner ) )
			{
				return false;
			}

			SetInvalid( pRequest->ownerLoadId );
		}

		if( !pRequest->spOwner )
		{
			HELIUM_TRACE(
				TraceLevels::Error,
				TXT( "LoosePackageLoader: Failed to load owner object for \"%s\".\n" ),
				*rObjectData.objectPath.ToString() );

			if( pObject )
			{
				pObject->SetFlags( Asset::FLAG_PRELOADED | Asset::FLAG_LINKED );
				pObject->ConditionalFinalizeLoad();
			}

			pRequest->flags |= LOAD_FLAG_PRELOADED | LOAD_FLAG_ERROR;

			return true;
		}
	}

	HELIUM_ASSERT( IsInvalid( pRequest->ownerLoadId ) );
	Asset* pOwner = pRequest->spOwner;

	AssetType* pType = pRequest->spType;
	HELIUM_ASSERT( pType );

	HELIUM_ASSERT( !pOwner || pOwner->IsFullyLoaded() );
	HELIUM_ASSERT( !pTemplate || pTemplate->IsFullyLoaded() );

	AsyncLoader& rAsyncLoader = AsyncLoader::GetStaticInstance();
	FilePath object_file_path = m_packageDirPath + *rObjectData.objectPath.GetName() + TXT( "." ) + Persist::ArchiveExtensions[ Persist::ArchiveTypes::Json ];

	bool load_properties_from_file = true;
	size_t object_file_size = 0;
	if ( !IsValid( pRequest->asyncFileLoadId ) )
//.........这里部分代码省略.........
开发者ID:James-Z,项目名称:Helium,代码行数:101,代码来源:LoosePackageLoader.cpp

示例4: 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,
//.........这里部分代码省略.........
开发者ID:HeliumProject,项目名称:Helium,代码行数:101,代码来源:CachePackageLoader.cpp


注:本文中的Asset::ConditionalFinalizeLoad方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。