本文整理汇总了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 )
示例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;
//.........这里部分代码省略.........