本文整理汇总了C++中ObjectType::GetBaseTypes方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectType::GetBaseTypes方法的具体用法?C++ ObjectType::GetBaseTypes怎么用?C++ ObjectType::GetBaseTypes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectType
的用法示例。
在下文中一共展示了ObjectType::GetBaseTypes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadObject
static void ReadObject(void* object, void* source, const ObjectType& type, const DataNode& node)
{
for (auto baseType : type.GetBaseTypes())
{
const ObjectType* baseObjectType = dynamic_cast<const ObjectType*>(baseType.type);
if (!baseObjectType)
continue;
void* baseObject = (*baseType.dynamicCastUpFunc)(object);
void* baseSourceObject = (*baseType.dynamicCastUpFunc)(source);
ReadObject(baseObject, baseSourceObject, *baseObjectType, node);
}
for (auto field : type.GetFields())
{
if (!field->GetAttribute<SerializableAttribute>())
continue;
auto fldNode = node.GetNode(field->GetName());
if (fldNode)
{
if (field->GetType()->IsBasedOn(TypeOf(IObject)))
{
bool usedConverter = false;
for (auto conv : mDataConverters)
{
if (conv->IsConvertsType(field->GetType()))
{
conv->FromData(field->GetValuePtr(object), node);
usedConverter = true;
break;
}
}
if (usedConverter)
continue;
fldNode->GetValueDelta(*(IObject*)field->GetValuePtr(object),
*(IObject*)field->GetValuePtr(source));
}
else field->DeserializeFromObject(object, *fldNode);
}
else field->CopyValue(object, source);
}
}
示例2: WriteObject
static void WriteObject(void* object, const ObjectType& type, DataNode& node)
{
for (auto baseType : type.GetBaseTypes())
{
const ObjectType* baseObjectType = dynamic_cast<const ObjectType*>(baseType.type);
if (!baseObjectType)
continue;
void* baseObject = (*baseType.dynamicCastUpFunc)(object);
WriteObject(baseObject, *baseObjectType, node);
}
for (auto field : type.GetFields())
{
auto srlzAttribute = field->GetAttribute<SerializableAttribute>();
if (srlzAttribute)
field->SerializeFromObject(object, *node.AddNode(field->GetName()));
}
}