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


C++ Router::addToEntity方法代码示例

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


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

示例1: GetOperation

void Admin::GetOperation(const Operation & op, OpVector & res)
{
    const std::vector<Root> & args = op->getArgs();
    if (args.empty()) {
        error(op, "Get has no args.", res, getId());
        return;
    }
    const Root & arg = args.front();
    if (!arg->hasAttrFlag(Atlas::Objects::OBJTYPE_FLAG)) {
        error(op, "Get arg has no objtype.", res, getId());
        return;
    }
    const std::string & objtype = arg->getObjtype();
    if (!arg->hasAttrFlag(Atlas::Objects::ID_FLAG)) {
        error(op, "Get arg has no id.", res, getId());
        return;
    }
    const std::string & id = arg->getId();
    if (id.empty()) {
        error(op, "Get arg id empty", res, getId());
        return;
    }
    Info info;
    if (objtype == "object" || objtype == "obj") {
        if (m_connection == 0) {
            return;
        }
        long intId = integerId(id);

        const RouterMap & OOGDict = m_connection->m_server.getObjects();
        RouterMap::const_iterator J = OOGDict.find(intId);
        const EntityDict & worldDict = m_connection->m_server.m_world.getEntities();
        EntityDict::const_iterator K = worldDict.find(intId);

        if (J != OOGDict.end()) {
            Router * obj = J->second;
            Anonymous info_arg;
            obj->addToEntity(info_arg);
            info->setArgs1(info_arg);
        } else if (K != worldDict.end()) {
            Anonymous info_arg;
            K->second->addToEntity(info_arg);
            info->setArgs1(info_arg);
        } else {
            clientError(op, compose("Unknown object id \"%1\" requested", id),
                        res, getId());
            return;
        }
    } else if (objtype == "class" ||
               objtype == "meta" ||
               objtype == "op_definition") {
        const Root & o = Inheritance::instance().getClass(id);
        if (!o.isValid()) {
            clientError(op, compose("Unknown type definition for \"%1\" "
                                    "requested", id), res);
            return;
        }
        info->setArgs1(o);
    } else if (objtype == "op") {
        if (arg->getClassNo() == Atlas::Objects::Operation::THOUGHT_NO) {
            long intId = integerId(id);
            const EntityDict & worldDict = m_connection->m_server.m_world.getEntities();
            EntityDict::const_iterator K = worldDict.find(intId);

            if (K != worldDict.end()) {
                Character* character = dynamic_cast<Character*>(K->second);
                if (character) {
                    character->sendMind(op, res);
                } else {
                    clientError(op, compose("Entity with id \"%1\" is not a character", id),
                                res, getId());
                    return;
                }

                std::vector<Root> newRet;
                //Why can't I do "info->setArgs(res)"?
                for (auto& operation : res) {
                    newRet.push_back(operation);
                }
                info->setArgs(newRet);
                res.clear();
            } else {
                clientError(op, compose("Unknown object id \"%1\" requested", id),
                            res, getId());
                return;
            }
        } else if (arg->getClassNo() == Atlas::Objects::Operation::GOAL_INFO_NO) {
            long intId = integerId(id);
            const EntityDict & worldDict = m_connection->m_server.m_world.getEntities();
            EntityDict::const_iterator K = worldDict.find(intId);

            if (K != worldDict.end()) {
                Character* character = dynamic_cast<Character*>(K->second);
                if (character) {
                    character->sendMind(op, res);
                } else {
                    clientError(op, compose("Entity with id \"%1\" is not a character", id),
                                res, getId());
                    return;
                }
//.........这里部分代码省略.........
开发者ID:mrceresa,项目名称:cyphesis,代码行数:101,代码来源:Admin.cpp


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