本文整理汇总了C++中ObjectType::get_parent方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectType::get_parent方法的具体用法?C++ ObjectType::get_parent怎么用?C++ ObjectType::get_parent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectType
的用法示例。
在下文中一共展示了ObjectType::get_parent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: result
/*!
\brief Serializes the ObjectType definitions in a RuntimeContext and stores the result
in a Config object.
\ingroup Runtime
\details Format of the returned Config object:
\code
<runtime>
<object-type name="String" parent="String"/>
</runtime>
\endcode
- \b object-type.name String containing the name of the ObjectType.
- \b object-type.parent String containing the name of the parent ObjectType.
- \b object-type.* Config data of the ObjectType.
\param[in] context Pointer to the RuntimeContext to serialize.
\return Returns a Config object containing the serialized ObjectType definitions in the
RuntimeContext.
*/
dmz::Config
dmz::runtime_object_types_to_config (RuntimeContext *context) {
RuntimeContextDefinitions *defs = (context ? context->get_definitions_context () : 0);
Config result (RuntimeName);
if (defs) {
defs->ref ();
const ObjectType RootObjectType = Definitions (context).get_root_object_type ();
HashTableHandleIterator it;
ObjectType *otype (0);
while (defs->objectHandleTable.get_next (it, otype)) {
if (RootObjectType != *otype) {
Config data ("object-type");
data.store_attribute ("name", otype->get_name ());
ObjectType parent = otype->get_parent ();
if (parent != RootObjectType) {
data.store_attribute ("parent", parent.get_name ());
}
data.add_children (otype->get_config ());
result.add_config (data);
}
}
defs->unref ();
}
return result;
}
示例2: test
//.........这里部分代码省略.........
newTestObject.is_of_type (anotherCaracal));
test.validate (
"test is_of_exact_type operator on a child type object",
!newTestObject.is_of_exact_type (shouldBeNothing) &&
!newTestObject.is_of_exact_type (anotherCat) &&
newTestObject.is_of_exact_type (anotherCaracal));
// test set_type
ObjectType anotherTestObject;
test.validate (
"test set_type (Name, context)",
newTestObject.set_type (CatName, context) &&
newTestObject.is_of_type (anotherCat) &&
newTestObject.is_of_exact_type (anotherCat));
anotherTestObject = shouldBeNothing;
test.validate (
"test set_type (Handle, context)",
newTestObject.set_type (anotherCaracal.get_handle (), context) &&
newTestObject.is_of_type (anotherCaracal) &&
newTestObject.is_of_exact_type (anotherCaracal));
test.validate (
"test get_name",
(newTestObject.get_name () == CaracalName));
test.validate (
"test get_handle",
(newTestObject.get_handle () == anotherCaracal.get_handle ()));
// get / become parent
ObjectType newKitty (CaracalName, context);
test.validate (
"test get_parent",
newKitty.get_parent () == anotherCat);
test.validate (
"test become_parent",
(newKitty == anotherCaracal) &&
newKitty.become_parent () &&
(newKitty == anotherCat));
// </validate accessor functions>
// ============================================================================ //
// <validate lookup functions>
String data;
anotherCaracal.get_config ().lookup_attribute ("info.texture", data);
test.validate (
"test lookup_attribute",
!data);
String data2, data3;
Config returnCaracalData;
test.validate (
"test lookup_config",
anotherCaracal.get_config ().lookup_all_config_merged ("info", returnCaracalData));
test.validate (
"test lookup_config->lookup_attribute -- success",
returnCaracalData.lookup_attribute ("ears", data2) &&
data2 == "awesome");
test.validate (
"test lookup_config->lookup_attribute -- failure",
!returnCaracalData.lookup_attribute ("howTo", data3) &&
!data3);