32 #include <MemoryX/interface/core/EntityBase.h>
33 #include <MemoryX/interface/memorytypes/MemoryEntities.h>
34 #include <MemoryX/interface/memorytypes/MemorySegments.h>
40 virtual public PersistentRelationSegmentBase
45 bool useMongoIds =
true) :
47 PersistentRelationSegmentBase()
53 const ::Ice::Current& = Ice::emptyCurrent)
const override
55 return RelationBasePtr::dynamicCast(getEntityById(
id));
60 const ::Ice::Current& = Ice::emptyCurrent)
const override
62 EntityBaseList rels = getEntitiesByAttrValue(
"name", name);
65 for (EntityBaseList::const_iterator it = rels.begin(); it != rels.end(); ++it)
67 RelationBasePtr rel = RelationBasePtr::dynamicCast(*it);
68 result.push_back(rel);
79 for (
const auto&
id : getAllEntityIds())
81 RelationBasePtr rel = RelationBasePtr::dynamicCast(getEntityById(
id));
83 if (rel->getSign() ==
sign)
85 result.push_back(rel);
94 const ::Ice::Current& = Ice::emptyCurrent)
const override
98 for (
const auto&
id : getAllEntityIds())
100 RelationBasePtr rel = RelationBasePtr::dynamicCast(getEntityById(
id));
101 EntityRefList relEntities = rel->getEntities();
103 for (EntityRefBasePtr& relEntity : relEntities)
105 if (relEntity->entityId == entityId)
107 result.push_back(rel);
118 const ::Ice::Current& = Ice::emptyCurrent)
const override
120 return getRelationsByEntityId(entityRef->entityId);
125 const ::Ice::Current& = Ice::emptyCurrent)
const override
127 return getRelationsByAttrValues(entities);
132 const EntityRefList& entities,
134 const ::Ice::Current& = Ice::emptyCurrent)
const override
136 RelationBasePtr result;
137 RelationList resultList = getRelationsByAttrValues(entities, name,
true,
sign);
139 if (resultList.size() != 0)
141 result = resultList[0];
149 getRelationsByAttrValues(
const EntityRefList& entities,
150 const std::string& name =
"",
151 bool considerSign =
false,
153 const ::Ice::Current& = Ice::emptyCurrent)
const
157 for (
const auto& entity : getAllEntities())
159 RelationBasePtr rel = RelationBasePtr::dynamicCast(entity);
161 if (!name.empty() && (rel->getName() != name))
166 if (considerSign && (
sign != rel->getSign()))
171 EntityRefList relEntities = rel->getEntities();
173 bool foundArgs =
true;
175 for (
const auto& entityRef : entities)
177 foundArgs &= std::find_if(relEntities.cbegin(),
179 [&](
const memoryx::EntityRefBasePtr& e) {
180 return entityRef->equals(e);
181 }) != relEntities.cend();
186 result.push_back(rel);
198 throw armarx::LocalException(
"Not yet implemented");
204 throw armarx::LocalException(
"Not yet implemented");