当前位置: 首页>>代码示例>>C++>>正文


C++ TypeNode::setParent方法代码示例

本文整理汇总了C++中TypeNode::setParent方法的典型用法代码示例。如果您正苦于以下问题:C++ TypeNode::setParent方法的具体用法?C++ TypeNode::setParent怎么用?C++ TypeNode::setParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TypeNode的用法示例。


在下文中一共展示了TypeNode::setParent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: children

TypeNode * Inheritance::addChild(const Root & obj)
{
    const std::string & child = obj->getId();
    const std::string & parent = obj->getParents().front();
    if (atlasObjects.find(child) != atlasObjects.end()) {
        std::cerr << String::compose("Installing type \"%1\"(\"%2\") "
                                   "which was already installed",
                                   child, parent) << std::endl;
        return 0;
    }
    TypeNodeDict::iterator I = atlasObjects.find(parent);
    if (I == atlasObjects.end()) {
        std::cerr << String::compose("Installing type \"%1\" "
                                   "which has unknown parent \"%2\".",
                                   child, parent) << std::endl;
        return 0;
    }
    Element children(ListType(1, child));
    if (I->second->description()->copyAttr("children", children) == 0) {
        assert(children.isList());
        children.asList().push_back(child);
    }
    I->second->description()->setAttr("children", children);

    TypeNode * type = new TypeNode(child, obj);
    type->setParent(I->second);

    atlasObjects[child] = type;

    return type;
}
开发者ID:Arsakes,项目名称:cyphesis,代码行数:31,代码来源:EntityBuildertest.cpp

示例2: children

TypeNode * Inheritance::addChild(const Root & obj)
{
    const std::string & child = obj->getId();
    const std::string & parent = obj->getParents().front();
    assert(atlasObjects.find(child) == atlasObjects.end());

    TypeNodeDict::iterator I = atlasObjects.find(parent);
    assert(I != atlasObjects.end());

    Element children(ListType(1, child));
    if (I->second->description()->copyAttr("children", children) == 0) {
        assert(children.isList());
        children.asList().push_back(child);
    }
    I->second->description()->setAttr("children", children);

    TypeNode * type = new TypeNode(child, obj);
    type->setParent(I->second);

    atlasObjects[child] = type;

    return type;
}
开发者ID:cyclefusion,项目名称:cyphesis,代码行数:23,代码来源:Admintest.cpp

示例3: children

TypeNode * Inheritance::addChild(const Root & obj)
{
    assert(obj->getParents().size() > 0);
    const std::string & child = obj->getId();
    const std::string & parent = obj->getParents().front();
    TypeNodeDict::const_iterator I = atlasObjects.find(child);
    TypeNodeDict::const_iterator Iend = atlasObjects.end();
    if (I != Iend) {
        const TypeNode * existing = I->second->parent();
        log(ERROR, String::compose("Installing %1 \"%2\"(\"%3\") "
                                   "which was already installed as %4 (\"%5\")",
                                   obj->getObjtype(), child, parent,
                                   I->second->description()->getObjtype(),
                                   existing ? existing->name() : "NON"));
        return 0;
    }
    I = atlasObjects.find(parent);
    if (I == Iend) {
        log(ERROR, String::compose("Installing %1 \"%2\" "
                                   "which has unknown parent \"%3\".",
                                   obj->getObjtype(), child, parent));;
        return 0;
    }
    Element children(ListType(1, child));
    if (I->second->description()->copyAttr("children", children) == 0) {
        assert(children.isList());
        children.asList().push_back(child);
    }
    I->second->description()->setAttr("children", children);

    TypeNode * type = new TypeNode(child, obj);
    type->setParent(I->second);

    atlasObjects.insert(std::make_pair(child, type));

    return type;
}
开发者ID:9cat,项目名称:cyphesis,代码行数:37,代码来源:Inheritance.cpp

