本文整理汇总了C++中atlas::message::Element::isString方法的典型用法代码示例。如果您正苦于以下问题:C++ Element::isString方法的具体用法?C++ Element::isString怎么用?C++ Element::isString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类atlas::message::Element
的用法示例。
在下文中一共展示了Element::isString方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processServer
void ServerInfo::processServer(const RootEntity &svr)
{
Atlas::Message::Element element;
if (!svr->copyAttr("ruleset", element) && element.isString()) {
_ruleset = element.String();
} else {
return;
}
_name = svr->getName();
if (!svr->copyAttr("clients", element) && element.isInt()) {
_clients = (int)element.Int();
} else {
return;
}
if (!svr->copyAttr("server", element) && element.isString()) {
_server = element.String();
} else {
return;
}
if (!svr->copyAttr("uptime", element) && element.isFloat()) {
_uptime = element.Float();
} else {
return;
}
m_status = VALID;
if (!svr->copyAttr("entities", element) && element.isInt()) {
_entities = element.Int();
}
if (!svr->copyAttr("version", element) && element.isString()) {
m_version = element.String();
}
if (!svr->copyAttr("builddate", element) && element.isString()) {
m_buildDate = element.String();
}
if (!svr->copyAttr("assets", element) && element.isList()) {
for (auto& url : element.List()) {
if (url.isString()) {
m_assets.emplace_back(url.String());
}
}
}
}
示例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: updateGui
void StaticAdapter::updateGui(const ::Atlas::Message::Element& element)
{
SelfUpdateContext context(*this);
if (mTextWindow) {
if (element.isString()) {
mTextWindow->setText(element.asString());
} else if (element.isNum()) {
std::stringstream ss;
ss << element.asNum();
mTextWindow->setText(ss.str());
}
}
}
示例4: onImaginary
void EmberEntity::onImaginary(const Atlas::Objects::Root& act)
{
Atlas::Message::Element attr;
if (act->copyAttr("description", attr) && attr.isString()) {
std::string message = getName() + " " + attr.asString() + ".";
ConsoleBackend::getSingletonPtr()->pushMessage(message, "info");
S_LOG_VERBOSE("Entity: " << this->getId() << " (" << this->getName() << ") imaginary: " << attr.String());
}
Entity::onImaginary(act);
}
示例5: set
void EntityProperty::set(const Atlas::Message::Element & val)
{
// INT id?
if (val.isString()) {
const std::string & id = val.String();
if (m_data.get() == 0 || m_data->getId() != id) {
debug(std::cout << "Assigning " << id << std::endl << std::flush;);
if (id.empty()) {
m_data = EntityRef(0);
} else {
LocatedEntity * e = BaseWorld::instance().getEntity(id);
if (e != 0) {
debug(std::cout << "Assigned" << std::endl << std::flush;);
m_data = EntityRef(e);
}
示例6: wrap
Py::Object CyPy_Element::wrap(Atlas::Message::Element value)
{
if (value.isNone()) {
return Py::None();
} else if (value.isString()) {
return Py::String(value.String());
} else if (value.isInt()) {
return Py::Long(value.Int());
} else if (value.isFloat()) {
return Py::Float(value.Float());
} else if (value.isList()) {
return CyPy_ElementList::wrap(value.List());
} else {
return CyPy_ElementMap::wrap(value.Map());
}
}
示例7:
void Property<std::string>::set(const Atlas::Message::Element & e)
{
if (e.isString()) {
this->m_data = e.String();
}
}
示例8: errorArrived
void EntityImporterBase::errorArrived(const Operation & op, OpVector & res)
{
std::string errorMessage;
if (!op->getArgs().empty()) {
auto arg = op->getArgs().front();
if (arg->hasAttr("message")) {
const Atlas::Message::Element messageElem = arg->getAttr("message");
if (messageElem.isString()) {
errorMessage = messageElem.asString();
}
}
}
switch (m_state) {
case RULE_WALKING:
{
//An error here just means that the rule we asked for didn't exist on the server, and we need
//to create it. This is an expected result.
auto& current = mRuleStack.back();
auto definition = current.definition;
assert(definition.isValid());
createRule(definition, res);
}
break;
case RULE_CREATING:
{
mStats.rulesProcessedCount++;
mStats.rulesCreateErrorCount++;
//An error here means that something went wrong when trying to create a rule. This is wrong.
//It probably means that there's something wrong with the data we're sending.
auto& current = mRuleStack.back();
std::string ruleId = current.definition->getId();
S_LOG_FAILURE("Could not create rule with id '" << ruleId << "', continuing with next. Server message: " << errorMessage);
EventProgress.emit();
walkRules(res);
}
break;
case RULE_UPDATING:
{
mStats.rulesProcessedCount++;
//An error here means that something went wrong when trying to update a rule. This is wrong.
//It probably means that there's something wrong with the data we're sending.
auto& current = mRuleStack.back();
std::string ruleId = current.definition->getId();
S_LOG_FAILURE("Could not update rule with id '" << ruleId << "', continuing with next. Server message: " << errorMessage);
mStats.rulesCreateErrorCount++;
EventProgress.emit();
walkRules(res);
}
break;
case ENTITY_WALKING:
{
//An error here just means that the entity we asked for didn't exist on the server, and we need
//to create it. This is an expected result.
assert(!mTreeStack.empty());
StackEntry & current = mTreeStack.back();
const RootEntity& obj = current.obj;
assert(obj.isValid());
createEntity(obj, res);
}
break;
case ENTITY_CREATING:
{
//An error here means that something went wrong when trying to create an entity. This is wrong.
//It probably means that there's something wrong with the data we're sending. Either the
//persisted data is corrupt, or there have been changes on the server (for example entity types
//renamed or removed).
std::string entityType = "unknown";
auto I = mCreateEntityMapping.find(op->getRefno());
if (I != mCreateEntityMapping.end()) {
auto J = mPersistedEntities.find(I->second);
if (J != mPersistedEntities.end()) {
auto& entity = J->second;
entityType = entity->getParent();
}
}
S_LOG_FAILURE("Could not create entity of type '" << entityType << "', continuing with next. Server message: " << errorMessage);
mStats.entitiesCreateErrorCount++;
EventProgress.emit();
walkEntities(res);
}
break;
default:
S_LOG_FAILURE("Unexpected state in state machine: " << m_state << ". Server message: " << errorMessage);
break;
};
}
示例9: main
int main(int argc, char ** argv)
{
loadConfig(argc, argv);
database_flag = false;
init_python_api();
int ret;
{
World e("1", 1);
TestWorld test_world(e);
Anonymous attributes;
EntityBuilder::init(test_world);
Ruleset::init();
assert(Ruleset::instance() != 0);
assert(EntityBuilder::instance() != 0);
assert(EntityBuilder::instance()->newEntity("1", 1, "world", attributes) == 0);
assert(EntityBuilder::instance()->newEntity("1", 1, "nonexistant", attributes) == 0);
assert(EntityBuilder::instance()->newEntity("1", 1, "thing", attributes) != 0);
Ruleset::del();
assert(Ruleset::instance() == 0);
EntityBuilder::del();
assert(EntityBuilder::instance() == 0);
Inheritance::clear();
}
{
World e("1", 1);
TestWorld test_world(e);
Anonymous attributes;
Atlas::Message::Element val;
EntityBuilder::init(test_world);
Ruleset::init();
assert(Ruleset::instance() != 0);
Entity * test_ent = EntityBuilder::instance()->newEntity("1", 1, "thing", attributes);
assert(test_ent != 0);
assert(!test_ent->getAttr("funky", val));
assert(val.isNone());
attributes->setAttr("funky", "true");
test_ent = EntityBuilder::instance()->newEntity("1", 1, "thing", attributes);
assert(test_ent != 0);
assert(test_ent->getAttr("funky", val));
assert(val.isString());
assert(val.String() == "true");
Ruleset::del();
assert(Ruleset::instance() == 0);
EntityBuilder::del();
assert(EntityBuilder::instance() == 0);
Inheritance::clear();
}
{
// Create a test world.
World e("1", 1);
TestWorld test_world(e);
Atlas::Message::Element val;
// Instance of EntityBuilder with all protected methods exposed
// for testing
ExposedEntityBuilder * entity_factory = new ExposedEntityBuilder(test_world);
// Instance of Ruleset with all protected methods exposed
// for testing
EntityBuilder * test_eb = EntityBuilder::instance();
assert(test_eb == entity_factory);
ExposedRuleset test_ruleset(test_eb);
// Attributes for test entities being created
Anonymous attributes;
// Create an entity which is an instance of one of the core classes
Entity * test_ent = test_eb->newEntity("1", 1, "thing", attributes);
assert(test_ent != 0);
// Check the created entity does not have the attribute values we
// will be testing later
assert(!test_ent->getAttr("funky", val));
assert(val.isNone());
// Set a test attribute
attributes->setAttr("funky", "true");
// Create another entity, and check that it has picked up the new
// attribute value
test_ent = test_eb->newEntity("1", 1, "thing", attributes);
assert(test_ent != 0);
assert(test_ent->getAttr("funky", val));
assert(val.isString());
assert(val.String() == "true");
//.........这里部分代码省略.........