62 for (AttributeMap::const_iterator iter =
source.attributes.begin() ; iter !=
source.attributes.end() ; iter++)
64 EntityAttributeBasePtr attrBase = iter->second;
65 EntityAttributeBasePtr attr = EntityAttributeBasePtr::dynamicCast(attrBase->ice_clone());
66 attributes[iter->first] = attr;
75 for (AbstractEntityWrapperBaseList::const_iterator iter =
source.wrappers.begin() ; iter !=
source.wrappers.end() ; iter++)
83 wrapper->setEntity(
this);
98 int remainingRefs = __getRef() - 1;
100 remainingRefs <= wrapperCount &&
104 #
if ICE_INT_VERSION >= 30603
113 for (
const AbstractEntityWrapperBasePtr& wrapper :
wrappers)
118 if (p->getEntity().get() ==
this)
125 if (counter == remainingRefs)
132 for (
const AbstractEntityWrapperBasePtr& wrapper : tmpWrappers)
190 return attr->getValue()->getBool();
210 EntityRefBaseList result;
219 for (
int i = 0; i < attr->size(); i++)
221 result.push_back(armarx::VariantPtr::dynamicCast(attr->getValueAt(i))->get<EntityRefBase>());
229 EntityRefBaseList result;
230 EntityRefBaseList explored;
233 while (!unexplored.empty())
235 EntityRefBasePtr entityRef = unexplored.back();
236 EntityPtr next = EntityPtr::dynamicCast(entityRef->getEntity());
237 unexplored.pop_back();
239 bool isExplored = std::find_if(explored.cbegin(), explored.cend(), [&](
const EntityRefBasePtr & entityRef)
241 return entityRef->entityId == next->getId();
242 }) != explored.cend();
249 EntityRefBaseList newParents = next->getDirectParentRefs();
250 explored.push_back(entityRef);
251 unexplored.insert(unexplored.end(), newParents.begin(), newParents.end());
253 if (next->isMetaEntity() && !includeMetaEntities)
258 result.push_back(entityRef);
266 Ice::StringSeq result;
268 std::transform(parents.cbegin(), parents.cend(), std::back_inserter(result), [](
const EntityRefBasePtr & e)
270 return e->entityName;
285 for (
const auto& entity : entityRefs)
296 AttributeMap::const_iterator it = attributes.find(attrName);
298 if (it != attributes.end())
304 return EntityAttributeBasePtr();
319 if (attr->size() != 1)
324 return armarx::VariantPtr::dynamicCast(attr->getValue());
330 attributes[attr->getName()] = attr;
336 attributes.erase(attrName);
343 return attributes.find(attrName) != attributes.end();
348 memoryx::NameList result;
351 for (AttributeMap::const_iterator it = attributes.begin(); it != attributes.end(); ++it)
353 result.push_back(it->first);
362 if (
getId() != otherEntity->getId())
371 if (
getName() != otherEntity->getName())
376 if (otherEntity->getAttributeNames().size() != attributeNames.size())
381 for (std::string& attributeName : attributeNames)
387 otherEntity->getAttribute(attributeName)->serialize(otherSerializer);
388 if (otherSerializer->toString() != thisSerializer->toString())
399 return this->
clone();
405 ret->deepCopy(*
this);
412 stream <<
"[" <<
id <<
"] " << name << std::endl;
413 stream <<
"Attributes: (" << attributes.size() <<
")" << std::endl;
415 for (AttributeMap::const_iterator it = attributes.begin(); it != attributes.end(); ++it)
417 stream << it->first <<
": " << EntityAttributePtr::dynamicCast(it->second) << std::endl;
441 void Entity::serialize(
const armarx::ObjectSerializerBasePtr& serializer, const ::Ice::Current&
c)
const
453 obj->setString(
"name", name);
460 for (AttributeMap::const_iterator it = attributes.begin(); it != attributes.end(); ++it)
463 it->second->serialize(attr,
c);
464 objAttrs->setElement(it->first, attr);
467 obj->setElement(
"attrs", objAttrs);
476 if (!obj->getIdField().empty() && obj->hasElement(obj->getIdField()))
478 id = obj->getStringId();
481 name = obj->getString(
"name");
485 const std::vector<std::string> attrNames = objAttrs->getElementNames();
492 for (std::vector<std::string>::const_iterator it = attrNames.begin(); it != attrNames.end(); ++it)
495 attr->deserialize(objAttrs->getElement(*it));