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


C++ Operation::getArgs方法代码示例

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


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

示例1: disappearanceArrived

void Interactive::disappearanceArrived(const Operation & op)
{
    if (m_accountId.empty()) {
        return;
    }
    if (m_accountId != op->getTo()) {
        // This is an IG op we are monitoring
        return;
    }
    if (op->getArgs().empty()) {
        return;
    }
    RootEntity ent = smart_dynamic_cast<RootEntity>(op->getArgs().front());
    if (!ent.isValid()) {
        std::cerr << "Got Disappearance of non-entity" << std::endl << std::flush;
        return;
    }
    if (!ent->hasAttrFlag(Atlas::Objects::ID_FLAG)) {
        std::cerr << "Got Disappearance of non-string ID" << std::endl << std::flush;
        return;
    }
    const std::string & id = ent->getId();
    std::cout << "Disappearance(id: " << id << ")";
    if (!ent->hasAttrFlag(Atlas::Objects::Entity::LOC_FLAG)) {
        std::cout << std::endl << std::flush;
        return;
    }
    const std::string & loc = ent->getLoc();
    std::cout << " in " << loc << std::endl;
    if (loc == "lobby") {
        std::cout << id << " has logged out." << std::endl;
    }
    std::cout << std::flush;
}
开发者ID:9cat,项目名称:cyphesis,代码行数:34,代码来源:Interactive.cpp

示例2: RelayOperation

void World::RelayOperation(const Operation & op, OpVector & res)
{
    //A Relay operation with refno sent to ourselves signals that we should prune
    //our registered relays in m_relays. This is a feature to allow for a timeout; if
    //no Relay has been received from the destination Entity after a certain period
    //we'll shut down the relay link.
    if (op->getTo() == getId() && op->getFrom() == getId() && !op->isDefaultRefno()) {
        auto I = m_relays.find(op->getRefno());
        if (I != m_relays.end()) {

            //Send an empty operation to signal that the relay has expired.
            I->second.callback(Operation(), I->second.entityId);
            m_relays.erase(I);
        }
    } else {
        if (op->getArgs().empty()) {
            log(ERROR, "World::RelayOperation no args.");
            return;
        }
        Operation relayedOp = Atlas::Objects::smart_dynamic_cast<Operation>(
                op->getArgs().front());

        if (!relayedOp.isValid()) {
            log(ERROR,
                    "World::RelayOperation first arg is not an operation.");
            return;
        }


        //If a relay op has a refno, it's a response to a Relay op previously sent out to another
        //entity, and we should signal that we have an incoming relayed op.
        if (!op->isDefaultRefno()) {
            //Note that the relayed op should be considered untrusted in this case, as it has originated
            //from a random entity or its mind.
            auto I = m_relays.find(op->getRefno());
            if (I == m_relays.end()) {
                log(WARNING,
                        "World::RelayOperation could not find registrered Relay with refno.");
                return;
            }

            //Make sure that this op really comes from the entity the original Relay op was sent to.
            if (op->getFrom() != I->second.entityId) {
                log(WARNING,
                        "World::RelayOperation got relay op with mismatching 'from'.");
                return;
            }

            //Get the relayed operation and call the callback.
            I->second.callback(relayedOp, I->second.entityId);

            m_relays.erase(I);

        } else {
            //Send it on to the basic Entity relay mechanism
            Entity::RelayOperation(op, res);
        }
    }

}
开发者ID:worldforge,项目名称:cyphesis,代码行数:60,代码来源:World.cpp

示例3: infoArrived

void Interactive::infoArrived(const Operation & op)
{
    reply_flag = true;
    if (op->getArgs().empty()) {
        return;
    }
    const Root & ent = op->getArgs().front();
    if (m_server_flag) {
        std::cout << "Server query success" << std::endl << std::flush;
        if (!ent->isDefaultName()) {
            m_serverName = ent->getName();
            std::string::size_type p = m_serverName.find(".");
            if (p != std::string::npos) {
                m_serverName = m_serverName.substr(0, p);
            }
            updatePrompt();
        }
        Element raw_attr;
        if (ent->copyAttr("server", raw_attr) == 0) {
            if (raw_attr.isString()) {
                m_systemType = raw_attr.String();
                updatePrompt();
            }
        }
        m_server_flag = false;
    } else if (m_currentTask == 0 && op->isDefaultRefno()) {
        std::cout << "Info(" << std::endl;
        output(ent);
        std::cout << ")" << std::endl << std::flush;
        // Display results of command
    }
    AtlasStreamClient::infoArrived(op);
}
开发者ID:9cat,项目名称:cyphesis,代码行数:33,代码来源:Interactive.cpp

