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


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

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


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

示例1: DeleteOperation

void World::DeleteOperation(const Operation & op, OpVector & res)
{
    //A delete operation with an argument sent to the world indicates that an
    //entity should be deleted forcefully (whereas a Delete operation sent to
    //an entity directly, which is the norm, always can be overridden by the entity).
    auto& args = op->getArgs();
    if (!args.empty()) {
        auto arg = args.front();
        if (!arg->isDefaultId()) {
            auto entity = BaseWorld::instance().getEntity(arg->getId());
            if (entity) {
                if (entity == this) {
                    Atlas::Message::Element force;
                    if (arg->copyAttr("force", force) == 0 && force.isInt() && force.asInt() == 1) {
                        clearWorld(res);
                    } else {
                        log(ERROR, "World::DeleteOperation cannot delete world unless 'force' flag is set.");
                    }
                } else {
                    BaseWorld::instance().delEntity(entity.get());
                }
            } else {
                log(NOTICE, String::compose("Tried to delete non existent entity with id %1", arg->getId()));
            }
        } else {
            log(ERROR, "World::DeleteOperation got delete op with arg but no id.");
        }
    } else {
        assert(m_location.m_parent == nullptr);
        // Deleting has no effect.
    }
}
开发者ID:worldforge,项目名称:cyphesis,代码行数:32,代码来源:World.cpp

示例2: processServer

void ServerInfo::processServer(const RootEntity &svr)
{
    Atlas::Message::Element element;

    if (!svr->copyAttr("ruleset", element) && element.isString()) {
        _ruleset = element.asString();
    } else {
        return;
    }

    _name = svr->getName();
    if (!svr->copyAttr("clients", element) && element.isInt()) {
        _clients = element.asInt();
    } else {
        return;
    }
    if (!svr->copyAttr("server", element) && element.isString()) {
        _server = element.asString();
    } else {
        return;
    }
    if (!svr->copyAttr("uptime", element) && element.isFloat()) {
        _uptime = element.asFloat();
    } else {
        return;
    }

    m_status = VALID;

    if (!svr->copyAttr("entities", element) && element.isInt()) {
        _entities = element.asInt();
    }
    
    if (!svr->copyAttr("version", element) && element.isString()) {
        m_version = element.asString();
    }
    
    if (!svr->copyAttr("builddate", element) && element.isString()) {
        m_buildDate = element.asString();
    }
}
开发者ID:danniellecandys,项目名称:eris,代码行数:41,代码来源:ServerInfo.cpp

示例3:

void Property<int>::set(const Atlas::Message::Element & e)
{
    if (e.isInt()) {
        this->m_data = e.asInt();
    }
}
开发者ID:9cat,项目名称:cyphesis,代码行数:6,代码来源:Planttest.cpp


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