本文整理汇总了C++中DataPtr::Set方法的典型用法代码示例。如果您正苦于以下问题:C++ DataPtr::Set方法的具体用法?C++ DataPtr::Set怎么用?C++ DataPtr::Set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataPtr
的用法示例。
在下文中一共展示了DataPtr::Set方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Copy
void Composite::Copy( void* source, void* destination ) const
{
if ( source != destination )
{
#pragma TODO("This should be inside a virtual function (like CopyTo) instead of a type check conditional")
if ( IsType( GetClass<Data>() ) )
{
Data* src = static_cast<Data*>(source);
Data* dest = static_cast<Data*>(destination);
dest->Set( src );
}
else
{
DynArray< Field >::ConstIterator itr = m_Fields.Begin();
DynArray< Field >::ConstIterator end = m_Fields.End();
for ( ; itr != end; ++itr )
{
const Field* field = &*itr;
// create data objects
DataPtr lhs = field->CreateData();
DataPtr rhs = field->CreateData();
// connnect
lhs->ConnectField(destination, field);
rhs->ConnectField(source, field);
// for normal data types, run overloaded assignement operator via data's vtable
// for reference container types, this deep copies containers (which is bad for
// non-cloneable (FieldFlags::Share) reference containers)
bool result = lhs->Set(rhs, field->m_Flags & FieldFlags::Share ? DataFlags::Shallow : 0);
HELIUM_ASSERT(result);
// disconnect
lhs->Disconnect();
rhs->Disconnect();
}
}
}
}