Entity Class Reference

#include <MemoryX/core/entity/Entity.h>

+ Inheritance diagram for Entity:

Public Member Functions

void __decRef () override
 
template<typename T >
IceInternal::Handle< TaddWrapper (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< TgetWrapper ()
 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)
 

Detailed Description

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.

Definition at line 246 of file Entity.h.

Constructor & Destructor Documentation

◆ Entity() [1/2]

Entity ( const Entity source)
protected

Definition at line 34 of file Entity.cpp.

+ Here is the call graph for this function:

◆ Entity() [2/2]

Entity ( )
inlineprotected

Definition at line 498 of file Entity.h.

+ Here is the caller graph for this function:

◆ ~Entity()

~Entity ( )
overrideprotected

Definition at line 142 of file Entity.cpp.

Member Function Documentation

◆ __decRef()

void __decRef ( )
override

Definition at line 91 of file Entity.cpp.

+ Here is the call graph for this function:

◆ addWrapper()

IceInternal::Handle<T> addWrapper ( T wrapper)
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();

Parameters
pointerto wrapper

Definition at line 408 of file Entity.h.

◆ clone()

EntityPtr clone ( const Ice::Current &  c = Ice::emptyCurrent) const

Definition at line 402 of file Entity.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CreateGenericEntity()

EntityPtr CreateGenericEntity ( )
static

Creates an entity without any convenience getter/setter functions.

This should only be used with GenericSegments (

See also
memoryx::MemoryInterface::addGenericSegment()).

Definition at line 42 of file Entity.cpp.

+ Here is the call graph for this function:

◆ deserialize()

void deserialize ( const armarx::ObjectSerializerBasePtr &  serializer,
const ::Ice::Current &  c = Ice::emptyCurrent 
)
override

Subclasses should use serializable attributes and consider these methods final.

Exemplary JSON deserialization:

EntityPtr entity = new EntityPtr;
armarx::JSONObjectPtr jsonSerializer = new armarx::JSONObject(getIceManager()->getCommunicator());
jsonSerializer->fromString(json);
entity->deserialize(jsonSerializer);

Definition at line 470 of file Entity.cpp.

+ Here is the call graph for this function:

◆ equals()

bool equals ( const EntityBasePtr &  otherEntity,
const ::Ice::Current &  = Ice::emptyCurrent 
) const
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.

See also
Entity::equalsAttributes
Parameters
otherEntitythe Entity to compare with
Returns
true if both entities are equal, false otherise

Definition at line 360 of file Entity.cpp.

+ Here is the call graph for this function:

◆ equalsAttributes()

bool equalsAttributes ( const EntityBasePtr &  otherEntity,
const ::Ice::Current &  = Ice::emptyCurrent 
) const
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.

See also
Entity::equals
Parameters
otherEntitythe Entity to compare with
Returns
true if both entities are equal, false otherise

Definition at line 369 of file Entity.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAllParentRefs()

EntityRefBaseList getAllParentRefs ( bool  includeMetaEntities = true) const
virtual

Retrieve all parents by traversing the whole hierarchy.

Returns
all parents

Definition at line 227 of file Entity.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAllParentsAsStringList()

std::vector< std::string > getAllParentsAsStringList ( ) const
virtual

Definition at line 264 of file Entity.cpp.

+ Here is the call graph for this function:

◆ getAttribute()

EntityAttributeBasePtr getAttribute ( const ::std::string &  attrName,
const ::Ice::Current &  = Ice::emptyCurrent 
) const
override

Retrieve attribute from entity.

If attribute is not present, a new attribute is returned. See Entity::hasAttribute()

Parameters
attrNamename of the attribute
Returns
shared pointer to attribute

Definition at line 293 of file Entity.cpp.

◆ getAttributeNames()

memoryx::NameList getAttributeNames ( const ::Ice::Current &  = Ice::emptyCurrent) const
override

Retrieve list of all attribute names.

Returns
list of names

Definition at line 346 of file Entity.cpp.

+ Here is the caller graph for this function:

◆ getAttributeValue()

armarx::VariantPtr getAttributeValue ( const ::std::string &  attrName) const
virtual

Retrieve value of an attribute from entity.

If attribute is not present, a new variant is returned. See Entity::hasAttribute()

Parameters
attrNamename of the attribute
Returns
shared pointer to variant containing the value

Definition at line 308 of file Entity.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDirectParentRefs()

EntityRefBaseList getDirectParentRefs ( ) const
virtual

Retrieve parent entity references.

Returns
parent entity references

Definition at line 208 of file Entity.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getId()

std::string getId ( const ::Ice::Current &  = Ice::emptyCurrent) const
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()

Returns
id as string

Definition at line 161 of file Entity.cpp.

+ Here is the caller graph for this function:

◆ getName()

std::string getName ( const ::Ice::Current &  = Ice::emptyCurrent) const
override

Retrieve name of this entity.

Returns
name

Definition at line 173 of file Entity.cpp.

+ Here is the caller graph for this function:

◆ getWrapper()

IceInternal::Handle<T> getWrapper ( )
inline

Retrieve EntityWrapper that has previously been added with Entity::addWrapper().

See also
addWrapper
Returns
NULL if no wrapper of type T

Definition at line 437 of file Entity.h.

◆ hasAttribute()

bool hasAttribute ( const ::std::string &  attrName,
const ::Ice::Current &  = Ice::emptyCurrent 
) const
override

Check whether this entity has an attribute with the given name.

