本文整理汇总了C++中ObjectBase::getKey方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectBase::getKey方法的具体用法?C++ ObjectBase::getKey怎么用?C++ ObjectBase::getKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectBase
的用法示例。
在下文中一共展示了ObjectBase::getKey方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadFromRecord
static bool LoadFromRecord(
typename TreeNodeField<C, T>::Type& fieldObject,
ObjectBase& object,
const Record& record,
const util::Env& env
){
assert(dynamic_cast<T*>(&object));
T& t(static_cast<T&>(object));
bool result(false);
if(record.isDefined(ComplexObjectFieldDefinition<C>::FIELDS[2].name))
{
size_t value(
record.getDefault<size_t>(
ComplexObjectFieldDefinition<C>::FIELDS[2].name,
0
) );
if(value != t.getRank())
{
result = true;
t.setRank(value);
}
}
if(record.isDefined(ComplexObjectFieldDefinition<C>::FIELDS[1].name))
{
util::RegistryKeyType up_id(
record.getDefault<util::RegistryKeyType>(
ComplexObjectFieldDefinition<C>::FIELDS[1].name,
0
) );
if(up_id > 0)
{
try
{
T* value(
env.getEditable<T>(up_id).get()
);
if(value != t.getParent(true))
{
t.setParent(env.getEditable<T>(up_id).get());
result = true;
}
}
catch(util::ObjectNotFoundException<T>&)
{
util::Log::GetInstance().warn(
"Data corrupted in on node " + boost::lexical_cast<std::string>(object.getKey()) +" : up node " +
boost::lexical_cast<std::string>(up_id) + " not found"
);
}
}
else
{
if( !t.isParentDefined() ||
t.getParent() != NULL
){
t.setParent(NULL);
result = true;
}
}
}
if(record.isDefined(ComplexObjectFieldDefinition<C>::FIELDS[0].name))
{
util::RegistryKeyType id(
record.getDefault<util::RegistryKeyType>(
ComplexObjectFieldDefinition<C>::FIELDS[0].name,
0
) );
if(id > 0)
{
try
{
typename T::RootType* value(env.getEditable<typename T::RootType>(id).get());
if(t.getRoot() != value)
{
t.setRoot(value);
result = true;
}
}
catch(util::ObjectNotFoundException<typename T::RootType>&)
{
util::Log::GetInstance().warn(
"Data corrupted in on node " + boost::lexical_cast<std::string>(object.getKey()) +" : root " +
boost::lexical_cast<std::string>(id) + " not found"
);
}
}
}
return result;
}