本文整理汇总了C++中atlas::message::Element::asList方法的典型用法代码示例。如果您正苦于以下问题:C++ Element::asList方法的具体用法?C++ Element::asList怎么用?C++ Element::asList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类atlas::message::Element
的用法示例。
在下文中一共展示了Element::asList方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: set
void TasksProperty::set(const Atlas::Message::Element & val)
{
if (!val.isList())
{
log(ERROR, "Task property must be a list.");
return;
}
if (m_task == 0) {
log(ERROR, "No task in ::set");
return;
}
ListType tasks = val.asList();
ListType::const_iterator I = tasks.begin();
ListType::const_iterator Iend = tasks.end();
for (; I != Iend; ++I) {
if (!I->isMap()) {
log(ERROR, "Task must be a map.");
return;
}
const MapType & task = I->asMap();
MapType::const_iterator J = task.begin();
MapType::const_iterator Jend = task.end();
for (J = task.begin(); J != Jend; ++J) {
m_task->setAttr(J->first, J->second);
}
}
}
示例2: updateGui
void SizeAdapter::updateGui(const ::Atlas::Message::Element& element)
{
AdapterSelfUpdateContext context(*this);
WFMath::AxisBox<3> axisBox;
try {
axisBox.fromAtlas(element.asList());
} catch (...) {
axisBox = WFMath::AxisBox<3>(WFMath::Point<3>(-0.5, -0.5, -0.5), WFMath::Point<3>(0.5, 0.5, 0.5));
}
if (mLowerXWindow) {
mLowerXWindow->setText(toString(axisBox.lowCorner().x()));
}
if (mLowerYWindow) {
mLowerYWindow->setText(toString(axisBox.lowCorner().y()));
}
if (mLowerZWindow) {
mLowerZWindow->setText(toString(axisBox.lowCorner().z()));
}
if (mUpperXWindow) {
mUpperXWindow->setText(toString(axisBox.highCorner().x()));
}
if (mUpperYWindow) {
mUpperYWindow->setText(toString(axisBox.highCorner().y()));
}
if (mUpperZWindow) {
mUpperZWindow->setText(toString(axisBox.highCorner().z()));
}
updateInfo();
}
示例3: addToEntity
void StdContainer::addToEntity(const std::string & key,
const Atlas::Objects::Entity::RootEntity & ent) const
{
Atlas::Message::Element v = Atlas::Message::ListType();
Atlas::Message::ListType & contlist = v.asList();
EntitySet::const_iterator Iend = m_entities.end();
for (EntitySet::const_iterator I = m_entities.begin(); I != Iend; ++I) {
contlist.push_back((*I)->getId());
}
ent->setAttr(key, v);
}
示例4: createShaders
void TerrainShaderParser::createShaders(const Atlas::Message::Element& surfaces)
{
Terrain::TerrainLayerDefinitionManager& terrainManager = Terrain::TerrainLayerDefinitionManager::getSingleton();
bool isValid = false;
if (surfaces.isList()) {
const Atlas::Message::ListType & slist(surfaces.asList());
for (Atlas::Message::ListType::const_iterator I = slist.begin(); I != slist.end(); ++I) {
if (I->isMap()) {
std::string name;
std::string pattern;
const Atlas::Message::MapType& surfaceMap(I->asMap());
Mercator::Shader::Parameters params;
if (surfaceMap.count("params")) {
const Atlas::Message::Element& paramsElem(surfaceMap.find("params")->second);
if (paramsElem.isMap()) {
for (Atlas::Message::MapType::const_iterator J = paramsElem.asMap().begin(); J != paramsElem.asMap().end(); ++J) {
if (J->second.isNum()) {
params[J->first] = J->second.asNum();
}
}
}
}
if (surfaceMap.count("name")) {
const Atlas::Message::Element& nameElem(surfaceMap.find("name")->second);
if (nameElem.isString()) {
const std::string& name = nameElem.asString();
Terrain::TerrainLayerDefinition* def(terrainManager.getDefinitionForShader(name));
if (def) {
if (surfaceMap.count("pattern")) {
const Atlas::Message::Element& patternElem(surfaceMap.find("pattern")->second);
if (patternElem.isString()) {
const std::string& pattern = patternElem.asString();
Mercator::Shader* shader = Mercator::ShaderFactories::instance().newShader(pattern, params);
if (shader) {
isValid = true;
mTerrainHandler.createShader(def, shader);
}
}
}
}
}
}
}
}
}
if (!isValid) {
createDefaultShaders();
}
}
示例5: resolveEntityReferences
void EntityImporterBase::resolveEntityReferences(Atlas::Message::Element& element)
{
if (element.isMap()) {
auto entityRefI = element.asMap().find("$eid");
if (entityRefI != element.asMap().end() && entityRefI->second.isString()) {
auto I = mEntityIdMap.find(entityRefI->second.asString());
if (I != mEntityIdMap.end()) {
entityRefI->second = I->second;
}
}
//If it's a map we need to process all child elements too
for (auto& I : element.asMap()) {
resolveEntityReferences(I.second);
}
} else if (element.isList()) {
//If it's a list we need to process all child elements too
for (auto& I : element.asList()) {
resolveEntityReferences(I);
}
}
}
示例6: start
void EntityImporterBase::start(const std::string& filename)
{
S_LOG_VERBOSE("Starting import from " << filename);
auto factories = Atlas::Objects::Factories::instance();
auto rootObj = loadFromFile(filename);
if (!rootObj.isValid()) {
EventCompleted.emit();
return;
}
Atlas::Message::Element metaElem;
Atlas::Message::Element entitiesElem;
Atlas::Message::Element mindsElem;
Atlas::Message::Element rulesElem;
rootObj->copyAttr("meta", metaElem);
rootObj->copyAttr("entities", entitiesElem);
rootObj->copyAttr("minds", mindsElem);
if (rootObj->copyAttr("rules", rulesElem) == 0) {
if (!rulesElem.isList()) {
S_LOG_WARNING("Rules element is not list.");
EventCompleted.emit();
return;
} else {
for (auto& ruleMessage : rulesElem.asList()) {
if (ruleMessage.isMap()) {
auto object = factories->createObject(ruleMessage.asMap());
if (object.isValid()) {
if (!object->isDefaultId()) {
mPersistedRules.insert(std::make_pair(object->getId(), object));
}
}
}
}
}
}
if (!entitiesElem.isNone() && !entitiesElem.isList()) {
S_LOG_WARNING("Entities element is not list.");
EventCompleted.emit();
return;
}
if (!mindsElem.isNone() && !mindsElem.isList()) {
S_LOG_WARNING("Minds element is not list.");
EventCompleted.emit();
return;
}
if (!entitiesElem.isNone()) {
for (auto& entityMessage : entitiesElem.asList()) {
if (entityMessage.isMap()) {
auto& entityMap = entityMessage.asMap();
auto object = factories->createObject(entityMap);
if (object.isValid()) {
if (!object->isDefaultId()) {
registerEntityReferences(object->getId(), entityMap);
mPersistedEntities.insert(std::make_pair(object->getId(), object));
}
}
}
}
}
//If we should resume the world, check if the world has a "suspended" property,
//and disable it if so.
if (mResumeWorld) {
auto I = mPersistedEntities.find("0");
if (I != mPersistedEntities.end()) {
if (I->second->hasAttr("suspended")) {
I->second->setAttr("suspended", 0);
S_LOG_INFO("Resuming suspended world.");
}
}
}
if (!mindsElem.isNone()) {
for (auto& mindMessage : mindsElem.asList()) {
if (mindMessage.isMap()) {
auto object = factories->createObject(mindMessage.asMap());
if (object.isValid()) {
if (!object->isDefaultId()) {
mPersistedMinds.insert(std::make_pair(object->getId(), object));
}
}
}
}
}
S_LOG_INFO("Starting loading of world. Number of entities: " << mPersistedEntities.size() << " Number of minds: " << mPersistedMinds.size() << " Number of rules: " << mPersistedRules.size());
mStats.entitiesCount = static_cast<unsigned int>(mPersistedEntities.size());
mStats.mindsCount = static_cast<unsigned int>(mPersistedMinds.size());
mStats.rulesCount = static_cast<unsigned int>(mPersistedRules.size());
EventProgress.emit();
if (mPersistedRules.empty()) {
startEntityWalking();
} else {
startRuleWalking();
}
//.........这里部分代码省略.........
示例7: AdapterBase
ListAdapter::ListAdapter(const ::Atlas::Message::Element& element, CEGUI::Window* childContainer)
: AdapterBase(element), mChildContainer(childContainer), mAttributes(element.asList())
{
}