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


C++ Element::isNone方法代码示例

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


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

示例1: test_sequence

void Tasktest::test_sequence()
{
    m_task->nextTick(1.5);

    Atlas::Message::Element val;
    m_task->getAttr("foo", val);
    assert(val.isNone());
    m_task->setAttr("foo", 1);
    m_task->getAttr("foo", val);
    assert(val.isInt());

    assert(!m_task->obsolete());

    OpVector res;

    assert(res.empty());

    Atlas::Objects::Operation::Generic c;
    c->setParents(std::list<std::string>(1, "generic"));

    m_task->initTask(c, res);

    Operation op;

    m_task->operation(op, res);

    m_task->irrelevant();

    assert(m_task->obsolete());
}
开发者ID:Arsakes,项目名称:cyphesis,代码行数:30,代码来源:Tasktest.cpp

示例2: main

int main()
{
    int ret = 0;

    Operation op;

    {
        Task * task;
        OpVector res;

        if (0) {
            task->TickOperation(op, res);
        }
    }

    Entity ent1("1", 1), ent2("2", 2);
    Character chr("3", 3);

    {
        Fell fell(chr, ent1, ent2);

        fell.nextTick(1.5);

        Atlas::Message::Element val;
        fell.getAttr("foo", val);
        assert(val.isNone());
        fell.setAttr("foo", 1);
        fell.getAttr("foo", val);
        assert(val.isInt());

        assert(!fell.obsolete());

        OpVector res;

        assert(res.empty());

        Atlas::Objects::Operation::Generic c;

        fell.initTask(c, res);

        assert(!res.empty());

        fell.TickOperation(op, res);

        fell.irrelevant();

        assert(fell.obsolete());
    }

    return ret;
}
开发者ID:erikogenvik,项目名称:cyphesis,代码行数:51,代码来源:Tasktest.cpp

示例3: wrap

Py::Object CyPy_Element::wrap(Atlas::Message::Element value)
{
    if (value.isNone()) {
        return Py::None();
    } else if (value.isString()) {
        return Py::String(value.String());
    } else if (value.isInt()) {
        return Py::Long(value.Int());
    } else if (value.isFloat()) {
        return Py::Float(value.Float());
    } else if (value.isList()) {
        return CyPy_ElementList::wrap(value.List());
    } else {
        return CyPy_ElementMap::wrap(value.Map());
    }
}
开发者ID:worldforge,项目名称:cyphesis,代码行数:16,代码来源:CyPy_Element.cpp

示例4: start

