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


C++ PropertyBase::apply方法代码示例

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


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

示例1: assert

PropertyBase * Entity::setAttr(const std::string & name, const Element & attr)
{
    PropertyBase * prop;
    // If it is an existing property, just update the value.
    PropertyDict::const_iterator I = m_properties.find(name);
    if (I != m_properties.end()) {
        prop = I->second;
        // Mark it as unclean
        prop->resetFlags(per_clean);
    } else {
        PropertyDict::const_iterator I;
        if (m_type != 0 &&
            (I = m_type->defaults().find(name)) != m_type->defaults().end()) {
            prop = I->second->copy();
        } else {
            // This is an entirely new property, not just a modifcation of
            // one in defaults, so we need to install it to this Entity.
            prop = PropertyManager::instance()->addProperty(name,
                                                            attr.getType());
            prop->install(this, name);
        }
        assert(prop != 0);
        m_properties[name] = prop;
    }

    prop->set(attr);
    // Allow the value to take effect.
    prop->apply(this);
    // Mark the Entity as unclean
    resetFlags(entity_clean);
    return prop;
}
开发者ID:cyclefusion,项目名称:cyphesis,代码行数:32,代码来源:Entity.cpp

示例2: setup

void StatisicsPropertyintegration::setup()
{
    m_char_type = new TypeNode("char_type");

    m_char_property = new StatisticsProperty;
    m_char_property->setFlags(flag_class);
    m_char_type->addProperty("char_prop", m_char_property);

    m_char1 = new Entity("1", 1);
    m_char1->setType(m_char_type);
    m_char_property->install(m_char1, "char_prop");
    m_char_property->apply(m_char1);

    m_char2 = new Entity("2", 2);
    m_char2->setType(m_char_type);
    m_char_property->install(m_char2, "char_prop");
    m_char_property->apply(m_char2);
}
开发者ID:9cat,项目名称:cyphesis,代码行数:18,代码来源:StatisticsPropertyintegration.cpp

示例3: add_properties

        Py::Object add_properties(const Py::Tuple& args)
        {
            auto ent = CyPy_Entity::value(args.front());

            PropertyBase * p = ent->setProperty("statistics", new StatisticsProperty);
            p->install(ent.get(), "statistics");
            p->apply(ent.get());
            ent->propertyApplied("statistics", *p);
            p = ent->setProperty("terrain", new TerrainProperty);
            p->install(ent.get(), "terrain");
            p->apply(ent.get());
            ent->propertyApplied("terrain", *p);
            p = ent->setProperty("line", new LineProperty);
            p->install(ent.get(), "line");
            p->apply(ent.get());
            ent->propertyApplied("line", *p);

            return Py::None();
        }
开发者ID:worldforge,项目名称:cyphesis,代码行数:19,代码来源:Py_PropertyTest.cpp

示例4:

static PyObject * add_properties(PyObject * self, PyEntity * o)
{
    if (!PyEntity_Check(o)) {
        PyErr_SetString(PyExc_TypeError, "Unknown Object type");
        return NULL;
    }

    Entity * ent = o->m_entity.e;
    
    PropertyBase * p = ent->setProperty("statistics", new StatisticsProperty);
    p->install(ent);
    p->apply(ent);
    p = ent->setProperty("terrain", new TerrainProperty);
    p->install(ent);
    p->apply(ent);
    p = ent->setProperty("line", new LineProperty);
    p->install(ent);
    p->apply(ent);

    Py_INCREF(Py_None);
    return Py_None;
}
开发者ID:anthonypesce,项目名称:cyphesis,代码行数:22,代码来源:Py_Propertytest.cpp

示例5: setup