示例4: setup

    void setup()
    {
        m_inheritance = new Inheritance();
//Set up testing environment for Type/Soft properties
        m_b1 = new TestEntity("1", 1);
        add_entity(m_b1);

        m_thingType = new TypeNode("thing");
        types["thing"] = m_thingType;

        m_barrelType = new TypeNode("barrel");
        m_barrelType->setParent(m_thingType);
        types["barrel"] = m_barrelType;
        m_b1->setType(m_barrelType);
        m_b1->setProperty("mass", new SoftProperty(Element(30)));
        m_b1->setProperty("burn_speed", new SoftProperty(Element(0.3)));
        m_b1->setProperty("isVisible", new SoftProperty(Element(true)));

        m_b2 = new Entity("2", 2);
        add_entity(m_b2);
        m_b2->setProperty("mass", new SoftProperty(Element(20)));
        m_b2->setProperty("burn_speed", new SoftProperty(0.25));
        m_b2->setType(m_barrelType);
        m_b2->setProperty("isVisible", new SoftProperty(Element(false)));

        m_b3 = new Entity("3", 3);
        add_entity(m_b3);
        m_b3->setProperty("mass", new SoftProperty(Element(25)));
        m_b3->setProperty("burn_speed", new SoftProperty(Element(0.25)));
        m_b3->setType(m_barrelType);

        m_boulderType = new TypeNode("boulder");
        types["boulder"] = m_boulderType;
        m_bl1 = new Entity("4", 4);
        add_entity(m_bl1);
        m_bl1->setProperty("mass", new SoftProperty(Element(25)));
        m_bl1->setType(m_boulderType);

        SoftProperty* prop1 = new SoftProperty();
        prop1->set(std::vector<Element>{25.0, 20.0});
        m_bl1->setProperty("float_list", prop1);

        SoftProperty* list_prop2 = new SoftProperty();
        list_prop2->set(std::vector<Element>{"foo", "bar"});
        m_bl1->setProperty("string_list", list_prop2);

// Create an entity-related memory map
        Atlas::Message::MapType entity_memory_map{{"disposition", 25}};

        m_memory.emplace("1", entity_memory_map);

//b1 contains bl1 which contains b3
        m_b1_container = new LocatedEntitySet;
        m_b1_container->insert(m_bl1);
        m_bl1->m_location.m_parent = m_b1;
        m_b1->m_contains = m_b1_container;
        m_b1->test_setDomain(new TestDomain(*m_b1));

        m_bl1_container = new LocatedEntitySet;
        m_bl1_container->insert(m_b3);
        m_b3->m_location.m_parent = m_bl1;

        m_bl1->m_contains = m_bl1_container;

//Set up testing environment for Outfit property
        m_glovesType = new TypeNode("gloves");
        types["gloves"] = m_glovesType;
        m_bootsType = new TypeNode("boots");
        m_characterType = new TypeNode("character");
        types["character"] = m_characterType;
        TypeNode* m_clothType = new TypeNode("cloth");
        types["cloth"] = m_clothType;
        TypeNode* m_leatherType = new TypeNode("leather");

        m_glovesEntity = new Entity("5", 5);
        add_entity(m_glovesEntity);
        m_glovesEntity->setType(m_glovesType);
        m_glovesEntity->setProperty("color", new SoftProperty("brown"));
        m_glovesEntity->setProperty("mass", new SoftProperty(5));
        //Mark it with a "reach" so we can use it in the "can_reach ... with" tests
        auto reachProp = new Property<double>();
        reachProp->data() = 10.0f;
        m_glovesEntity->setProperty("reach", reachProp);

        m_bootsEntity = new Entity("6", 6);
        add_entity(m_bootsEntity);
        m_bootsEntity->setType(m_bootsType);
        m_bootsEntity->setProperty("color", new SoftProperty("black"));
        m_bootsEntity->setProperty("mass", new SoftProperty(10));


        m_cloth = new Entity("8", 8);
        add_entity(m_cloth);
        m_cloth->setType(m_clothType);
        m_cloth->setProperty("color", new SoftProperty("green"));

        m_leather = new Entity("9", 9);
        add_entity(m_leather);
        m_leather->setType(m_leatherType);
        m_leather->setProperty("color", new SoftProperty("pink"));
//.........这里部分代码省略.........
开发者ID:worldforge,项目名称:cyphesis,代码行数:101,代码来源:EntityFilterTest.cpp


注:本文中的TypeNode::setParent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。