void EntityImporterBase::start(const std::string& filename)
{
    S_LOG_VERBOSE("Starting import from " << filename);
    auto factories = Atlas::Objects::Factories::instance();

    auto rootObj = loadFromFile(filename);

    if (!rootObj.isValid()) {
        EventCompleted.emit();
        return;
    }
    Atlas::Message::Element metaElem;
    Atlas::Message::Element entitiesElem;
    Atlas::Message::Element mindsElem;
    Atlas::Message::Element rulesElem;
    rootObj->copyAttr("meta", metaElem);
    rootObj->copyAttr("entities", entitiesElem);
    rootObj->copyAttr("minds", mindsElem);
    if (rootObj->copyAttr("rules", rulesElem) == 0) {
        if (!rulesElem.isList()) {
            S_LOG_WARNING("Rules element is not list.");
            EventCompleted.emit();
            return;
        } else {
            for (auto& ruleMessage : rulesElem.asList()) {
                if (ruleMessage.isMap()) {
                    auto object = factories->createObject(ruleMessage.asMap());
                    if (object.isValid()) {
                        if (!object->isDefaultId()) {
                            mPersistedRules.insert(std::make_pair(object->getId(), object));
                        }
                    }
                }
            }

        }
    }

    if (!entitiesElem.isNone() && !entitiesElem.isList()) {
        S_LOG_WARNING("Entities element is not list.");
        EventCompleted.emit();
        return;
    }
    if (!mindsElem.isNone() && !mindsElem.isList()) {
        S_LOG_WARNING("Minds element is not list.");
        EventCompleted.emit();
        return;
    }

    if (!entitiesElem.isNone()) {
        for (auto& entityMessage : entitiesElem.asList()) {
            if (entityMessage.isMap()) {
                auto& entityMap = entityMessage.asMap();
                auto object = factories->createObject(entityMap);
                if (object.isValid()) {
                    if (!object->isDefaultId()) {
                        registerEntityReferences(object->getId(), entityMap);
                        mPersistedEntities.insert(std::make_pair(object->getId(), object));
                    }
                }
            }
        }
    }

    //If we should resume the world, check if the world has a "suspended" property,
    //and disable it if so.
    if (mResumeWorld) {
        auto I = mPersistedEntities.find("0");
        if (I != mPersistedEntities.end()) {
            if (I->second->hasAttr("suspended")) {
                I->second->setAttr("suspended", 0);
                S_LOG_INFO("Resuming suspended world.");
            }
        }
    }
    if (!mindsElem.isNone()) {
        for (auto& mindMessage : mindsElem.asList()) {
            if (mindMessage.isMap()) {
                auto object = factories->createObject(mindMessage.asMap());
                if (object.isValid()) {
                    if (!object->isDefaultId()) {
                        mPersistedMinds.insert(std::make_pair(object->getId(), object));
                    }
                }
            }
        }
    }

    S_LOG_INFO("Starting loading of world. Number of entities: " << mPersistedEntities.size() << " Number of minds: " << mPersistedMinds.size() << " Number of rules: " << mPersistedRules.size());
    mStats.entitiesCount = static_cast<unsigned int>(mPersistedEntities.size());
    mStats.mindsCount = static_cast<unsigned int>(mPersistedMinds.size());
    mStats.rulesCount = static_cast<unsigned int>(mPersistedRules.size());

    EventProgress.emit();

    if (mPersistedRules.empty()) {
        startEntityWalking();
    } else {
        startRuleWalking();
    }
//.........这里部分代码省略.........
开发者ID:worldforge,项目名称:cyphesis,代码行数:101,代码来源:EntityImporterBase.cpp

示例5: getattro

Py::Object CyPy_Task::getattro(const Py::String& name)
{
    auto nameStr = name.as_string();
    if (nameStr == "usage") {
        return CyPy_UsageInstance::wrap(m_value->m_usageInstance);
    }
    if (nameStr == "actor") {
        return CyPy_LocatedEntity::wrap(m_value->m_usageInstance.actor);
    }
    if (nameStr == "tool") {
        return CyPy_LocatedEntity::wrap(m_value->m_usageInstance.tool);
    }
//    if (nameStr == "targets") {
//        Py::List list(m_value->m_usageInstance.targets.size());
//        for (size_t i = 0; i < m_value->m_usageInstance.targets.size(); ++i) {
//            list[i] = CyPy_EntityLocation::wrap(m_value->m_usageInstance.targets[i]);
//        }
//        return list;
//    }
//    if (nameStr == "consumed") {
//        Py::List list(m_value->m_usageInstance.consumed.size());
//        for (size_t i = 0; i < m_value->m_usageInstance.consumed.size(); ++i) {
//            list[i] = CyPy_EntityLocation::wrap(m_value->m_usageInstance.consumed[i]);
//        }
//        return list;
//    }
    if (nameStr == "definition") {
        return CyPy_Usage::wrap(m_value->m_usageInstance.definition);
    }
    if (nameStr == "op") {
        return CyPy_Operation::wrap(m_value->m_usageInstance.op);
    }


    if (nameStr == "progress") {
        return Py::Float(m_value->progress());
    }
    if (nameStr == "duration") {
        if (!m_value->m_duration) {
            return Py::None();
        }
        return Py::Float(*m_value->m_duration);
    }
    if (nameStr == "tick_interval") {
        if (!m_value->m_tick_interval) {
            return Py::None();
        }
        return Py::Float(*m_value->m_tick_interval);
    }
    if (nameStr == "name") {
        return Py::String(m_value->name());
    }
    Atlas::Message::Element val;
    if (m_value->getAttr(name, val) == 0) {
        if (val.isNone()) {
            return Py::None();
        } else {
            return CyPy_Element::wrap(val);
        }
    }

    return PythonExtensionBase::getattro(name);
}
开发者ID:worldforge,项目名称:cyphesis,代码行数:63,代码来源:CyPy_Task.cpp

示例6: main

int main(int argc, char ** argv)
{
    loadConfig(argc, argv);

    database_flag = false;

    init_python_api();

    int ret;

    {
        World e("1", 1);
        TestWorld test_world(e);
        Anonymous attributes;

        EntityBuilder::init(test_world);
        Ruleset::init();

        assert(Ruleset::instance() != 0);

        assert(EntityBuilder::instance() != 0);

        assert(EntityBuilder::instance()->newEntity("1", 1, "world", attributes) == 0);
        assert(EntityBuilder::instance()->newEntity("1", 1, "nonexistant", attributes) == 0);
        assert(EntityBuilder::instance()->newEntity("1", 1, "thing", attributes) != 0);

        Ruleset::del();
        assert(Ruleset::instance() == 0);
        EntityBuilder::del();
        assert(EntityBuilder::instance() == 0);
        Inheritance::clear();
    }

    {
        World e("1", 1);
        TestWorld test_world(e);
        Anonymous attributes;
        Atlas::Message::Element val;

        EntityBuilder::init(test_world);
        Ruleset::init();

        assert(Ruleset::instance() != 0);

        Entity * test_ent = EntityBuilder::instance()->newEntity("1", 1, "thing", attributes);
        assert(test_ent != 0);
        assert(!test_ent->getAttr("funky", val));
        assert(val.isNone());

        attributes->setAttr("funky", "true");

        test_ent = EntityBuilder::instance()->newEntity("1", 1, "thing", attributes);
        assert(test_ent != 0);
        assert(test_ent->getAttr("funky", val));
        assert(val.isString());
        assert(val.String() == "true");

        Ruleset::del();
        assert(Ruleset::instance() == 0);
        EntityBuilder::del();
        assert(EntityBuilder::instance() == 0);
        Inheritance::clear();
    }

    {
        // Create a test world.
        World e("1", 1);
        TestWorld test_world(e);
        Atlas::Message::Element val;

        // Instance of EntityBuilder with all protected methods exposed
        // for testing
        ExposedEntityBuilder * entity_factory = new ExposedEntityBuilder(test_world);
        // Instance of Ruleset with all protected methods exposed
        // for testing
        EntityBuilder * test_eb = EntityBuilder::instance();
        assert(test_eb == entity_factory);
        ExposedRuleset test_ruleset(test_eb);

        // Attributes for test entities being created
        Anonymous attributes;

        // Create an entity which is an instance of one of the core classes
        Entity * test_ent = test_eb->newEntity("1", 1, "thing", attributes);
        assert(test_ent != 0);
        // Check the created entity does not have the attribute values we
        // will be testing later
        assert(!test_ent->getAttr("funky", val));
        assert(val.isNone());

        // Set a test attribute
        attributes->setAttr("funky", "true");

        // Create another entity, and check that it has picked up the new
        // attribute value
        test_ent = test_eb->newEntity("1", 1, "thing", attributes);
        assert(test_ent != 0);
        assert(test_ent->getAttr("funky", val));
        assert(val.isString());
        assert(val.String() == "true");
//.........这里部分代码省略.........
开发者ID:erikogenvik,项目名称:cyphesis,代码行数:101,代码来源:Rulesetintegration.cpp


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