本文整理汇总了C++中Entities类的典型用法代码示例。如果您正苦于以下问题:C++ Entities类的具体用法?C++ Entities怎么用?C++ Entities使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Entities类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TEST_F
TEST_F(LocalIds, using_entities)
{
if (get_parallel_size() == 1)
{
setup_mesh("generated:2x2x2", stk::mesh::BulkData::AUTO_AURA);
BulkDataHelper bulkDataHelper(get_bulk());
typedef stk::mesh::Field<double, stk::mesh::Cartesian3d> CoordFieldType;
CoordFieldType *coords = get_meta().get_field<CoordFieldType>(stk::topology::NODE_RANK, "coordinates");
unsigned elemIndex = 0;
const stk::mesh::BucketVector& elemBuckets = get_bulk().buckets(stk::topology::ELEM_RANK);
for(size_t i=0;i<elemBuckets.size();++i)
{
const stk::mesh::Bucket& bucket = *elemBuckets[i];
for(size_t j=0;j<bucket.size();++j)
{
Entities nodes = bulkDataHelper.get_nodes(bucket[j]);
for(unsigned k=0;k<nodes.size();++k)
{
double *node_data = stk::mesh::field_data(*coords, nodes[k]);
EXPECT_NEAR(gold_x_coordinates[elemIndex][k], node_data[0], 1.e-6);
}
++elemIndex;
}
}
}
}
示例2: getEntities
Entities Manager::getEntities(const std::string& componentType)
{
Entities entityList;
for (auto e : entities_) {
if (e->hasComponent(componentType)) {
entityList.push_back(e);
}
}
return entityList;
}
示例3: collisionBetweenEntities
void Collisionhandler::collisionBetweenEntities(Entities &entities){
for (Entities::size_type i = 0; i < entities.size(); i++){
Entity *e0 = entities[i];
for (Entities::size_type j = i + 1; j < entities.size(); j++){
Entity *e1 = entities[j];
if (e0->isOnScreen() && e1->isOnScreen()) {
if (hasCollided(e0, e1)) {
if (e0->getType() != e1->getType() && e0->getType() == Entity::PLAYER) {
checkCollisionDirection(e0, e1);
//checkCollisionDirection(e1, e0);
}
}
}
}
}
}
示例4:
bool Colision::doHeroShot(Entities& arg, Entities& arg_cmp)
{
if (arg.getType() != MAZZELTOF && arg.getType() != PEPELOUNI)
{
Serializer<IBLAST::PackCollHeroShot> ser;
ser.GData()._type = IBLAST::_COLL_HERO_SHOT;
ser.GData()._idMob = arg_cmp.getIdMob();
ser.GData()._idShot = arg_cmp.getIdT();
memset(ser.GData()._playerName, '/0', IBLAST::_MAX_NAME_LEN);
memcpy(ser.GData()._playerName, arg.getName().c_str(), IBLAST::_MAX_NAME_LEN);
ser.Serialize();
this->IBlast.gSocketNFO().SendTo(ser.GBinData());
return (true);
}
return false;
}
示例5: postQueryContext
/* ****************************************************************************
*
* postBatchQuery -
*
* POST /v2/op/query
*
* Payload In: BatchQueryRequest
* Payload Out: Entities
*
* URI parameters:
* - limit=NUMBER
* - offset=NUMBER
* - options=count,keyValues
*/
std::string postBatchQuery
(
ConnectionInfo* ciP,
int components,
std::vector<std::string>& compV,
ParseData* parseDataP
)
{
BatchQuery* bqP = &parseDataP->bq.res;
QueryContextRequest* qcrP = &parseDataP->qcr.res;
Entities entities;
std::string answer;
qcrP->fill(bqP);
bqP->release(); // qcrP just 'took over' the data from bqP, bqP no longer needed
answer = postQueryContext(ciP, components, compV, parseDataP);
if (ciP->httpStatusCode != SccOk)
{
parseDataP->qcr.res.release();
return answer;
}
// 03. Render Entities response
if (parseDataP->qcrs.res.contextElementResponseVector.size() == 0)
{
ciP->httpStatusCode = SccOk;
answer = "[]";
}
else
{
entities.fill(&parseDataP->qcrs.res);
TIMED_RENDER(answer = entities.render(ciP, EntitiesResponse));
}
// 04. Cleanup and return result
entities.release();
parseDataP->qcr.res.release();
return answer;
}
示例6: TEST
/* ****************************************************************************
*
* present - no output expected, just exercising the code
*/
TEST(Entities, present)
{
utInit();
Entity* enP = new Entity();
enP->id = "E";
enP->type = "T";
enP->isPattern = "false";
ContextAttribute* caP = new ContextAttribute("A", "T", "val");
enP->attributeVector.push_back(caP);
Entities ens;
ens.vec.push_back(enP);
ens.oe.fill(SccNone, "Lorem ipsum", "FooError");
ens.present("");
utExit();
}
示例7:
PyObject* Entities<T>::__py_pyGet(PyObject* self, PyObject * args, PyObject* kwds)
{
Entities* lpEntities = static_cast<Entities*>(self);
PyObject * pDefault = Py_None;
int id = 0;
if (!PyArg_ParseTuple( args, "i|O", &id, &pDefault))
{
return NULL;
}
PyObject* pEntity = lpEntities->find(id);
if (!pEntity)
{
pEntity = pDefault;
}
Py_INCREF(pEntity);
return pEntity;
}
示例8: al_clear_to_color
void Display::updateDisplay(Entities &entities){
al_clear_to_color(al_map_rgba(0, 0, 0, 255));
std::list<Entity*> entitiesTemp = entities.getEntities();
for (std::list<Entity*>::iterator it = entitiesTemp.begin(); it != entitiesTemp.end(); it++){
(*it)->draw();
}
displayText(score, Coordinates(80, 10), font2);
al_flip_display();
}
示例9: collisionBetweenEntitiesAndTerrains
void Collisionhandler::collisionBetweenEntitiesAndTerrains(Entities &entities, Terrains &terrains){
for (Entities::size_type i = 0; i < entities.size(); i++){
Entity *e0 = entities[i];
for (Terrains::size_type j = 0; j < terrains.size(); j++){
Terrain *e1 = terrains[j];
if (e0->isOnScreen() && e1->isOnScreen()) {
if (hasCollided(e0, e1)) {
checkCollisionDirection(e0, e1);
}
}
}
}
}
示例10: postQueryContext
/* ****************************************************************************
*
* getEntities -
*
* GET /v2/entities
*
* Payload In: None
* Payload Out: Entities
*
* URI parameters:
* - limit=NUMBER
* - offset=NUMBER
* - count=true/false
*
* 01. Fill in QueryContextRequest
* 02. Call standard op postQueryContext
* 03. Render Entities response
* 04. Cleanup and return result
*/
std::string getEntities
(
ConnectionInfo* ciP,
int components,
std::vector<std::string>& compV,
ParseData* parseDataP
)
{
std::string answer;
Entities entities;
// 01. Fill in QueryContextRequest
parseDataP->qcr.res.fill(".*", "", "true", EntityTypeEmptyOrNotEmpty, "");
// 02. Call standard op postQueryContext
answer = postQueryContext(ciP, components, compV, parseDataP);
// 03. Render Entities response
if (parseDataP->qcrs.res.contextElementResponseVector.size() == 0)
{
ciP->httpStatusCode = SccOk;
answer = "[]";
}
else
{
entities.fill(&parseDataP->qcrs.res);
answer = entities.render(ciP, EntitiesResponse);
}
// 04. Cleanup and return result
entities.release();
parseDataP->qcr.res.release();
return answer;
}
示例11: PyLong_AsLong
PyObject * Entities<T>::mp_subscript(PyObject* self, PyObject* key /*entityID*/)
{
Entities* lpEntities = static_cast<Entities*>(self);
ENTITY_ID entityID = PyLong_AsLong(key);
if (PyErr_Occurred())
return NULL;
PyObject * pyEntity = NULL;
ENTITYS_MAP& entities = lpEntities->getEntities();
ENTITYS_MAP::const_iterator iter = entities.find(entityID);
if (iter != entities.end())
pyEntity = iter->second.get();
if(pyEntity == NULL)
{
PyErr_Format(PyExc_KeyError, "%d", entityID);
PyErr_PrintEx(0);
return NULL;
}
Py_INCREF(pyEntity);
return pyEntity;
}
示例12: make_range
boost::iterator_range<ElementIterator> make_range(Entities& entities)
{
ElementIterator begin(entities);
return boost::make_iterator_range(begin,begin+entities.size());
}
示例13: oe
/* ****************************************************************************
*
* getEntities -
*
* GET /v2/entities
*
* Payload In: None
* Payload Out: Entities
*
* URI parameters:
* - limit=NUMBER
* - offset=NUMBER
* - count=true/false
* - id
* - idPattern
* - q
* - geometry
* - coords
*
* 01. Fill in QueryContextRequest
* 02. Call standard op postQueryContext
* 03. Render Entities response
* 04. Cleanup and return result
*/
std::string getEntities
(
ConnectionInfo* ciP,
int components,
std::vector<std::string>& compV,
ParseData* parseDataP
)
{
Entities entities;
std::string answer;
std::string pattern = ".*"; // all entities, default value
std::string id = ciP->uriParam["id"];
std::string idPattern = ciP->uriParam["idPattern"];
std::string q = ciP->uriParam["q"];
std::string geometry = ciP->uriParam["geometry"];
std::string coords = ciP->uriParam["coords"];
std::string out;
if ((idPattern != "") && (id != ""))
{
OrionError oe(SccBadRequest, "Incompatible parameters: id, IdPattern");
TIMED_RENDER(answer = oe.render(ciP, ""));
return answer;
}
else if (id != "")
{
// FIXME: a more efficient query could be possible ...
std::vector<std::string> idsV;
stringSplit(id, ',', idsV);
for (unsigned int ix = 0; ix != idsV.size(); ++ix)
{
if (ix != 0)
{
pattern += "|";
}
pattern += idsV[ix];
}
}
else if (idPattern != "")
{
pattern = idPattern;
}
// Making sure geometry and coords are not used individually
if ((coords != "") && (geometry == ""))
{
OrionError oe(SccBadRequest, "URI param /coords/ used without /geometry/");
TIMED_RENDER(out = oe.render(ciP, ""));
return out;
}
else if ((geometry != "") && (coords == ""))
{
OrionError oe(SccBadRequest, "URI param /geometry/ used without /coords/");
TIMED_RENDER(out = oe.render(ciP, ""));
return out;
}
// Making sure geometry is valid (if present)
orion::Geometry geo;
std::vector<std::string> coordsV;
if (geometry != "")
{
std::string errorString;
if (geo.parse(geometry.c_str(), &errorString) != 0)
{
OrionError oe(SccBadRequest, std::string("error parsing geometry: ") + errorString);
//.........这里部分代码省略.........
示例14: postUpdateContext
/* ****************************************************************************
*
* postBatchUpdate -
*
* POST /v2/op/update
*
* Payload In: BatchUpdateRequest
* Payload Out: 201 or error
*
* URI parameters:
* - limit=NUMBER
* - offset=NUMBER
* - options=keyValues
*/
std::string postBatchUpdate
(
ConnectionInfo* ciP,
int components,
std::vector<std::string>& compV,
ParseData* parseDataP
)
{
BatchUpdate* buP = &parseDataP->bu.res;
UpdateContextRequest* upcrP = &parseDataP->upcr.res;
Entities entities;
std::string answer;
upcrP->fill(&buP->entities, buP->updateActionType.get());
buP->release(); // upcrP just 'took over' the data from buP, buP is no longer needed
parseDataP->upcr.res.present("");
answer = postUpdateContext(ciP, components, compV, parseDataP);
for (unsigned int ix = 0; ix < parseDataP->upcrs.res.contextElementResponseVector.size(); ++ix)
{
ContextElementResponse* cerP = parseDataP->upcrs.res.contextElementResponseVector[ix];
if (cerP->statusCode.code != SccOk)
{
parseDataP->upcrs.res.errorCode.fill(cerP->statusCode);
}
}
//
// If an error is flagged by ciP->httpStatusCode, store it in parseDataP->upcrs.res.errorCode
// for later processing (not sure this ever happen ...)
//
if (ciP->httpStatusCode != SccOk)
{
parseDataP->upcrs.res.errorCode.code = ciP->httpStatusCode;
parseDataP->upcrs.res.errorCode.details = answer;
}
// If postUpdateContext gives back a parseDataP->upcrs with !200 OK in 'errorCode', transform to HTTP Status error
if (parseDataP->upcrs.res.errorCode.code != SccOk)
{
OrionError oe(parseDataP->upcrs.res.errorCode);
ciP->httpStatusCode = parseDataP->upcrs.res.errorCode.code;
// If 404 and details empty, assuming 'Entity not found'
if ((parseDataP->upcrs.res.errorCode.code == SccContextElementNotFound) && (oe.details == ""))
{
oe.details = "Entity not found";
}
answer = oe.render(ciP, "");
}
else
{
//
// NOTE
// For simplicity, 204 is always returned, even if entities are created
//
ciP->httpStatusCode = SccNoContent;
answer = "";
}
// 04. Cleanup and return result
entities.release();
parseDataP->upcr.res.release();
return answer;
}
示例15: operator
bool IsElementsSurface::operator()(const Entities& component)
{
return component.element_type().dimension() == component.element_type().dimensionality() + 1;
}