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


C++ DynamicArray::Push方法代码示例

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


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

示例1: TickDeserialize


//.........这里部分代码省略.........
	if (load_properties_from_file && !object_creation_failure)
	{
		// Sanity checks for file load, then success path
		HELIUM_ASSERT( bytesRead == pRequest->asyncFileLoadBufferSize );
		if( IsInvalid( bytesRead ) )
		{
			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 )
开发者ID:James-Z,项目名称:Helium,代码行数:67,代码来源:LoosePackageLoader.cpp

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


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