Parameters
attrNamename of the attribute
Returns
attribute available

Definition at line 339 of file Entity.cpp.

+ Here is the caller graph for this function:

◆ ice_clone()

Ice::ObjectPtr ice_clone ( ) const
override

Definition at line 397 of file Entity.cpp.

+ Here is the call graph for this function:

◆ ice_postUnmarshal()

void ice_postUnmarshal ( )
overrideprotected

Definition at line 433 of file Entity.cpp.

◆ ice_preMarshal()

void ice_preMarshal ( )
overrideprotected

Definition at line 421 of file Entity.cpp.

◆ isMetaEntity()

bool isMetaEntity ( const ::Ice::Current &  = Ice::emptyCurrent) const
override

Indicates whether this entity only contains meta information.

Returns
isMetaEntity

Definition at line 185 of file Entity.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ output()

void output ( std::ostream &  stream) const
protected

Definition at line 409 of file Entity.cpp.

◆ putAttribute() [1/2]

void putAttribute ( const ::memoryx::EntityAttributeBasePtr &  attr,
const ::Ice::Current &  = Ice::emptyCurrent 
)
override

Store attribute in entity.

Name is taken from attribute member. Overwrites attribute with the same name if present.

Parameters
attrpointer to attribute

Definition at line 327 of file Entity.cpp.

◆ putAttribute() [2/2]

void putAttribute ( const std::string &  attrName,
T  attrValue,
ProbabilityMeasureBasePtr  uncertainty = ProbabilityMeasureBasePtr() 
)
inline

Create and store attribute from name, value, and optionally uncertainty measure.

Overwrites attribute with the same name if present.

Parameters
attrNamename of the attribute
attrValuevalue of the attribute
uncertaintyprobability measure

Definition at line 350 of file Entity.h.

+ Here is the call graph for this function:

◆ removeAttribute()

void removeAttribute ( const ::std::string &  attrName,
const ::Ice::Current &  = Ice::emptyCurrent 
)
override

Remove attribute with given name from entity.

Parameters
attrNamename of the attribute

Definition at line 333 of file Entity.cpp.

+ Here is the caller graph for this function:

◆ serialize()

void serialize ( const armarx::ObjectSerializerBasePtr &  serializer,
const ::Ice::Current &  c = Ice::emptyCurrent 
) const
override

Subclasses should use serializable attributes and consider these methods final.

Exemplary JSON serialization:

EntityPtr entity = new Entity;
entity->serialize(jsonSerializer);
ARMARX_ERROR << "Entity: " << jsonSerializer->asString(true);

Definition at line 441 of file Entity.cpp.

+ Here is the call graph for this function:

◆ setDirectParentRefs()

void setDirectParentRefs ( const EntityRefBaseList &  entityRefs)
virtual

Replace parent entity references.

Parameters
entityRefsnew parent entity references

Definition at line 276 of file Entity.cpp.

+ Here is the call graph for this function:

◆ setId()

void setId ( const ::std::string &  id,
const ::Ice::Current &  = Ice::emptyCurrent 
)
override

Set id of this entity.

Id is usually set by adding the entity to a memory segment.

Parameters
idas string

Definition at line 167 of file Entity.cpp.

+ Here is the caller graph for this function:

◆ setMetaEntity()

void setMetaEntity ( bool  isMetaEntity,
const ::Ice::Current &  = Ice::emptyCurrent 
)
override

Mark this entity as meta (i.e.

it only contains meta information)

Parameters
isMetaEntity

Definition at line 196 of file Entity.cpp.

+ Here is the call graph for this function:

◆ setName()

void setName ( const ::std::string &  name,
const ::Ice::Current &  = Ice::emptyCurrent 
)
override

Set name of this entity.

Parameters
name

Definition at line 179 of file Entity.cpp.

+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ armarx::GenericFactory

friend class armarx::GenericFactory
friend

Definition at line 496 of file Entity.h.

◆ operator<< [1/3]

std::ostream& operator<< ( std::ostream &  stream,
const Entity rhs 
)
friend

Definition at line 517 of file Entity.h.

◆ operator<< [2/3]

std::ostream& operator<< ( std::ostream &  stream,
const EntityBasePtr &  rhs 
)
friend

Definition at line 529 of file Entity.h.

◆ operator<< [3/3]

std::ostream& operator<< ( std::ostream &  stream,
const EntityPtr rhs 
)
friend

Definition at line 523 of file Entity.h.

Member Data Documentation

◆ attributesMutex

std::mutex attributesMutex
mutableprotected

Definition at line 504 of file Entity.h.

◆ entityMutex

std::shared_mutex entityMutex
mutableprotected

Definition at line 505 of file Entity.h.

◆ wrappers

AbstractEntityWrapperBaseList wrappers
protected

Definition at line 502 of file Entity.h.

◆ wrappersMutex

std::recursive_mutex wrappersMutex
mutableprotected

Definition at line 506 of file Entity.h.


The documentation for this class was generated from the following files:
memoryx::Entity::Entity
Entity()
Definition: Entity.h:498
armarx::JSONObject
The JSONObject class is used to represent and (de)serialize JSON objects.
Definition: JSONObject.h:43
IceInternal::Handle< JSONObject >
ARMARX_ERROR
#define ARMARX_ERROR
Definition: Logging.h:189
memoryx::EntityPtr
IceInternal::Handle< Entity > EntityPtr
Typedef of EntityPtr as IceInternal::Handle<Entity> for convenience.
Definition: Entity.h:46