Go to the documentation of this file.
27 #include <shared_mutex>
28 #include <type_traits>
34 #include <MemoryX/interface/core/EntityBase.h>
35 #include <MemoryX/interface/core/ProbabilityMeasures.h>
245 class Entity :
virtual public memoryx::EntityBase
261 ::std::string
getId(const ::Ice::Current& = Ice::emptyCurrent)
const override;
267 void setId(const ::std::string&
id, const ::Ice::Current& = Ice::emptyCurrent)
override;
273 ::std::string
getName(const ::Ice::Current& = Ice::emptyCurrent)
const override;
279 void setName(const ::std::string& name, const ::Ice::Current& = Ice::emptyCurrent)
override;
285 bool isMetaEntity(const ::Ice::Current& = Ice::emptyCurrent)
const override;
303 virtual EntityRefBaseList
getAllParentRefs(
bool includeMetaEntities =
true)
const;
319 const ::Ice::Current& = Ice::emptyCurrent)
const override;
326 EntityAttributeBasePtr
328 const ::Ice::Current& = Ice::emptyCurrent)
const override;
342 void putAttribute(const ::memoryx::EntityAttributeBasePtr& attr,
343 const ::Ice::Current& = Ice::emptyCurrent)
override;
352 template <
typename T>
356 ProbabilityMeasureBasePtr uncertainty = ProbabilityMeasureBasePtr())
358 const ::memoryx::EntityAttributeBasePtr attr =
new EntityAttribute(attrName);
371 const ::Ice::Current& = Ice::emptyCurrent)
override;
390 bool equals(
const EntityBasePtr& otherEntity,
391 const ::Ice::Current& = Ice::emptyCurrent)
const override;
403 const ::Ice::Current& = Ice::emptyCurrent)
const override;
417 template <
typename T>
421 static_assert(!std::is_same_v<T, EntityWrappers::AbstractEntityWrapper>,
422 "The template parameter for Entity::addWrapper should not be of base "
423 "class AbstractEntityWrapper");
425 static_assert(!std::is_base_of_v<T, EntityWrappers::AbstractEntityWrapper>,
426 "The template parameter for Entity::addWrapper needs to inherit from "
427 "AbstractEntityWrapper");
433 wrapper->setEntity(
this);
448 template <
typename T>
452 static_assert(!std::is_same_v<T, EntityWrappers::AbstractEntityWrapper>,
453 "The template parameter for Entity::getWrapper should not be of base "
454 "class AbstractEntityWrapper");
456 static_assert(!std::is_base_of_v<T, EntityWrappers::AbstractEntityWrapper>,
457 "The template parameter for Entity::getWrapper needs to inherit from "
458 "AbstractEntityWrapper");
460 AbstractEntityWrapperBaseList::iterator iter =
wrappers.begin();
493 void serialize(
const armarx::ObjectSerializerBasePtr& serializer,
494 const ::Ice::Current& = Ice::emptyCurrent)
const override;
507 void deserialize(
const armarx::ObjectSerializerBasePtr& serializer,
508 const ::Ice::Current& = Ice::emptyCurrent)
override;
512 template <
class BaseClass,
class VariantClass>
520 void output(std::ostream& stream)
const;
556 stream << EntityPtr::dynamicCast(rhs);
void ice_preMarshal() override
void setMetaEntity(bool isMetaEntity, const ::Ice::Current &=Ice::emptyCurrent) override
Mark this entity as meta (i.e.
The Variant class is described here: Variants.
const armarx::VariantTypeId EntityRef
void putAttribute(const std::string &attrName, T attrValue, ProbabilityMeasureBasePtr uncertainty=ProbabilityMeasureBasePtr())
Create and store attribute from name, value, and optionally uncertainty measure.
void putAttribute(const ::memoryx::EntityAttributeBasePtr &attr, const ::Ice::Current &=Ice::emptyCurrent) override
Store attribute in entity.
::std::string getName(const ::Ice::Current &=Ice::emptyCurrent) const override
Retrieve name of this entity.
::std::string getId(const ::Ice::Current &=Ice::emptyCurrent) const override
Retrieve id of this entity which is an integer in string representation.
void deserialize(const armarx::ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) override
Subclasses should use serializable attributes and consider these methods final.
EntityAttributeBasePtr getAttribute(const ::std::string &attrName, const ::Ice::Current &=Ice::emptyCurrent) const override
Retrieve attribute from entity.
void removeAttribute(const ::std::string &attrName, const ::Ice::Current &=Ice::emptyCurrent) override
Remove attribute with given name from entity.
EntityPtr clone(const Ice::Current &c=Ice::emptyCurrent) const
void serialize(const armarx::ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) const override
Subclasses should use serializable attributes and consider these methods final.
memoryx::NameList getAttributeNames(const ::Ice::Current &=Ice::emptyCurrent) const override
Retrieve list of all attribute names.
static EntityPtr CreateGenericEntity()
Creates an entity without any convenience getter/setter functions.
void ice_postUnmarshal() override
void output(std::ostream &stream) const
virtual armarx::VariantPtr getAttributeValue(const ::std::string &attrName) const
Retrieve value of an attribute from entity.
virtual void setDirectParentRefs(const EntityRefBaseList &entityRefs)
Replace parent entity references.
Ice::ObjectPtr ice_clone() const override
IceInternal::Handle< T > getWrapper()
Retrieve EntityWrapper that has previously been added with Entity::addWrapper().
virtual EntityRefBaseList getDirectParentRefs() const
Retrieve parent entity references.
std::mutex attributesMutex
IceInternal::Handle< T > addWrapper(T *wrapper)
Add EntityWrapper to entity.
virtual std::vector< std::string > getAllParentsAsStringList() const
virtual EntityRefBaseList getAllParentRefs(bool includeMetaEntities=true) const
Retrieve all parents by traversing the whole hierarchy.
Vertex source(const detail::edge_base< Directed, Vertex > &e, const PCG &)
void setId(const ::std::string &id, const ::Ice::Current &=Ice::emptyCurrent) override
Set id of this entity.
AbstractEntityWrapperBaseList wrappers
bool equalsAttributes(const EntityBasePtr &otherEntity, const ::Ice::Current &=Ice::emptyCurrent) const override
equalsAttributes computes if two Entity instances are equal.
std::shared_mutex entityMutex
bool hasAttribute(const ::std::string &attrName, const ::Ice::Current &=Ice::emptyCurrent) const override
Check whether this entity has an attribute with the given name.
friend std::ostream & operator<<(std::ostream &stream, const Entity &rhs)
Attribute of MemoryX entities.
std::shared_ptr< Object > ObjectPtr
bool equals(const EntityBasePtr &otherEntity, const ::Ice::Current &=Ice::emptyCurrent) const override
equals computes if two Entity instances are equal.
void setName(const ::std::string &name, const ::Ice::Current &=Ice::emptyCurrent) override
Set name of this entity.
std::recursive_mutex wrappersMutex
bool isMetaEntity(const ::Ice::Current &=Ice::emptyCurrent) const override
Indicates whether this entity only contains meta information.