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


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

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


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

示例1: updateEntity

void StorageManager::updateEntity(LocatedEntity * ent)
{
    std::string location;
    Atlas::Message::MapType map;
    map["pos"] = ent->m_location.pos().toAtlas();
    if (ent->m_location.orientation().isValid()) {
        map["orientation"] = ent->m_location.orientation().toAtlas();
    }
    Database::instance()->encodeObject(map, location);

    //Under normal circumstances only the top world won't have a location.
    if (ent->m_location.m_loc) {
        Database::instance()->updateEntity(ent->getId(),
                                       ent->getSeq(),
                                       location,
                                       ent->m_location.m_loc->getId());
    } else {
        Database::instance()->updateEntityWithoutLoc(ent->getId(),
                                       ent->getSeq(),
                                       location);
    }
    ++m_updateEntityCount;
    KeyValues new_property_tuples;
    KeyValues upd_property_tuples;
    const PropertyDict & properties = ent->getProperties();
    PropertyDict::const_iterator I = properties.begin();
    PropertyDict::const_iterator Iend = properties.end();
    for (; I != Iend; ++I) {
        PropertyBase * prop = I->second;
        if (prop->flags() & per_mask) {
            continue;
        }
        // FIXME check if this is new or just modded.
        if (prop->flags() & per_seen) {
            encodeProperty(prop, upd_property_tuples[I->first]);
            ++m_updatePropertyCount;
        } else {
            encodeProperty(prop, new_property_tuples[I->first]);
            ++m_insertPropertyCount;
        }
        prop->setFlags(per_clean | per_seen);
    }
    if (!new_property_tuples.empty()) {
        Database::instance()->insertProperties(ent->getId(),
                                               new_property_tuples);
    }
    if (!upd_property_tuples.empty()) {
        Database::instance()->updateProperties(ent->getId(),
                                               upd_property_tuples);
    }
    ent->setFlags(entity_clean);
}
开发者ID:Arsakes,项目名称:cyphesis,代码行数:52,代码来源:StorageManager.cpp

示例2: test_setAttr_new

void Entitytest::test_setAttr_new()
{
    ASSERT_TRUE(!m_TestProperty_install_called);

    PropertyBase * pb = m_entity->setAttr("test_int_property", 24);
    ASSERT_NOT_NULL(pb);

    ASSERT_TRUE((pb->flags() & flag_class) == 0);

    auto * int_property = dynamic_cast<TestProperty *>(pb);
    ASSERT_NOT_NULL(int_property);
    ASSERT_EQUAL(int_property->data(), 24);
    ASSERT_TRUE(m_TestProperty_install_called);
    ASSERT_TRUE(m_TestProperty_apply_called);
}
开发者ID:alriddoch,项目名称:cyphesis,代码行数:15,代码来源:Entitytest.cpp

示例3: test_setAttr_type

void Entitytest::test_setAttr_type()
{
    TestProperty * type_property = new TestProperty;
    type_property->data() = 17;
    type_property->flags() &= flag_class;
    m_type->addProperty("test_int_property", type_property);

    PropertyBase * pb = m_entity->setAttr("test_int_property", 24);
    ASSERT_NOT_NULL(pb);
    ASSERT_NOT_EQUAL(type_property, pb);

    ASSERT_TRUE((pb->flags() & flag_class) == 0);

    auto * int_property = dynamic_cast<TestProperty *>(pb);
    ASSERT_NOT_NULL(int_property);
    ASSERT_EQUAL(int_property->data(), 24);
    ASSERT_TRUE(!m_TestProperty_install_called);
    ASSERT_TRUE(m_TestProperty_apply_called);
}
开发者ID:alriddoch,项目名称:cyphesis,代码行数:19,代码来源:Entitytest.cpp

示例4: insertEntity

void StorageManager::insertEntity(LocatedEntity * ent)
{
    std::string location;
    Atlas::Message::MapType map;
    map["pos"] = ent->m_location.pos().toAtlas();
    if (ent->m_location.orientation().isValid()) {
        map["orientation"] = ent->m_location.orientation().toAtlas();
    }
    Database::instance()->encodeObject(map, location);

    Database::instance()->insertEntity(ent->getId(),
                                       ent->m_location.m_loc->getId(),
                                       ent->getType()->name(),
                                       ent->getSeq(),
                                       location);
    ++m_insertEntityCount;
    KeyValues property_tuples;
    const PropertyDict & properties = ent->getProperties();
    PropertyDict::const_iterator I = properties.begin();
    PropertyDict::const_iterator Iend = properties.end();
    for (; I != Iend; ++I) {
        PropertyBase * prop = I->second;
        if (prop->flags() & per_ephem) {
            continue;
        }
        encodeProperty(prop, property_tuples[I->first]);
        prop->setFlags(per_clean | per_seen);
    }
    if (!property_tuples.empty()) {
        Database::instance()->insertProperties(ent->getId(), property_tuples);
        ++m_insertPropertyCount;
    }
    ent->resetFlags(entity_queued);
    ent->setFlags(entity_clean | entity_pos_clean | entity_orient_clean);
    ent->updated.connect(sigc::bind(sigc::mem_fun(this, &StorageManager::entityUpdated), ent));
    ent->containered.connect(sigc::bind(sigc::mem_fun(this, &StorageManager::entityContainered), ent));

}
开发者ID:Arsakes,项目名称:cyphesis,代码行数:38,代码来源:StorageManager.cpp

