24 #include <Ice/Connection.h>
25 #include <Ice/ObjectAdapter.h>
26 #include <IceUtil/UUID.h>
47 std::unique_lock lock(tokenMutex);
49 if (!lockToken.empty() &&
c.ctx.count(
"token") > 0 &&
c.ctx.at(
"token") == lockToken)
59 std::unique_lock lock(tokenMutex);
61 if (!lockToken.empty() &&
c.ctx.count(
"token") > 0 &&
c.ctx.at(
"token") == lockToken)
71 EntityBasePtr entity = getEntityById(
id);
74 throw EntityNotFoundException();
77 json->setIceObject(
"entity", entity);
78 return json->asString(
true);
83 bool includeMetaEntities,
84 const Ice::Current&
c)
const
86 auto comp = [](
const EntityBasePtr& e1,
const EntityBasePtr& e2)
87 {
return e1->getId() < e2->getId(); };
89 std::set<EntityBasePtr, decltype(comp)> result(comp);
90 std::set<EntityBasePtr, decltype(comp)> searchList(comp);
91 EntityPtr root = EntityPtr::dynamicCast(getEntityById(
id,
c));
92 searchList.insert(root);
94 auto all = getAllEntities(
c);
95 std::string attribName =
"parentEntityRefs";
97 while (!searchList.empty())
99 EntityPtr curParent = EntityPtr::dynamicCast(*searchList.begin());
100 auto curParentRef = getEntityRefById(curParent->getId(),
c);
101 searchList.erase(searchList.begin());
102 for (EntityBasePtr& entity :
all)
104 if (!entity->hasAttribute(attribName,
c))
108 auto attr = entity->getAttribute(attribName,
c);
109 for (
int i = 0; i < attr->size(); ++i)
112 armarx::VariantPtr::dynamicCast(attr->getValueAt(i,
c))->get<
EntityRef>();
113 if (ref->equals(curParentRef))
115 ARMARX_INFO_S << ref->entityName <<
" is parent of " << entity->getName();
116 if (result.count(entity) ==
119 searchList.insert(entity);
121 result.insert(entity);
127 if (!includeMetaEntities)
129 EntityBaseList filteredResult;
130 std::copy_if(result.begin(),
132 std::back_inserter(filteredResult),
133 [](
const EntityBasePtr& entity) { return !entity->isMetaEntity(); });
134 return filteredResult;
136 return EntityBaseList(result.begin(), result.end());
141 bool includeMetaEntities,
142 const Ice::Current&
c)
const
144 auto entity = getEntityByName(entityName);
151 return EntityBaseList();
162 lockToken = lock->token = IceUtil::generateUUID();
166 EntityMemorySegmentInterfacePrx::uncheckedCast(
c.adapter->createProxy(
c.id));
174 lock->keepAliveIntervalMs * 2,
194 throw InvalidLockTokenException();
215 throw InvalidLockTokenException();
228 const Ice::Current&
c)
234 throw InvalidLockTokenException();
261 <<
"' did not receive keep-alive in time ("
262 << age.toMilliSecondsDouble()
264 <<
" ) - unlocking segment";
295 segment->unlockSegmentWithToken(this->token);
321 segment->keepLockAlive(this->token);