|
#include <MemoryX/core/entity/Entity.h>
Public Member Functions | |
void | __decRef () override |
template<typename T > | |
IceInternal::Handle< T > | addWrapper (T *wrapper) |
Add EntityWrapper to entity. More... | |
EntityPtr | clone (const Ice::Current &c=Ice::emptyCurrent) const |
void | deserialize (const armarx::ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) override |
Subclasses should use serializable attributes and consider these methods final. More... | |
bool | equals (const EntityBasePtr &otherEntity, const ::Ice::Current &=Ice::emptyCurrent) const override |
equals computes if two Entity instances are equal. More... | |
bool | equalsAttributes (const EntityBasePtr &otherEntity, const ::Ice::Current &=Ice::emptyCurrent) const override |
equalsAttributes computes if two Entity instances are equal. More... | |
virtual EntityRefBaseList | getAllParentRefs (bool includeMetaEntities=true) const |
Retrieve all parents by traversing the whole hierarchy. More... | |
virtual std::vector< std::string > | getAllParentsAsStringList () const |
EntityAttributeBasePtr | getAttribute (const ::std::string &attrName, const ::Ice::Current &=Ice::emptyCurrent) const override |
Retrieve attribute from entity. More... | |
memoryx::NameList | getAttributeNames (const ::Ice::Current &=Ice::emptyCurrent) const override |
Retrieve list of all attribute names. More... | |
virtual armarx::VariantPtr | getAttributeValue (const ::std::string &attrName) const |
Retrieve value of an attribute from entity. More... | |
virtual EntityRefBaseList | getDirectParentRefs () const |
Retrieve parent entity references. More... | |
::std::string | getId (const ::Ice::Current &=Ice::emptyCurrent) const override |
Retrieve id of this entity which is an integer in string representation. More... | |
::std::string | getName (const ::Ice::Current &=Ice::emptyCurrent) const override |
Retrieve name of this entity. More... | |
template<typename T > | |
IceInternal::Handle< T > | getWrapper () |
Retrieve EntityWrapper that has previously been added with Entity::addWrapper(). More... | |
bool | hasAttribute (const ::std::string &attrName, const ::Ice::Current &=Ice::emptyCurrent) const override |
Check whether this entity has an attribute with the given name. More... | |
Ice::ObjectPtr | ice_clone () const override |
bool | isMetaEntity (const ::Ice::Current &=Ice::emptyCurrent) const override |
Indicates whether this entity only contains meta information. More... | |
void | putAttribute (const ::memoryx::EntityAttributeBasePtr &attr, const ::Ice::Current &=Ice::emptyCurrent) override |
Store attribute in entity. More... | |
template<typename T > | |
void | putAttribute (const std::string &attrName, T attrValue, ProbabilityMeasureBasePtr uncertainty=ProbabilityMeasureBasePtr()) |
Create and store attribute from name, value, and optionally uncertainty measure. More... | |
void | removeAttribute (const ::std::string &attrName, const ::Ice::Current &=Ice::emptyCurrent) override |
Remove attribute with given name from entity. More... | |
void | serialize (const armarx::ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) const override |
Subclasses should use serializable attributes and consider these methods final. More... | |
virtual void | setDirectParentRefs (const EntityRefBaseList &entityRefs) |
Replace parent entity references. More... | |
void | setId (const ::std::string &id, const ::Ice::Current &=Ice::emptyCurrent) override |
Set id of this entity. More... | |
void | setMetaEntity (bool isMetaEntity, const ::Ice::Current &=Ice::emptyCurrent) override |
Mark this entity as meta (i.e. More... | |
void | setName (const ::std::string &name, const ::Ice::Current &=Ice::emptyCurrent) override |
Set name of this entity. More... | |
Static Public Member Functions | |
static EntityPtr | CreateGenericEntity () |
Creates an entity without any convenience getter/setter functions. More... | |
Protected Member Functions | |
Entity () | |
Entity (const Entity &source) | |
void | ice_postUnmarshal () override |
void | ice_preMarshal () override |
void | output (std::ostream &stream) const |
~Entity () override | |
Protected Attributes | |
std::mutex | attributesMutex |
std::shared_mutex | entityMutex |
AbstractEntityWrapperBaseList | wrappers |
std::recursive_mutex | wrappersMutex |
Friends | |
template<class BaseClass , class VariantClass > | |
class | armarx::GenericFactory |
std::ostream & | operator<< (std::ostream &stream, const Entity &rhs) |
std::ostream & | operator<< (std::ostream &stream, const EntityBasePtr &rhs) |
std::ostream & | operator<< (std::ostream &stream, const EntityPtr &rhs) |
Entity is the superclass for all MemoryX memory chunks.
An entity can be stored within different memory types (WorkingMemory, LTM, ...) and can be serialized to a database for persistence. Each entity is identified with an id, which is unique within a scope define by the memory processes (so it depends on the memory type and entity type). Further, each entity has a friendly name identifying its content.
Entities contain an arbitrary set of attributes (see memoryx::EntityAttribute). This mechanism allows to add new attributes on the fly, without changing the declaration of the entity. Further, all subclasses of entities use this attribute mechanism to store their properties.
Convenient access to the attributes can be realized by implementing a subclass off memory::AbstractAttributeWrapper. Wrappers map the attributes to c++ functions. Further extended functionality such as grid file attachement to attributes can be implemented in the wrapper. Wrappers are registered to the entity with the addWrapper() method. Only one wrapper of a specific type can be added.
|
inlineprotected |
|
overrideprotected |
Definition at line 142 of file Entity.cpp.
|
override |
|
inline |
Add EntityWrapper to entity.
EntityWrapper provide a specific view on the entity and allow convenient c++ style access to the attributes of the entity. They can also handle associated files. See e.g. EntityWrappers::SimoxObjectWrapper
Example:
SimoxObjectWrapperPtr simoxWrapper = entity->addWrapper(new SimoxObjectWrapper(...)); ManipulationObjectPtr mo = simoxWrapper->getManipulationObject();
pointer | to wrapper |
EntityPtr clone | ( | const Ice::Current & | c = Ice::emptyCurrent | ) | const |
Definition at line 402 of file Entity.cpp.
|
static |
Creates an entity without any convenience getter/setter functions.
This should only be used with GenericSegments (
Definition at line 42 of file Entity.cpp.
|
override |
Subclasses should use serializable attributes and consider these methods final.
Exemplary JSON deserialization:
Definition at line 470 of file Entity.cpp.
|
override |
equals computes if two Entity instances are equal.
Attributes of both Entities in the order Id, name, and attributes have to match in order to be considered equal.
otherEntity | the Entity to compare with |
Definition at line 360 of file Entity.cpp.
|
override |
equalsAttributes computes if two Entity instances are equal.
Attributes of both Entities in the order name and attributes have to match in order to be considered equal.
otherEntity | the Entity to compare with |
Definition at line 369 of file Entity.cpp.
|
virtual |
Retrieve all parents by traversing the whole hierarchy.
Definition at line 227 of file Entity.cpp.
|
virtual |
|
override |
Retrieve attribute from entity.
If attribute is not present, a new attribute is returned. See Entity::hasAttribute()
attrName | name of the attribute |
Definition at line 293 of file Entity.cpp.
|
override |
Retrieve list of all attribute names.
Definition at line 346 of file Entity.cpp.
|
virtual |
Retrieve value of an attribute from entity.
If attribute is not present, a new variant is returned. See Entity::hasAttribute()
attrName | name of the attribute |
Definition at line 308 of file Entity.cpp.
|
virtual |
Retrieve parent entity references.
Definition at line 208 of file Entity.cpp.
|
override |
Retrieve id of this entity which is an integer in string representation.
Id is unique within one memory segment and is returned by e.g. WorkingMemorySegment::addEntity()
Definition at line 161 of file Entity.cpp.
|
override |
Retrieve name of this entity.
Definition at line 173 of file Entity.cpp.
|
inline |
Retrieve EntityWrapper that has previously been added with Entity::addWrapper().
|
override |
Check whether this entity has an attribute with the given name.
attrName | name of the attribute |
Definition at line 339 of file Entity.cpp.
|
override |
|
overrideprotected |
Definition at line 433 of file Entity.cpp.
|
overrideprotected |
Definition at line 421 of file Entity.cpp.
|
override |
Indicates whether this entity only contains meta information.
Definition at line 185 of file Entity.cpp.
|
protected |
Definition at line 409 of file Entity.cpp.
|
override |
Store attribute in entity.
Name is taken from attribute member. Overwrites attribute with the same name if present.
attr | pointer to attribute |
Definition at line 327 of file Entity.cpp.
|
inline |
Create and store attribute from name, value, and optionally uncertainty measure.
Overwrites attribute with the same name if present.
attrName | name of the attribute |
attrValue | value of the attribute |
uncertainty | probability measure |
Definition at line 350 of file Entity.h.
|
override |
Remove attribute with given name from entity.
attrName | name of the attribute |
Definition at line 333 of file Entity.cpp.
|
override |
Subclasses should use serializable attributes and consider these methods final.
Exemplary JSON serialization:
Definition at line 441 of file Entity.cpp.
|
virtual |
Replace parent entity references.
entityRefs | new parent entity references |
Definition at line 276 of file Entity.cpp.
|
override |
Set id of this entity.
Id is usually set by adding the entity to a memory segment.
id | as string |
Definition at line 167 of file Entity.cpp.
|
override |
Mark this entity as meta (i.e.
it only contains meta information)
isMetaEntity |
Definition at line 196 of file Entity.cpp.
|
override |
Set name of this entity.
name |
Definition at line 179 of file Entity.cpp.
|
friend |
|
friend |
|
friend |
|
friend |