• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ message::Element类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中atlas::message::Element的典型用法代码示例。如果您正苦于以下问题:C++ Element类的具体用法?C++ Element怎么用?C++ Element使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Element类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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.
    }
}
开发者ID:worldforge,项目名称:cyphesis,代码行数:32,代码来源:World.cpp


示例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");
}
开发者ID:danniellecandys,项目名称:cyphesis,代码行数:25,代码来源:EntityFilterProviderstest.cpp


示例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);
        }
    }
}
开发者ID:9cat,项目名称:cyphesis,代码行数:29,代码来源:TasksProperty.cpp


示例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());
}
开发者ID:Arsakes,项目名称:cyphesis,代码行数:30,代码来源:Tasktest.cpp


示例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);
			}
		}
	}
}
开发者ID:Laefy,项目名称:ember,代码行数:25,代码来源:EntityEditor.cpp


示例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());
		}
	}
}
开发者ID:jekin-worldforge,项目名称:ember,代码行数:32,代码来源:TerrainModAdapter.cpp


示例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);
}
开发者ID:jekin-worldforge,项目名称:ember,代码行数:27,代码来源:TerrainModAdapter.cpp


示例8: testAttribute

bool NumericComparerWrapper::testAttribute(const Atlas::Message::Element& attribute)
{
 	if (attribute.isNum()) {
		return mNumericComparer->test(attribute.asNum());
 	}
 	return false;
}
开发者ID:sajty,项目名称:ember,代码行数:7,代码来源:NumericComparerWrapper.cpp


示例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);
}
开发者ID:sajty,项目名称:ember,代码行数:26,代码来源:AreaAdapter.cpp


示例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;

}
开发者ID:Arsakes,项目名称:ember,代码行数:56,代码来源:TerrainParser.cpp


示例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));
	}
}
开发者ID:sajty,项目名称:ember,代码行数:10,代码来源:TerrainEntityManager.cpp


示例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);
}
开发者ID:9cat,项目名称:cyphesis,代码行数:11,代码来源:Container.cpp


示例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;
    }
}
开发者ID:LawrenceWeng,项目名称:cyphesis,代码行数:12,代码来源:Providers.cpp


示例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;
}
开发者ID:erikogenvik,项目名称:cyphesis,代码行数:51,代码来源:Tasktest.cpp


示例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();
  }
}
开发者ID:junrw,项目名称:ember-gsoc2012,代码行数:51,代码来源:TerrainShaderParser.cpp


示例16: 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());
		}
	}
}
开发者ID:Arsakes,项目名称:ember,代码行数:14,代码来源:StaticAdapter.cpp


示例17: 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);

}
开发者ID:junrw,项目名称:ember-gsoc2012,代码行数:14,代码来源:EmberEntity.cpp


示例18: 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);
                }
开发者ID:9cat,项目名称:cyphesis,代码行数:15,代码来源:EntityProperty.cpp


示例19: 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());
    }
}
开发者ID:worldforge,项目名称:cyphesis,代码行数:16,代码来源:CyPy_Element.cpp


示例20: 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();

}
开发者ID:jekin-worldforge,项目名称:ember,代码行数:31,代码来源:SizeAdapter.cpp



注:本文中的atlas::message::Element类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ objects::Root类代码示例发布时间:2022-05-31
下一篇:
C++ atl::CString类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap