本文整理汇总了C++中atlas::message::Element::asInt方法的典型用法代码示例。如果您正苦于以下问题:C++ Element::asInt方法的具体用法?C++ Element::asInt怎么用?C++ Element::asInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类atlas::message::Element
的用法示例。
在下文中一共展示了Element::asInt方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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.
}
}
示例2: processServer
void ServerInfo::processServer(const RootEntity &svr)
{
Atlas::Message::Element element;
if (!svr->copyAttr("ruleset", element) && element.isString()) {
_ruleset = element.asString();
} else {
return;
}
_name = svr->getName();
if (!svr->copyAttr("clients", element) && element.isInt()) {
_clients = element.asInt();
} else {
return;
}
if (!svr->copyAttr("server", element) && element.isString()) {
_server = element.asString();
} else {
return;
}
if (!svr->copyAttr("uptime", element) && element.isFloat()) {
_uptime = element.asFloat();
} else {
return;
}
m_status = VALID;
if (!svr->copyAttr("entities", element) && element.isInt()) {
_entities = element.asInt();
}
if (!svr->copyAttr("version", element) && element.isString()) {
m_version = element.asString();
}
if (!svr->copyAttr("builddate", element) && element.isString()) {
m_buildDate = element.asString();
}
}
示例3:
void Property<int>::set(const Atlas::Message::Element & e)
{
if (e.isInt()) {
this->m_data = e.asInt();
}
}