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


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

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


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

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