本文整理汇总了C++中Operation::getParents方法的典型用法代码示例。如果您正苦于以下问题:C++ Operation::getParents方法的具体用法?C++ Operation::getParents怎么用?C++ Operation::getParents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Operation
的用法示例。
在下文中一共展示了Operation::getParents方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_external_op_puppet_nonexistant
void TrustedConnectionCreatorintegration::test_external_op_puppet_nonexistant()
{
// 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(compose("%1", m_id_counter++));
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_Link_send_sent.isValid());
ASSERT_EQUAL(m_Link_send_sent->getParents().front(),
"unseen");
ASSERT_TRUE(!m_Link_send_sent->isDefaultTo());
ASSERT_EQUAL(m_Link_send_sent->getTo(), m_creator->getId());
}
示例2: 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);
}
示例3: operation
void Flusher::operation(const Operation & op, OpVector & res)
{
shared_ptr<ObjectContext> flush_context = m_context.lock();
if (!flush_context) {
m_complete = true;
return;
}
if (op->getClassNo() == Atlas::Objects::Operation::SIGHT_NO) {
// We have a sight op, check if its the sight of an entity we
// want to delete.
const std::vector<Root> & args = op->getArgs();
if (args.empty()) {
std::cerr << "Got empty sight" << std::endl << std::flush;
return;
}
const Root & arg = args.front();
assert(arg.isValid());
RootEntity sight_ent = smart_dynamic_cast<RootEntity>(arg);
if (!sight_ent.isValid()) {
return;
}
if (!sight_ent->hasAttrFlag(Atlas::Objects::ID_FLAG)) {
std::cerr << "Got sight no ID" << std::endl << std::flush;
return;
}
if (!sight_ent->hasAttrFlag(Atlas::Objects::PARENTS_FLAG)) {
std::cerr << "Got sight no PARENTS" << std::endl << std::flush;
return;
}
if (sight_ent->getParents().empty() ||
sight_ent->getParents().front() != type) {
return;
}
const std::string & id = sight_ent->getId();
std::cout << "Deleting: " << type << "(" << id << ")"
<< std::endl << std::flush;
// Send a delete to the entity we have seen.
Delete d;
Anonymous dmap;
dmap->setId(id);
d->setArgs1(dmap);
flush_context->setFromContext(d);
d->setTo(id);
res.push_back(d);
// Send a tick for a short time in the future so that
// we can look again once this entity is definitly gone.
Tick t;
Anonymous tick_arg;
tick_arg->setName("flusher");
flush_context->setFromContext(t);
t->setTo(t->getFrom());
t->setFutureSeconds(0.1);
t->setArgs1(tick_arg);
res.push_back(t);
} else if (op->getParents().front() == "tick") {
// We have a tick op, check if its the one we sent ourselves
// to schedule the next look.
if (op->getArgs().empty() ||
op->getArgs().front()->getName() != "flusher") {
std::cout << "Not for us" << std::endl << std::flush;
return;
}
// Send another look by type.
Look l;
Anonymous lmap;
lmap->setParents(std::list<std::string>(1, type));
l->setArgs1(lmap);
flush_context->setFromContext(l);
res.push_back(l);
} else if (op->getParents().front() == "unseen") {
// We have an unseen op, which signals our last look returned
// no results.
m_complete = true;
}
}
示例4: operation
void OperationMonitor::operation(const Operation & op, OpVector &) {
++op_count;
std::cout << op->getParents().front() << "(from=\"" << op->getFrom()
<< "\",to=\"" << op->getTo() << "\")"
<< std::endl << std::flush;
}