本文整理汇总了C++中Anonymous::setParents方法的典型用法代码示例。如果您正苦于以下问题:C++ Anonymous::setParents方法的具体用法?C++ Anonymous::setParents怎么用?C++ Anonymous::setParents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Anonymous
的用法示例。
在下文中一共展示了Anonymous::setParents方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_check_fail
// check() empty description
void PropertyRuleHandlertest::test_check_fail()
{
Anonymous description;
description->setParents(std::list<std::string>(1, "foo"));
int ret = rh->check(description);
assert(ret == -1);
}
示例2: test_check_pass
// check() description with op_definition objtype
void PropertyRuleHandlertest::test_check_pass()
{
Anonymous description;
description->setObjtype("type");
description->setParents(std::list<std::string>(1, "foo"));
int ret = rh->check(description);
assert(ret == 0);
}
示例3: run_operation_checks
void run_operation_checks(TestServerAccount * ac, Entity * chr, WorldRouter & world)
{
// Entity injection test
{
Anonymous ent;
// Add the test attributes
ent->setAttr("objtype", "obj");
ent->setAttr("name", "test_entity");
ent->setParents(std::list<std::string>(1,"thing"));
Create op;
OpVector res;
op->setArgs1(ent);
ac->operation(op, res);
Entity *reply = world.findByName("test_entity");
assert(reply != 0);
}
// Regular create op tests
{
// This is the only op we've overridden
Create op;
OpVector res;
ac->operation(op, res);
op->setArgs1(Root());
ac->operation(op, res);
Anonymous op_arg;
op->setArgs1(op_arg);
ac->operation(op, res);
op_arg->setParents(std::list<std::string>());
ac->operation(op, res);
op_arg->setParents(std::list<std::string>(1, "game_entity"));
ac->operation(op, res);
op_arg->setObjtype("obj");
ac->operation(op, res);
op_arg->setName("Bob");
ac->operation(op, res);
op_arg->setObjtype("class");
ac->operation(op, res);
op_arg->setId("game_entity");
ac->operation(op, res);
op_arg->setId("new_class");
ac->operation(op, res);
op_arg->setParents(std::list<std::string>(1, ""));
ac->operation(op, res);
op_arg->setParents(std::list<std::string>(1, "non_exist"));
ac->operation(op, res);
}
}
示例4: test_characterError_playable
void Playertest::test_characterError_playable()
{
Player::playableTypes.insert("settler");
Atlas::Objects::Operation::Create op;
Anonymous description;
description->setName("13e45264-e512-411b-9f8a-2e5cb6327c87");
description->setParents(std::list<std::string>(1, "settler"));
OpVector res;
int result = m_account->characterError(op, description, res);
ASSERT_EQUAL(result, 0);
ASSERT_EQUAL(res.size(), 0u);
}
示例5: test_characterError_no_name
void Playertest::test_characterError_no_name()
{
Player::playableTypes.insert("settler");
Atlas::Objects::Operation::Create op;
Anonymous description;
description->setParents(std::list<std::string>(1, "settler"));
OpVector res;
int result = m_account->characterError(op, description, res);
ASSERT_NOT_EQUAL(result, 0);
ASSERT_EQUAL(res.size(), 1u);
ASSERT_EQUAL(res.front()->getClassNo(),
Atlas::Objects::Operation::ERROR_NO);
}
示例6: create
int AtlasStreamClient::create(const std::string & type,
const std::string & username,
const std::string & password)
{
m_username = username;
Create c;
Anonymous account;
account->setAttr("username", username);
account->setAttr("password", password);
account->setParents(std::list<std::string>(1, type));
c->setArgs1(account);
c->setSerialno(newSerialNo());
send(c);
return waitForLoginResponse();
}
示例7: setup
void Flusher::setup(const std::string & arg, OpVector & ret)
{
shared_ptr<ObjectContext> flush_context = m_context.lock();
if (!flush_context) {
m_complete = true;
return;
}
type = arg;
m_description = String::compose("flushing %1", type);
// Send a look to search by type.
Look l;
Anonymous lmap;
lmap->setParents(std::list<std::string>(1, type));
l->setArgs1(lmap);
flush_context->setFromContext(l);
ret.push_back(l);
}
示例8: main
int main()
{
EntityBuilder::init();
{
RuleHandler * rh = new EntityRuleHandler(EntityBuilder::instance());
delete rh;
}
// check() not a class
{
RuleHandler * rh = new EntityRuleHandler(EntityBuilder::instance());
Anonymous description;
description->setParents(std::list<std::string>(1, "foo"));
int ret = rh->check(description);
assert(ret == -1);
delete rh;
}
// check() stub says it's a task
{
RuleHandler * rh = new EntityRuleHandler(EntityBuilder::instance());
stub_isTask_result = true;
Anonymous description;
description->setObjtype("class");
description->setParents(std::list<std::string>(1, "foo"));
int ret = rh->check(description);
assert(ret == -1);
stub_isTask_result = false;
delete rh;
}
// check() stub says it's not a task
{
RuleHandler * rh = new EntityRuleHandler(EntityBuilder::instance());
Anonymous description;
description->setObjtype("class");
description->setParents(std::list<std::string>(1, "foo"));
int ret = rh->check(description);
assert(ret == 0);
delete rh;
}
{
RuleHandler * rh = new EntityRuleHandler(EntityBuilder::instance());
Anonymous description;
description->setId("class_name");
std::string dependent, reason;
int ret = rh->install("class_name", "parent_name",
description, dependent, reason);
assert(ret == 1);
assert(dependent == "parent_name");
delete rh;
}
// Install a rule with addChild rigged to give a correct result
{
RuleHandler * rh = new EntityRuleHandler(EntityBuilder::instance());
Anonymous description;
description->setId("class_name");
std::string dependent, reason;
stub_addChild_result = (TypeNode *) malloc(sizeof(TypeNode));
int ret = rh->install("class_name", "parent_name",
description, dependent, reason);
assert(ret == 1);
assert(dependent == "parent_name");
free(stub_addChild_result);
stub_addChild_result = 0;
delete rh;
}
{
RuleHandler * rh = new EntityRuleHandler(EntityBuilder::instance());
Anonymous description;
int ret = rh->update("", description);
// FIXME Currently does nothing
assert(ret == -1);
delete rh;
//.........这里部分代码省略.........
示例9: 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;
}
}
示例10: exec
void Interactive::exec(const std::string & cmd, const std::string & arg)
{
bool reply_expected = true;
reply_flag = false;
error_flag = false;
boost::shared_ptr<ObjectContext> command_context = m_currentContext.lock();
if (!command_context) {
std::cout << "ERROR: Context free" << std::endl << std::flush;
return;
}
if (cmd == "stat") {
Get g;
send(g);
} else if (cmd == "install") {
size_t space = arg.find(' ');
if (space == std::string::npos || space >= (arg.size() - 1)) {
std::cout << "usage: install <type id> <parent id>"
<< std::endl << std::flush;
} else {
Create c;
c->setFrom(m_accountId);
Anonymous ent;
ent->setId(std::string(arg, 0, space));
ent->setObjtype("class");
ent->setParents(std::list<std::string>(1, std::string(arg, space + 1)));
c->setArgs1(ent);
send(c);
}
reply_expected = false;
} else if (cmd == "look") {
Look l;
if (!arg.empty()) {
Anonymous cmap;
cmap->setId(arg);
l->setArgs1(cmap);
}
l->setSerialno(newSerialNo());
command_context->setFromContext(l);
send(l);
reply_expected = false;
} else if (cmd == "logout") {
Logout l;
l->setFrom(m_accountId);
if (!arg.empty()) {
Anonymous lmap;
lmap->setId(arg);
l->setArgs1(lmap);
reply_expected = false;
}
send(l);
} else if (cmd == "say") {
Talk t;
Anonymous ent;
ent->setAttr("say", arg);
t->setArgs1(ent);
t->setFrom(m_accountId);
send(t);
} else if (cmd == "help" || cmd == "?") {
reply_expected = false;
help();
} else if (cmd == "query") {
Get g;
if (!arg.empty()) {
Anonymous cmap;
if (::isdigit(arg[0])) {
cmap->setObjtype("obj");
} else {
cmap->setObjtype("meta");
}
cmap->setId(arg);
g->setArgs1(cmap);
}
g->setFrom(m_accountId);
send(g);
} else if (cmd == "reload") {
if (arg.empty()) {
reply_expected = false;
std::cout << "reload: Argument required" << std::endl << std::flush;
} else {
Set s;
Anonymous tmap;
tmap->setObjtype("class");
tmap->setId(arg);
s->setArgs1(tmap);
s->setFrom(m_accountId);
send(s);
}
} else if (cmd == "get") {
Get g;
if (!arg.empty()) {
Anonymous cmap;
if (::isdigit(arg[0])) {
cmap->setObjtype("obj");
//.........这里部分代码省略.........
示例11: main
int main()
{
database_flag = false;
init_python_api();
WorldRouter world;
Entity & e = world.m_gameWorld;
Ruleset::init();
ServerRouting server(world, "noruleset", "unittesting",
"1", 1, "2", 2);
CommServer commServer(server);
TestCommClient * tc = new TestCommClient(commServer);
Connection * c = new Connection(*tc, server, "addr", "3", 3);
TestServerAccount * ac = new TestServerAccount(c, "user", "password", "4", 4);
Entity * chr;
Player * p = new Player(0, "bob", "bobspass", "8", 8);
server.addAccount(p);
{
chr = new Entity("5", 5);
chr->m_location.m_loc = &e;
chr->m_location.m_loc->makeContainer();
assert(chr->m_location.m_loc->m_contains != 0);
chr->m_location.m_loc->m_contains->insert(chr);
ac->addCharacter(chr);
chr->destroy();
}
{
chr = new Character("6", 6);
chr->m_location.m_loc = &e;
chr->m_location.m_loc->makeContainer();
assert(chr->m_location.m_loc->m_contains != 0);
chr->m_location.m_loc->m_contains->insert(chr);
ac->addCharacter(chr);
chr->destroy();
}
{
chr = new Character("7", 7);
chr->m_location.m_loc = &e;
chr->m_location.m_loc->makeContainer();
assert(chr->m_location.m_loc->m_contains != 0);
chr->m_location.m_loc->m_contains->insert(chr);
ac->addCharacter(chr);
}
{
Anonymous new_char;
ac->testAddNewCharacter("game_entity", new_char, RootEntity());
}
ac->getType();
{
MapType emap;
ac->addToMessage(emap);
}
{
RootEntity ent;
ac->addToEntity(ent);
}
{
Create op;
Anonymous ent;
OpVector res;
ac->testCharacterError(op, ent, res);
ent->setParents(std::list<std::string>(1, "game_entity"));
ac->testCharacterError(op, ent, res);
ent->setParents(std::list<std::string>());
ac->testCharacterError(op, ent, res);
}
run_operation_checks(ac, chr, world);
ac->m_connection = 0;
run_operation_checks(ac, chr, world);
delete ac;
shutdown_python_api();
return 0;
//.........这里部分代码省略.........