示例4: RelayOperation

/// \brief Handle a relay operation
void Entity::RelayOperation(const Operation & op, OpVector & res)
{
    if (op->getArgs().empty()) {
        log(ERROR, "Entity::RelayOperation no args.");
        return;
    }
    Operation relayedOp = Atlas::Objects::smart_dynamic_cast<Operation>(
            op->getArgs().front());

    if (!relayedOp.isValid()) {
        log(ERROR,
                "Entity::RelayOperation first arg is not an operation.");
        return;
    }

    if (op->isDefaultSerialno()) {
        log(ERROR, "Entity::RelayOperation no serial number.");
        return;
    }

    //Add a sight of the operation
    Sight sight;
    sight->setArgs1(relayedOp);

    Atlas::Objects::Operation::Generic responseOp;
    responseOp->setType("relay", Atlas::Objects::Operation::RELAY_NO);
    responseOp->setArgs1(sight);
    responseOp->setTo(op->getFrom());
    res.push_back(responseOp);

    //Make sure that the contained op is addressed to the entity
    relayedOp->setTo(getId());
    operation(relayedOp, res);

}
开发者ID:cyclefusion,项目名称:cyphesis,代码行数:36,代码来源:Entity.cpp

示例5: tick_handler

HandlerResult SpawnerProperty::tick_handler(LocatedEntity * e,
        const Operation & op, OpVector & res)
{
    if (!op->getArgs().empty()) {
        auto& arg = op->getArgs().front();
        if (arg->getName() == "spawner") {
            //This is our tick
            handleTick(e, op, res);
            return OPERATION_BLOCKED;
        }
    }
    return OPERATION_IGNORED;
}
开发者ID:Arsakes,项目名称:cyphesis,代码行数:13,代码来源:SpawnerProperty.cpp

示例6: customConnectOperation