void TerrainModPropertyintegration::setup()
{
    m_world = new Entity("0", 0);

    new TestWorld(*m_world);

    m_entity = new Entity("1", 1);
    m_entity->m_location.m_pos = Point3D(5.f, 5.f, 5.f);
    m_entity->m_location.m_loc = m_world;
    m_world->incRef();
    ASSERT_TRUE(m_entity->m_location.isValid());

    PropertyFactory<TerrainModProperty> terrainmod_property_factory;

    m_terrainProperty = new TerrainProperty;
    m_terrainProperty->install(m_world, "terrain");
    m_world->setProperty("terrain", m_terrainProperty);
    m_terrainProperty->apply(m_world);

    m_property = terrainmod_property_factory.newProperty();
    m_property->install(m_entity, "terrainmod");
    m_entity->setProperty("terrainmod", m_property);
    m_property->apply(m_entity);
}
开发者ID:cyclefusion,项目名称:cyphesis,代码行数:24,代码来源:TerrainModPropertyintegration.cpp

示例6: restorePropertiesRecursively

void StorageManager::restorePropertiesRecursively(LocatedEntity * ent)
{
    Database * db = Database::instance();
    PropertyManager * pm = PropertyManager::instance();
    DatabaseResult res = db->selectProperties(ent->getId());

    //Keep track of those properties that have been set on the instance, so we'll know what
    //type properties we should ignore.
    std::unordered_set<std::string> instanceProperties;

    DatabaseResult::const_iterator I = res.begin();
    DatabaseResult::const_iterator Iend = res.end();
    for (; I != Iend; ++I) {
        const std::string name = I.column("name");
        if (name.empty()) {
            log(ERROR, compose("No name column in property row for %1",
                               ent->getId()));
            continue;
        }
        const std::string val_string = I.column("value");
        if (name.empty()) {
            log(ERROR, compose("No value column in property row for %1,%2",
                               ent->getId(), name));
            continue;
        }
        MapType prop_data;
        db->decodeMessage(val_string, prop_data);
        MapType::const_iterator J = prop_data.find("val");
        if (J == prop_data.end()) {
            log(ERROR, compose("No property value data for %1:%2",
                               ent->getId(), name));
            continue;
        }
        assert(ent->getType() != 0);
        const Element & val = J->second;

        Element existingVal;
        if (ent->getAttr(name, existingVal) == 0) {
            if (existingVal == val) {
                //If the existing property, either on the instance or the type, is equal to the persisted one just skip it.
                continue;
            }
        }


        PropertyBase * prop = ent->modProperty(name);
        if (prop == nullptr) {
            prop = pm->addProperty(name, val.getType());
            prop->install(ent, name);
            //This transfers ownership of the property to the entity.
            ent->setProperty(name, prop);
        }

        //If we get to here the property either doesn't exists, or have a different value than the default or existing property.
        prop->set(val);
        prop->setFlags(per_clean | per_seen);
        prop->apply(ent);
        instanceProperties.insert(name);
    }

    if (ent->getType()) {
        for (auto& propIter : ent->getType()->defaults()) {
            if (!instanceProperties.count(propIter.first)) {
                PropertyBase * prop = propIter.second;
                // If a property is in the class it won't have been installed
                // as setAttr() checks
                prop->install(ent, propIter.first);
                // The property will have been applied if it has an overriden
                // value, so we only apply it the value is still default.
                prop->apply(ent);
            }
        }
    }


    //Now restore all properties of the child entities.
    if (ent->m_contains) {
        for (auto& childEntity : *ent->m_contains) {
            restorePropertiesRecursively(childEntity);
        }
    }

    //We must send a sight op to the entity informing it of itself before we send any thoughts.
    //Else the mind won't have any information about itself.
    {
        Atlas::Objects::Operation::Sight sight;
        sight->setTo(ent->getId());
        Atlas::Objects::Entity::Anonymous args;
        ent->addToEntity(args);
        sight->setArgs1(args);
        ent->sendWorld(sight);
    }
    //We should also send a sight op to the parent entity which owns the entity.
    //TODO: should this really be necessary or should we rely on other Sight functionality?
    if (ent->m_location.m_loc) {
        Atlas::Objects::Operation::Sight sight;
        sight->setTo(ent->m_location.m_loc->getId());
        Atlas::Objects::Entity::Anonymous args;
        ent->addToEntity(args);
        sight->setArgs1(args);
//.........这里部分代码省略.........
开发者ID:Arsakes,项目名称:cyphesis,代码行数:101,代码来源:StorageManager.cpp


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