本文整理汇总了C++中atlas::message::Element类的典型用法代码示例。如果您正苦于以下问题:C++ Element类的具体用法?C++ Element怎么用?C++ Element使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Element类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: test_OutfitProviders
void ProvidersTest::test_OutfitProviders()
{
Atlas::Message::Element value;
//Check if we get the right entity in outfit query
auto provider = CreateProvider( { "entity", "outfit", "hands" });
provider->value(value, QueryContext { *m_ch1 });
assert(value.Ptr() == m_glovesEntity);
//Check for outfit's property query
provider = CreateProvider( { "entity", "outfit", "hands", "color" });
provider->value(value, QueryContext { *m_ch1 });
assert(value.String() == "brown");
//Check if we get the right entity in nested outfit query
provider = CreateProvider(
{ "entity", "outfit", "hands", "outfit", "thumb" });
provider->value(value, QueryContext { *m_ch1 });
assert(value.Ptr() == m_cloth);
//Check for nested outfit's property
provider = CreateProvider( { "entity", "outfit", "hands", "outfit", "thumb",
"color" });
provider->value(value, QueryContext { *m_ch1 });
assert(value.String() == "green");
}
示例3: 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);
}
}
}
示例4: test_sequence
void Tasktest::test_sequence()
{
m_task->nextTick(1.5);
Atlas::Message::Element val;
m_task->getAttr("foo", val);
assert(val.isNone());
m_task->setAttr("foo", 1);
m_task->getAttr("foo", val);
assert(val.isInt());
assert(!m_task->obsolete());
OpVector res;
assert(res.empty());
Atlas::Objects::Operation::Generic c;
c->setParents(std::list<std::string>(1, "generic"));
m_task->initTask(c, res);
Operation op;
m_task->operation(op, res);
m_task->irrelevant();
assert(m_task->obsolete());
}
示例5: submitChanges
void EntityEditor::submitChanges()
{
if (mRootAdapter->hasChanges()) {
Atlas::Message::Element rootElement = mRootAdapter->getSelectedChangedElements();
if (rootElement.isMap()) {
std::map<std::string, ::Atlas::Message::Element> attributes(rootElement.asMap());
if (attributes.size()) {
std::stringstream ss;
Atlas::Message::QueuedDecoder decoder;
Atlas::Codecs::XML codec(ss, decoder);
Atlas::Formatter formatter(ss, codec);
Atlas::Message::Encoder encoder(formatter);
formatter.streamBegin();
encoder.streamMessageElement(attributes);
formatter.streamEnd();
S_LOG_VERBOSE("Sending attribute update to server:\n" << ss.str());
EmberServices::getSingleton().getServerService().setAttributes(&mEntity, attributes);
}
}
}
}
示例6: updateGui
void TerrainModAdapter::updateGui(const ::Atlas::Message::Element& element)
{
mPositioningsBinder.sync();
mTerrainModsBinder.sync();
if (element.isMap()) {
const ::Atlas::Message::MapType& mapElement = element.asMap();
::Atlas::Message::MapType::const_iterator I = mapElement.find("height");
float height = 0;
if (I != mapElement.end()) {
mPositioningsBinder.select("height");
if (I->second.isNum()) {
height = I->second.asNum();
}
} else {
I = mapElement.find("heightoffset");
if (I != mapElement.end()) {
mPositioningsBinder.select("heightoffset");
if (I->second.isNum()) {
height = I->second.asNum();
}
}
}
std::stringstream ss;
ss << height;
mHeightTextbox->setText(ss.str());
I = mapElement.find("type");
if (I != mapElement.end() && I->second.isString()) {
mTerrainModsBinder.select(I->second.asString());
}
}
}
示例7: AdapterBase
TerrainModAdapter::TerrainModAdapter(const ::Atlas::Message::Element& element, CEGUI::PushButton* showButton, EmberEntity* entity, CEGUI::Combobox* posTypeCombobox, CEGUI::Combobox* modTypeCombobox, CEGUI::Editbox* heightTextbox)
: AdapterBase(element), mEntity(entity), mPolygonAdapter(0), mHeightTextbox(heightTextbox), mTerrainModsBinder(modTypeCombobox), mPositioningsBinder(posTypeCombobox)
{
if (element.isMap()) {
const ::Atlas::Message::MapType& areaData(element.asMap());
::Atlas::Message::MapType::const_iterator I = areaData.find("shape");
if (I != areaData.end()) {
mPolygonAdapter = std::auto_ptr<PolygonAdapter>(new PolygonAdapter(I->second, showButton, entity));
} else {
mPolygonAdapter = std::auto_ptr<PolygonAdapter>(new PolygonAdapter(::Atlas::Message::Element(), showButton, entity));
}
} else {
mPolygonAdapter = std::auto_ptr<PolygonAdapter>(new PolygonAdapter(::Atlas::Message::Element(), showButton, entity));
}
if (heightTextbox) {
addGuiEventConnection(heightTextbox->subscribeEvent(CEGUI::Window::EventTextChanged, CEGUI::Event::Subscriber(&TerrainModAdapter::heightTextbox_TextChanged, this)));
}
mTerrainModsBinder.addType("levelmod", "Level", LevelTerrainMod());
mTerrainModsBinder.addType("adjustmod", "Adjust", AdjustTerrainMod());
mPositioningsBinder.addType("height", "Fixed", FixedPositioning());
mPositioningsBinder.addType("heightoffset", "Relative", RelativePositioning());
updateGui(element);
}
示例8: testAttribute
bool NumericComparerWrapper::testAttribute(const Atlas::Message::Element& attribute)
{
if (attribute.isNum()) {
return mNumericComparer->test(attribute.asNum());
}
return false;
}
示例9: mLayer
AreaAdapter::AreaAdapter(const ::Atlas::Message::Element& element, CEGUI::PushButton* showButton, CEGUI::Combobox* layerWindow, EmberEntity* entity) :
AdapterBase(element), mLayer(0), mLayerWindow(layerWindow), mEntity(entity), mPolygonAdapter(nullptr)
{
if (element.isMap()) {
const ::Atlas::Message::MapType& areaData(element.asMap());
::Atlas::Message::MapType::const_iterator shapeI = areaData.find("shape");
if (shapeI != areaData.end()) {
mPolygonAdapter = std::unique_ptr<PolygonAdapter>(new PolygonAdapter(shapeI->second, showButton, entity));
} else {
::Atlas::Message::MapType defaultShape;
mPolygonAdapter = std::unique_ptr<PolygonAdapter>(new PolygonAdapter(getDefaultPolygon().toAtlas(), showButton, entity));
}
WFMath::Polygon<2> poly;
Terrain::TerrainAreaParser parser;
parser.parseArea(areaData, poly, mLayer);
} else {
mPolygonAdapter = std::unique_ptr<PolygonAdapter>(new PolygonAdapter(getDefaultPolygon().toAtlas(), showButton, entity));
}
if (mLayerWindow) {
addGuiEventConnection(mLayerWindow->subscribeEvent(CEGUI::Combobox::EventListSelectionChanged, CEGUI::Event::Subscriber(&AreaAdapter::layerWindow_ListSelectionChanged, this)));
}
updateGui(mOriginalValue);
}
示例10: parseTerrain
TerrainDefPointStore TerrainParser::parseTerrain(const Atlas::Message::Element& terrain, const WFMath::Point<3>& offset) const
{
//_fpreset();
if (!terrain.isMap()) {
S_LOG_FAILURE("Terrain is not a map");
}
const Atlas::Message::MapType & tmap = terrain.asMap();
Atlas::Message::MapType::const_iterator I = tmap.find("points");
if (I == tmap.end()) {
S_LOG_FAILURE("No terrain points");
}
Terrain::TerrainDefPointStore pointStore;
if (I->second.isList()) {
// Legacy support for old list format.
const Atlas::Message::ListType& plist = I->second.asList();
Atlas::Message::ListType::const_iterator J = plist.begin();
for (; J != plist.end(); ++J) {
if (!J->isList()) {
S_LOG_INFO("Non list in points");
continue;
}
const Atlas::Message::ListType & point = J->asList();
if (point.size() != 3) {
S_LOG_INFO("Point without 3 nums.");
continue;
}
Terrain::TerrainDefPoint defPoint(static_cast<int> (point[0].asNum() + offset.x()), static_cast<int> (point[1].asNum() + offset.y()), static_cast<float> (point[3].asNum() + offset.z()));
pointStore.push_back(defPoint);
}
} else if (I->second.isMap()) {
const Atlas::Message::MapType& plist = I->second.asMap();
Atlas::Message::MapType::const_iterator J = plist.begin();
for (; J != plist.end(); ++J) {
if (!J->second.isList()) {
S_LOG_INFO("Non list in points.");
continue;
}
const Atlas::Message::ListType & point = J->second.asList();
if (point.size() != 3) {
S_LOG_INFO("Point without 3 nums.");
continue;
}
int x = static_cast<int> (point[0].asNum());
int y = static_cast<int> (point[1].asNum());
float z = point[2].asNum();
Terrain::TerrainDefPoint defPoint(x + offset.x(), y + offset.y(), z + offset.z());
pointStore.push_back(defPoint);
}
} else {
S_LOG_FAILURE("Terrain is the wrong type");
}
return pointStore;
}
示例11: entityTerrainModAttrChanged
void TerrainEntityManager::entityTerrainModAttrChanged(EmberEntity& entity, const Atlas::Message::Element& value)
{
if (value.isMap() && mTerrainMods.find(&entity) == mTerrainMods.end()) {
Terrain::TerrainMod* mod = new Terrain::TerrainMod(entity, value.Map());
mod->init();
mTerrainMods.insert(std::make_pair(&entity, mod));
mTerrainHandler.addTerrainMod(mod);
entity.BeingDeleted.connect(sigc::bind(sigc::mem_fun(*this, &TerrainEntityManager::entityBeingDeletedTerrainMod), &entity));
}
}
示例12: 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);
}
示例13: value
void ContainsRecursiveFunctionProvider::value(Atlas::Message::Element& value,
const QueryContext& context) const
{
Atlas::Message::Element container;
m_consumer->value(container, context);
if (container.isPtr()) {
value = checkContainer((LocatedEntitySet*)container.Ptr());
}
else{
value = false;
}
}
示例14: main
int main()
{
int ret = 0;
Operation op;
{
Task * task;
OpVector res;
if (0) {
task->TickOperation(op, res);
}
}
Entity ent1("1", 1), ent2("2", 2);
Character chr("3", 3);
{
Fell fell(chr, ent1, ent2);
fell.nextTick(1.5);
Atlas::Message::Element val;
fell.getAttr("foo", val);
assert(val.isNone());
fell.setAttr("foo", 1);
fell.getAttr("foo", val);
assert(val.isInt());
assert(!fell.obsolete());
OpVector res;
assert(res.empty());
Atlas::Objects::Operation::Generic c;
fell.initTask(c, res);
assert(!res.empty());
fell.TickOperation(op, res);
fell.irrelevant();
assert(fell.obsolete());
}
return ret;
}
示例15: 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();
}
}