void Juncture::customConnectOperation(const Operation & op, OpVector & res)
{
    log(INFO, "Juncture got connect");

    if (m_peer != 0) {
        error(op, "Juncture already connected", res, getId());
        return;
    }
    assert(m_socket == 0);

    const std::vector<Root> & args = op->getArgs();
    if (args.empty()) {
        error(op, "No argument to connect op", res, getId());
        return;
    }
    const Root & arg = args.front();
    Element hostname_attr;
    if (arg->copyAttr("hostname", hostname_attr) != 0 ||
        !hostname_attr.isString()) {
        error(op, "Argument to connect op has no hostname", res, getId());
        return;
    }
    const std::string & hostname = hostname_attr.String();

    Element port_attr;
    if (arg->copyAttr("port", port_attr) != 0 || !port_attr.isInt()) {
        error(op, "Argument to connect op has no port", res, getId());
        return;
    }
    int port = port_attr.Int();

    debug(std::cout << "Connecting to " << hostname << std::endl << std::flush;);
开发者ID:anthonypesce,项目名称:cyphesis,代码行数:32,代码来源:Juncture.cpp

示例7: 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

示例8: LogoutOperation

void Admin::LogoutOperation(const Operation & op, OpVector & res)
{
    const std::vector<Root> & args = op->getArgs();
    
    if (args.empty()) {
        Account::LogoutOperation(op, res);
        return;
    }

    const Root & arg = args.front();
    if (!arg->hasAttrFlag(Atlas::Objects::ID_FLAG)) {
        error(op, "No account id given on logout op", res, getId());
        return;
    }
    const std::string & account_id = arg->getId();
    if (account_id == getId()) {
        Account::LogoutOperation(op, res);
        return;
    }

    if (m_connection == NULL) {
        error(op,"Disconnected admin account handling explicit logout",res, getId());
        return;
    }

    Router * account = m_connection->m_server.getObject(account_id);
    if (!account) {
        error(op, "Logout failed", res, getId());
        return;
    }
    account->operation(op, res);
}
开发者ID:mrceresa,项目名称:cyphesis,代码行数:32,代码来源:Admin.cpp

示例9: tick_handler

HandlerResult DomainProperty::tick_handler(LocatedEntity * entity, const Operation & op, OpVector & res)
{
    if (!op->getArgs().empty() && op->getArgs().front()->getName() == "domain") {
        Domain* domain = sInstanceState.getState(entity);
        if (domain) {

            float timeNow = op->getSeconds();

            float timeForNextTick = domain->tick(timeNow, res);
            if (timeForNextTick > 0) {
                scheduleTick(*entity, timeForNextTick);
            }
        }
        return OPERATION_BLOCKED;
    }
    return OPERATION_IGNORED;
}
开发者ID:,项目名称:,代码行数:17,代码来源:

示例10: operation

void WaitForDeletionTask::operation(const Operation & op, OpVector & res)
{
    if (op->getClassNo() == Atlas::Objects::Operation::SIGHT_NO) {
        if (!op->getArgs().empty()) {
            auto& innerOp = op->getArgs().front();
            if (innerOp->getClassNo() == Atlas::Objects::Operation::DELETE_NO) {
                auto deleteOp = Atlas::Objects::smart_dynamic_cast<Operation>(innerOp);
                if (!deleteOp->getArgs().empty()) {
                    auto args = deleteOp->getArgs().front();
                    if (args->getId() == m_entityId) {
                        m_complete = true;
                    }
                }
            }
        }
    }
}
开发者ID:Arsakes,项目名称:cyphesis,代码行数:17,代码来源:WaitForDeletionTask.cpp

示例11: sightArrived

void EntityImporterBase::sightArrived(const Operation & op, OpVector & res)
{
    if (op->isDefaultArgs() || op->getArgs().empty()) {
        S_LOG_FAILURE("No arg");
        return;
    }
    const Root & arg = op->getArgs().front();
    switch (m_state) {
    case ENTITY_WALKSTART:
        if (op->isDefaultRefno()) {
            break;
        }
        if (arg->isDefaultId()) {
            S_LOG_WARNING("Corrupted top level entity: no id");
            cancel();
            return;
        } else {
            getEntity(arg->getId(), res);
        }


        // Expecting sight of world root
        break;
    case ENTITY_UPDATING:
    {
        const Operation& sub_op = smart_dynamic_cast<Operation>(arg);
        if (!sub_op.isValid()) {
            break;
        }
        if (sub_op->getClassNo() != Atlas::Objects::Operation::SET_NO || sub_op->getArgs().empty() || sub_op->isDefaultSerialno()) {
            S_LOG_FAILURE("This is not our entity update response.");
            break;
        }
        walkEntities(res);
    }
        break;
    case ENTITY_CREATING:
    case ENTITY_WALKING:
        //Just ignore sights when creating; these are sights of the actual creation ops.
        break;
    default:
        S_LOG_WARNING("Unexpected state in state machine: " << m_state);
        break;
    };
}
开发者ID:worldforge,项目名称:cyphesis,代码行数:45,代码来源:EntityImporterBase.cpp

示例12: operation

void RuleTraversalTask::operation(const Operation & op, OpVector & res)
{
    if (!op->isDefaultRefno() && op->getRefno() == mSerial) {
        if (op->getClassNo() == Atlas::Objects::Operation::INFO_NO) {
            if (!op->getArgs().empty()) {
                const auto& arg = op->getArgs().front();
                if (arg.isValid()) {
                    bool result = mVisitor(arg);
                    if (result) {
                        Element childrenElement;
                        if (arg->copyAttr("children", childrenElement) == 0 && childrenElement.isList() && !childrenElement.List().empty()) {
                            const ListType& childrenList = childrenElement.asList();
                            mStack.emplace_back();
                            for (auto& childElement : childrenList) {
                                if (childElement.isString()) {
                                    mStack.back().children.push_back(childElement.String());
                                }
                            }
                            mStack.back().currentChildIterator = mStack.back().children.begin();
                            getRule(*mStack.back().currentChildIterator, res);
                            return;
                        } else {
                            while (!mStack.empty()) {
                                StackEntry& stackEntry = mStack.back();
                                stackEntry.currentChildIterator++;
                                if (stackEntry.currentChildIterator == stackEntry.children.end()) {
                                    mStack.pop_back();
                                } else {
                                    getRule(*stackEntry.currentChildIterator, res);
                                    return;
                                }
                            }
                            m_complete = true;
                        }
                    } else {
                        m_complete = true;
                    }
                }
            }
        }
    }
}
开发者ID:olekw,项目名称:cyphesis,代码行数:42,代码来源:RuleTraversalTask.cpp

示例13: burn_handler

HandlerResult BurnSpeedProperty::burn_handler(LocatedEntity * e,
                                              const Operation & op,
                                              OpVector & res)
{
    if (op->getArgs().empty()) {
        e->error(op, "Fire op has no argument", res, e->getId());
        return OPERATION_IGNORED;
    }

    const double & burn_speed = data();
    const Root & fire_ent = op->getArgs().front();
    double consumed = burn_speed * fire_ent->getAttr("status").asNum();

    const std::string & to = fire_ent->getId();
    Anonymous nour_ent;
    nour_ent->setId(to);
    nour_ent->setAttr("mass", consumed);

    StatusProperty * status_prop = e->requirePropertyClass<StatusProperty>("status", 1.f);
    assert(status_prop != 0);
    status_prop->setFlags(flag_unsent);
    double & status = status_prop->data();

    Element mass_attr;
    if (e->getAttrType("mass", mass_attr, Element::TYPE_FLOAT) != 0) {
        mass_attr = 1.f;
    }
    status -= (consumed / mass_attr.Float());
    status_prop->apply(e);

    Update update;
    update->setTo(e->getId());
    res.push_back(update);

    Nourish n;
    n->setTo(to);
    n->setArgs1(nour_ent);

    res.push_back(n);

    return OPERATION_IGNORED;
}
开发者ID:Arsakes,项目名称:cyphesis,代码行数:42,代码来源:BurnSpeedProperty.cpp

示例14: SetOperation

void Admin::SetOperation(const Operation & op, OpVector & res)
{
    const std::vector<Root> & args = op->getArgs();
    if (args.empty()) {
        error(op, "Set has no args.", res, getId());
        return;
    }
    const Root & arg = args.front();
    if (!arg->hasAttrFlag(Atlas::Objects::OBJTYPE_FLAG)) {
        error(op, "Set arg has no objtype.", res, getId());
        return;
    }
    const std::string & objtype = arg->getObjtype();
    if (!arg->hasAttrFlag(Atlas::Objects::ID_FLAG)) {
        error(op, "Set arg has no id.", res, getId());
        return;
    }
    const std::string & id = arg->getId();

    if (objtype == "object" || objtype == "obj") {

        long intId = integerId(id);

        if (intId == getIntId()) {
            setAttribute(arg);
        } else {

            if (m_charactersDict.find(intId) != m_charactersDict.end()) {
                Account::SetOperation(op, res);
                return;
            }
            log(WARNING, "Unable to set attributes of non-character yet");
        }
        // Manipulate attributes of existing objects.
    } else if (objtype == "class" || objtype == "op_definition") {
        if (Inheritance::instance().hasClass(id)) {
            if (Ruleset::instance()->modifyRule(id, arg) == 0) {
                Info info;
                info->setTo(getId());
                info->setArgs1(arg);
                res.push_back(info);
            } else {
                error(op, "Updating type failed", res, getId());
            }
            return;
        }
        error(op, "Client attempting to use obsolete Set to install new type",
              res, getId());
        return;
    } else {
        error(op, "Unknow object type set", res, getId());
        return;
    }
}
开发者ID:Arsakes,项目名称:cyphesis,代码行数:54,代码来源:Admin.cpp

示例15: customMonitorOperation

/// \brief Process a Monitor operation
///
/// @param op The operation to be processed.
/// @param res The result of the operation is returned here.
void Admin::customMonitorOperation(const Operation & op, OpVector & res)
{
    if (!op->getArgs().empty()) {
        if (m_connection != 0) {
            if (!m_monitorConnection.connected()) {
                m_monitorConnection = m_connection->m_server.m_world.Dispatching.connect(sigc::mem_fun(this, &Admin::opDispatched));
            }
        }
    } else {
        if (m_monitorConnection.connected()) {
            m_monitorConnection.disconnect();
        }
    }
}
开发者ID:mrceresa,项目名称:cyphesis,代码行数:18,代码来源:Admin.cpp


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