本文整理汇总了C++中Operation::getClassNo方法的典型用法代码示例。如果您正苦于以下问题:C++ Operation::getClassNo方法的具体用法?C++ Operation::getClassNo怎么用?C++ Operation::getClassNo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Operation
的用法示例。
在下文中一共展示了Operation::getClassNo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: operation
void EntityImporterBase::operation(const Operation & op)
{
//std::cout << "Got op ==================" << std::endl;
//debug_dump(op, std::cout);
if (m_state == CANCEL) {
m_state = CANCELLED;
return;
}
if (m_state == CANCELLED) {
return;
}
OpVector res;
if (op->getClassNo() == Atlas::Objects::Operation::INFO_NO) {
infoArrived(op, res);
} else if (op->getClassNo() == Atlas::Objects::Operation::ERROR_NO) {
errorArrived(op, res);
} else if (op->getClassNo() == Atlas::Objects::Operation::SIGHT_NO) {
sightArrived(op, res);
}
for (auto& resOp : res) {
sendOperation(resOp);
}
}
示例2: operation
HandlerResult TerrainModProperty::operation(LocatedEntity * ent,
const Operation & op,
OpVector & res)
{
if (op->getClassNo() == Atlas::Objects::Operation::DELETE_NO) {
return delete_handler(ent, op, res);
} else if (op->getClassNo() == Atlas::Objects::Operation::MOVE_NO) {
return move_handler(ent, op, res);
}
return OPERATION_IGNORED;
}
示例3: test_external_op_puppet
void TrustedConnectionCreatorintegration::test_external_op_puppet()
{
// Dispatching a Talk external op from the creator, to the creator should
// result in it being passed directly to the normal op dispatch,
// shortcutting the world.
m_creator->m_externalMind = new ExternalMind(*m_creator);
m_creator->m_externalMind->linkUp(m_connection);
Entity * other = new Entity(compose("%1", m_id_counter), m_id_counter++);
other->setType(m_creatorType);
m_server->m_world.addEntity(other);
Atlas::Objects::Operation::Talk op;
op->setFrom(m_creator->getId());
op->setTo(other->getId());
m_connection->externalOperation(op, *m_connection);
// Operation should be via world dispatch, as if it was from the Entity
// we are puppeting.
ASSERT_TRUE(m_BaseWorld_message_called.isValid());
ASSERT_EQUAL(m_BaseWorld_message_called->getClassNo(),
Atlas::Objects::Operation::TALK_NO);
ASSERT_TRUE(!m_BaseWorld_message_called->isDefaultTo());
ASSERT_EQUAL(m_BaseWorld_message_called->getTo(), other->getId());
ASSERT_NOT_NULL(m_BaseWorld_message_called_from);
ASSERT_EQUAL(m_BaseWorld_message_called_from, other);
}
示例4: OtherOperation
void Juncture::OtherOperation(const Operation & op, OpVector & res)
{
const int op_type = op->getClassNo();
if (op_type == Atlas::Objects::Operation::CONNECT_NO) {
return customConnectOperation(op, res);
}
}
示例5: OtherOperation
void Admin::OtherOperation(const Operation & op, OpVector & res)
{
const int op_type = op->getClassNo();
if (op_type == Atlas::Objects::Operation::MONITOR_NO) {
return customMonitorOperation(op, res);
}
}
示例6: operation
void Entity::operation(const Operation & op, OpVector & res)
{
if (m_script != 0 &&
m_script->operation(op->getParents().front(), op, res) != 0) {
return;
}
auto J = m_delegates.equal_range(op->getClassNo());
HandlerResult hr = OPERATION_IGNORED;
for (;J.first != J.second; ++J.first) {
HandlerResult hr_call = callDelegate(J.first->second, op, res);
//We'll record the most blocking of the different results only.
if (hr != OPERATION_BLOCKED) {
if (hr_call != OPERATION_IGNORED) {
hr = hr_call;
}
}
// How to access the property? We need a non-const pointer to call
// operation, but to get this easily we need to force instantiation
// from the type dict, making properties way less efficient.
// Making the operation() method const strongly limits the usefulness
// of delegates, but if we fetch the pointer the hard way, we then
// require the method to handle instantiation on demand.
//
// Can we make a clean way to handle the property in the general case
// handle instantiation itself? Making it responsible for copying
// itself on instantiation would be faster than the
// get/set/PropertyManager currently required in in modProperty.
}
//If the operation was blocked we shouldn't send it on to the entity.
if (hr == OPERATION_BLOCKED) {
return;
}
return callOperation(op, res);
}
示例7: operation
void EntityImporterBase::operation(const Operation & op)
{
if (m_state == CANCEL) {
m_state = CANCELLED;
return;
}
if (m_state == CANCELLED) {
return;
}
OpVector res;
if (op->getClassNo() == Atlas::Objects::Operation::INFO_NO) {
infoArrived(op, res);
} else if (op->getClassNo() == Atlas::Objects::Operation::ERROR_NO) {
errorArrived(op, res);
} else if (op->getClassNo() == Atlas::Objects::Operation::SIGHT_NO) {
sightArrived(op, res);
}
for (auto& op : res) {
sendOperation(op);
}
}
示例8: operation
void Juncture::operation(const Operation & op, OpVector & res)
{
const OpNo op_no = op->getClassNo();
switch (op_no) {
case Atlas::Objects::Operation::LOGIN_NO:
LoginOperation(op, res);
break;
case OP_INVALID:
break;
default:
OtherOperation(op, res);
break;
}
}
示例9: 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;
}
}
}
}
}
}
示例10: 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;
}
}
}
}
}
}
示例11: operation
/// \brief Execute an operation sent by a connected peer
///
/// \param op The operation to be executed
/// \param res The result set of replies
void Peer::operation(const Operation &op, OpVector &res)
{
if (!op->isDefaultRefno()) {
replied.emit(op);
}
const OpNo op_no = op->getClassNo();
switch (op_no) {
case Atlas::Objects::Operation::INFO_NO:
{
// If we receive an Info op while we are not yet authenticated, it
// can only be the result of an authentication request.
if (m_state == PEER_AUTHENTICATING) {
const std::vector<Root> & args = op->getArgs();
if (args.empty()) {
return;
}
const Root & arg = args.front();
if (!arg->hasAttrFlag(Atlas::Objects::ID_FLAG)) {
return;
}
// Response to a Login op
m_accountId = arg->getId();
if (!arg->getParents().empty()) {
m_accountType = arg->getParents().front();
}
m_state = PEER_AUTHENTICATED;
} else if (m_state == PEER_AUTHENTICATED) {
// If we received an Info op while authenticated, it is a
// response to a teleport request.
peerTeleportResponse(op, res);
}
}
break;
case Atlas::Objects::Operation::ERROR_NO:
{
m_state = PEER_FAILED;
}
break;
}
}
示例12: test_external_op
void ConnectionCharacterintegration::test_external_op()
{
// Dispatching a Talk external op from the character should result in
// it being passed on to the world.
m_character->linkExternal(m_connection);
Atlas::Objects::Operation::Talk op;
op->setFrom(m_character->getId());
m_connection->externalOperation(op, *m_connection);
// BaseWorld::message should have been called from Enitty::sendWorld
// with the Talk operation, modified to have TO set to the character.
ASSERT_TRUE(m_BaseWorld_message_called.isValid());
ASSERT_EQUAL(m_BaseWorld_message_called->getClassNo(),
Atlas::Objects::Operation::TALK_NO);
ASSERT_TRUE(!m_BaseWorld_message_called->isDefaultTo());
ASSERT_EQUAL(m_BaseWorld_message_called->getTo(), m_character->getId());
ASSERT_NOT_NULL(m_BaseWorld_message_called_from);
ASSERT_EQUAL(m_BaseWorld_message_called_from, m_character);
}
示例13: test_connect_up
void ConnectionCharacterintegration::test_connect_up()
{
// Dispatching an external op from the character should cause it to
// get connected up with an external mind
RootOperation op;
op->setFrom(m_character->getId());
ASSERT_NULL(m_character->m_externalMind);
m_connection->externalOperation(op, *m_connection);
ASSERT_NOT_NULL(m_character->m_externalMind);
ExternalMind * em =
dynamic_cast<ExternalMind*>(m_character->m_externalMind);
ASSERT_NOT_NULL(em);
ASSERT_TRUE(em->isLinked());
ASSERT_TRUE(em->isLinkedTo(m_connection));
ASSERT_TRUE(m_Link_send_sent.isValid());
ASSERT_EQUAL(m_Link_send_sent->getClassNo(),
Atlas::Objects::Operation::INFO_NO);
ASSERT_EQUAL(m_logEvent_logged, TAKE_CHAR);
}
示例14: test_external_op_override
void TrustedConnectionCreatorintegration::test_external_op_override()
{
// Dispatching a Talk external op from the creator should result in
// it being passed on to the world, exactly as if this was a Character
// except that we assume that Creator was set up linked.
m_creator->m_externalMind = new ExternalMind(*m_creator);
m_creator->m_externalMind->linkUp(m_connection);
Atlas::Objects::Operation::Talk op;
op->setFrom(m_creator->getId());
op->setTo(m_creator->getId());
m_connection->externalOperation(op, *m_connection);
// The operation should have been passed to Entity::callOperation for
// dispatch, completely unfiltered.
ASSERT_TRUE(m_Entity_callOperation_called.isValid());
ASSERT_EQUAL(m_Entity_callOperation_called->getClassNo(),
Atlas::Objects::Operation::TALK_NO);
ASSERT_TRUE(!m_Entity_callOperation_called->isDefaultTo());
ASSERT_EQUAL(m_Entity_callOperation_called->getTo(), m_creator->getId());
}
示例15: send
void Link::send(const Operation & op) const
{
stub_link_send_op = op->getClassNo();
++stub_link_send_count;
}