示例5: main

int main()
{

    {
        // Test constructor
        PropertyBase * pb = new EntityProperty();
        delete pb;
    }

    {
        // Check constructor has set flags correctly to zero
        PropertyBase * pb = new EntityProperty;
        assert(pb->flags().m_flags == 0);
        delete pb;
    }

    {
        // Check getting the value fails when property is unassigned
        Element val;

        PropertyBase * pb = new EntityProperty;
        assert(pb->get(val) == -1);
        delete pb;
    }

    {
        // Check that setting the value to a pointer works
        Entity ent("1", 1);

        PropertyBase * pb = new EntityProperty;
        pb->set(Atlas::Message::Element(&ent));
        delete pb;
    }

    {
        // Check that setting the value to a pointer works can get retrieved
        Entity ent("1", 1);
        Element val;

        PropertyBase * pb = new EntityProperty;
        pb->set(Atlas::Message::Element(&ent));
        assert(pb->get(val) == 0);
        assert(val.isMap());
        assert(val.asMap().find("$eid")->second == ent.getId());
        delete pb;
    }

    {
        // Check that adding the uninitialised value to a message works.
        MapType map;
        static const std::string key = "foo";

        PropertyBase * pb = new EntityProperty;

        MapType::const_iterator I = map.find(key);
        assert(I == map.end());

        pb->add(key, map);

        I = map.find(key);
        assert(I != map.end());
        assert(I->second.isString());
        assert(I->second.String().empty());
        delete pb;
    }

    {
        // Check that adding the uninitialised value to an argument works.
        Anonymous arg;
        static const std::string key = "foo";
        Element val;

        PropertyBase * pb = new EntityProperty;

        assert(!arg->hasAttr(key));
        assert(arg->copyAttr(key, val) != 0);

        pb->add(key, arg);

        assert(arg->hasAttr(key));
        assert(arg->copyAttr(key, val) == 0);
        assert(val.isString());
        assert(val.String().empty());
        delete pb;
    }

    {
        // Check that adding the uninitialised value to an argument as a hard
        // attribute works
        Anonymous arg;
        static const std::string key = "id";
        Element val;

        PropertyBase * pb = new EntityProperty;

        assert(!arg->hasAttr(key));
        // Hard coded attribute ID has not been set, so returns false, but
        // copying it gives us the default
        assert(arg->copyAttr(key, val) == 0);
        assert(val.isString());
//.........这里部分代码省略.........
开发者ID:worldforge,项目名称:cyphesis,代码行数:101,代码来源:EntityPropertyTest.cpp

示例6: main

int main()
{
    // Assertions to verify the flags have the desired properties.
    assert((per_clean | per_mask) == per_mask);
    assert((per_ephem | per_mask) == per_mask);
    assert((per_ephem | per_clean) == per_mask);

    assert((per_clean & per_mask) == per_clean);
    assert((per_ephem & per_mask) == per_ephem);
    assert((per_ephem & per_clean) == 0);

    assert((vis_hidden | vis_mask) == vis_mask);
    assert((vis_internal | vis_mask) == vis_mask);
    assert((vis_internal | vis_hidden) == vis_mask);

    assert((vis_hidden & vis_mask) == vis_hidden);
    assert((vis_internal & vis_mask) == vis_internal);
    assert((vis_internal & vis_hidden) == 0);

    assert((vis_mask & per_mask) == 0);

    Element val;

    {
    PropertyBase * pb = new MinimalProperty;
    exerciseProperty(pb);
    delete pb;
    }

    {
    long i = 23;
    PropertyBase * pb = new SoftProperty;
    assert(pb->flags() == 0);
    pb->set(i);
    pb->get(val);
    assert(val == i);
    exerciseProperty(pb);
    delete pb;
    }

    {
    long i = 23;
    PropertyBase * pb = new SoftProperty(i);
    assert(pb->flags() == 0);
    pb->get(val);
    assert(val == i);
    exerciseProperty(pb);
    delete pb;
    }

    {
    long i = 23;
    PropertyBase * pb = new Property<int>(0);
    assert(pb->flags() == 0);
    pb->set(i);
    pb->get(val);
    assert(val == i);
    exerciseProperty(pb);
    delete pb;
    }

    {
    long i = 23;
    PropertyBase * pb = new Property<long>(0);
    assert(pb->flags() == 0);
    pb->set(i);
    pb->get(val);
    assert(val == i);
    exerciseProperty(pb);
    delete pb;
    }

    {
    float f = 17.2f;
    PropertyBase * pb = new Property<float>(1);
    assert(pb->flags() == 1);
    pb->set(f);
    pb->get(val);
    assert(val == f);
    exerciseProperty(pb);
    delete pb;
    }

    {
    double d = 65.4;
    PropertyBase * pb = new Property<double>(2);
    assert(pb->flags() == 2);
    pb->set(d);
    pb->get(val);
    assert(val == d);
    exerciseProperty(pb);
    delete pb;
    }

    {
    std::string s = "Test String";
    PropertyBase * pb = new Property<std::string>(3);
    assert(pb->flags() == 3);
    pb->set(s);
    pb->get(val);
//.........这里部分代码省略.........
开发者ID:erikogenvik,项目名称:cyphesis,代码行数:101,代码来源:Propertytest.cpp


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