PersistentEntitySegment.cpp
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package MemoryX::Core
17 * @author Alexey Kozlov ( kozlov at kit dot edu)
18 * @date 2013
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 
24 #include "SegmentedMemory.h"
26 #include <ArmarXCore/interface/serialization/JSONSerialization.h>
29 
30 #include <IceUtil/UUID.h>
31 #include <Ice/ObjectAdapter.h>
33 
34 #include <iostream>
35 
38 
39 namespace memoryx
40 {
42  bool useMongoIds /* = true */) :
43  useMongoIds(useMongoIds)
44  {
46  setSingleRWCollection(entityCollection);
47  }
48 
50  {
51  }
52 
53  NameList PersistentEntitySegment::getReadCollectionsNS(const ::Ice::Current& c) const
54  {
55  memoryx::NameList result;
56  auto lock = getReadLock(c);
57 
58  for (CollectionPrxList::const_iterator it = readCollections.begin(); it != readCollections.end(); ++it)
59  {
60  if (!*it)
61  {
62  continue;
63  }
64 
65  result.push_back((*it)->getNS());
66  }
67 
68  return result;
69  }
70 
72  {
73  ARMARX_INFO_S << "Clearing read collections";
74  auto lock = getWriteLock(c);
75  readCollections.clear();
76  }
77 
78  void PersistentEntitySegment::addReadCollection(const CollectionInterfacePrx& coll, const ::Ice::Current& c)
79  {
80  if (coll)
81  {
83 
84  bool found = false;
85  const std::string newName = coll->getNS();
86 
87  for (CollectionPrxList::iterator it = readCollections.begin(); it != readCollections.end(); it++)
88  {
90 
91  if (newName == (*it)->getNS())
92  {
93  found = true;
94  break;
95  }
96  }
97 
98  if (!found)
99  {
100  readCollections.push_back(coll);
101  ARMARX_INFO_S << coll->getNS() << " collection added to list";
102  }
103  else
104  {
105  ARMARX_INFO_S << coll->getNS() << " collection already in list";
106  }
107  }
108  }
109 
110  std::string PersistentEntitySegment::getWriteCollectionNS(const ::Ice::Current& c) const
111  {
112  return writeCollection->getNS();
113  }
114 
115  void PersistentEntitySegment::setWriteCollection(const CollectionInterfacePrx& coll, const ::Ice::Current& c)
116  {
117  if (coll)
118  {
119  writeCollection = coll;
120  }
121  }
122 
123  void PersistentEntitySegment::setSingleRWCollection(const CollectionInterfacePrx& coll, const ::Ice::Current& c)
124  {
125  setWriteCollection(coll);
127  addReadCollection(coll);
128  }
129 
130  std::string PersistentEntitySegment::getObjectTypeId(const ::Ice::Current& c) const
131  {
132  return objectTypeId;
133  }
134 
135  std::string PersistentEntitySegment::addEntity(const EntityBasePtr& entity,
136  const ::Ice::Current& c)
137  {
139  return addEntityThreadUnsafe(entity);
140  }
141 
142  std::string PersistentEntitySegment::addEntityThreadUnsafe(const EntityBasePtr& entity)
143  {
144  DBStorableData dbEntity;
145  {
146  std::unique_lock lock(dbSerializerMutex);
147  dbEntity = dbSerializer->serializeIceObject(entity);
148  }
149  return writeCollection->insert(dbEntity);
150 
151  }
152 
153  std::string PersistentEntitySegment::upsertEntity(const std::string& entityId, const EntityBasePtr& entity, const Ice::Current& c)
154  {
156  return upsertEntityThreadUnsafe(entityId, entity);
157  }
158 
159  std::string PersistentEntitySegment::upsertEntityThreadUnsafe(const std::string& entityId, const EntityBasePtr& entity)
160  {
161  if (hasEntityByIdThreadUnsafe(entityId))
162  {
163  updateEntityThreadUnsafe(entityId, entity);
164  return entityId;
165  }
166  else
167  {
168  return addEntityThreadUnsafe(entity);
169  }
170 
171  }
172 
173  EntityIdList PersistentEntitySegment::upsertEntityList(const EntityBaseList& entityList, const Ice::Current& c)
174  {
176  return upsertEntityListThreadUnsafe(entityList);
177  }
178 
179  EntityIdList PersistentEntitySegment::upsertEntityListThreadUnsafe(const EntityBaseList& entityList)
180  {
181  EntityIdList entityIds(entityList.size(), "");
182 
183  for (size_t i = 0; i < entityList.size(); i++)
184  {
185  try
186  {
187  entityIds[i] = upsertEntityThreadUnsafe(entityList[i]->getId(), entityList[i]);
188  }
189  catch (const memoryx::InvalidEntityException& e)
190  {
191  // don't handle this exception but return an empty string as ID for this specific entity
192  }
193  }
194 
195  return entityIds;
196  }
197 
198 
199  std::string PersistentEntitySegment::upsertEntityByName(const std::string& entityName, const EntityBasePtr& entity, const Ice::Current& c)
200  {
202  return upsertEntityByNameThreadUnsafe(entityName, entity);
203  }
204 
205  std::string PersistentEntitySegment::upsertEntityByNameThreadUnsafe(const std::string& entityName, const EntityBasePtr& entity)
206  {
207  auto oldEntity = getEntityByNameThreadUnsafe(entityName);
208  if (oldEntity)
209  {
210  updateEntityThreadUnsafe(oldEntity->getId(), entity);
211  return oldEntity->getId();
212  }
213  else
214  {
215  return addEntityThreadUnsafe(entity);
216  }
217 
218  }
219 
220 
221  EntityIdList PersistentEntitySegment::addEntityList(const EntityBaseList& entityList, const Ice::Current& c)
222  {
224  return addEntityListThreadUnsafe(entityList);
225  }
226 
227  EntityIdList PersistentEntitySegment::addEntityListThreadUnsafe(const EntityBaseList& entityList)
228  {
229  DBStorableDataList dbEntities;
230  dbEntities.reserve(entityList.size());
231 
232  for (size_t i = 0; i < entityList.size(); i++)
233  {
234  std::unique_lock lock(dbSerializerMutex);
235 
236  dbEntities.push_back(dbSerializer->serializeIceObject(entityList[i]));
237  }
238 
239  return writeCollection->insertList(dbEntities);
240 
241  }
242 
243 
244  void PersistentEntitySegment::updateEntity(const ::std::string& entityId, const EntityBasePtr& update, const ::Ice::Current& c)
245  {
247  updateEntityThreadUnsafe(entityId, update);
248  }
249 
250  void PersistentEntitySegment::updateEntityThreadUnsafe(const std::string& entityId, const EntityBasePtr& update)
251  {
252  update->setId(entityId);
253  DBStorableData dbEntity;
254  {
255  std::unique_lock lock(dbSerializerMutex);
256  dbEntity = dbSerializer->serializeIceObject(update);
257  }
258 
259  writeCollection->update(dbEntity);
260 
261  }
262 
263  void PersistentEntitySegment::removeEntity(const ::std::string& entityId,
264  const ::Ice::Current& c)
265  {
267  removeEntityThreadUnsafe(entityId);
268  }
269 
270  void PersistentEntitySegment::removeEntityThreadUnsafe(const std::string& entityId)
271  {
272  if (useMongoIds)
273  {
274  writeCollection->removeByMongoId(entityId);
275  }
276  else
277  {
278  writeCollection->removeByFieldValue("_id", entityId);
279  }
280 
281  }
282 
284  {
286 
287  auto ids = getAllEntityIdsThreadUnsafe();
288 
289  for (auto& id : ids)
290  {
292  }
293  }
294 
295  bool PersistentEntitySegment::hasEntityById(const std::string& entityId, const Ice::Current& c) const
296  {
298  return hasEntityByIdThreadUnsafe(entityId);
299  }
300 
301  bool PersistentEntitySegment::hasEntityByIdThreadUnsafe(const std::string& entityId) const
302  {
303  if (entityId.empty() || entityId.size() != 24)
304  {
305  return false;
306  }
307  try
308  {
309  for (CollectionPrxList::const_iterator it = readCollections.begin(); it != readCollections.end(); ++it)
310  {
311  if (!*it)
312  {
313  continue;
314  }
315 
316  const DBStorableData dbEntity = useMongoIds ?
317  (*it)->findByMongoId(entityId) : (*it)->findOneByFieldValue("_id", entityId);
318 
319  if (!dbEntity.JSON.empty())
320  {
321  return true;
322  }
323  }
324  }
325  catch (...)
326  {
327 
328  }
329 
330  return false;
331 
332  }
333 
334  bool PersistentEntitySegment::hasEntityByName(const std::string& entityName, const Ice::Current& c) const
335  {
337  return hasEntityByNameThreadUnsafe(entityName);
338  }
339 
340  bool PersistentEntitySegment::hasEntityByNameThreadUnsafe(const std::string& entityName) const
341  {
342  for (CollectionPrxList::const_iterator it = readCollections.begin(); it != readCollections.end(); ++it)
343  {
344  CollectionInterfacePrx coll = *it;
345 
346  if (!coll)
347  {
348  continue;
349  }
350 
351  const DBStorableData dbEntity = coll->findOneByFieldValue("name", entityName);
352 
353  if (!dbEntity.JSON.empty())
354  {
355  return true;
356  }
357  }
358 
359  return false;
360 
361  }
362 
363  EntityBasePtr PersistentEntitySegment::getEntityById(const ::std::string& entityId,
364  const ::Ice::Current& c) const
365  {
367 
368  return getEntityByIdThreadUnsafe(entityId);
369  }
370 
371  EntityBasePtr PersistentEntitySegment::getEntityByIdThreadUnsafe(const std::string& entityId) const
372  {
373  if (entityId.empty())
374  {
375  ARMARX_ERROR_S << "Entity id must not be empty!";
376  return EntityBasePtr();
377  }
378 
379 
380  for (CollectionPrxList::const_iterator it = readCollections.begin(); it != readCollections.end(); ++it)
381  {
382  if (!*it)
383  {
384  continue;
385  }
386 
387  const DBStorableData dbEntity = useMongoIds ?
388  (*it)->findByMongoId(entityId) : (*it)->findOneByFieldValue("_id", entityId);
389 
390  if (!dbEntity.JSON.empty())
391  {
392  return deserializeEntity(dbEntity);
393  }
394  }
395 
396  return EntityBasePtr();
397  }
398 
399  EntityBasePtr PersistentEntitySegment::getEntityByName(const ::std::string& name,
400  const ::Ice::Current& c) const
401  {
403  return getEntityByNameThreadUnsafe(name);
404  }
405 
406  EntityBasePtr PersistentEntitySegment::getEntityByNameThreadUnsafe(const std::string& name) const
407  {
408  for (CollectionPrxList::const_iterator it = readCollections.begin(); it != readCollections.end(); ++it)
409  {
410  if (!*it)
411  {
412  continue;
413  }
414 
415  const DBStorableData dbEntity = (*it)->findOneByFieldValue("name", name);
416 
417  if (!dbEntity.JSON.empty())
418  {
419  return deserializeEntity(dbEntity);
420  }
421  }
422 
423  return EntityBasePtr();
424 
425  }
426 
427  EntityBaseList PersistentEntitySegment::getEntitiesByAttrValue(const ::std::string& attrName, const ::std::string& attrValue, const ::Ice::Current& c) const
428  {
429  EntityBaseList result;
430  const std::string fieldName = "attrs." + attrName + ".value.value";
432 
433  for (CollectionPrxList::const_iterator itColl = readCollections.begin(); itColl != readCollections.end(); ++itColl)
434  {
435  if (!*itColl)
436  {
437  continue;
438  }
439 
440  const DBStorableDataList dbEntities = (*itColl)->findByFieldValue(fieldName, attrValue);
441 
442  for (DBStorableDataList::const_iterator itEntity = dbEntities.begin(); itEntity != dbEntities.end(); ++itEntity)
443  {
444  EntityBasePtr entity = deserializeEntity(*itEntity);
445 
446  if (entity)
447  {
448  result.push_back(entity);
449  }
450  }
451  }
452 
453  return result;
454  }
455 
456 
457  EntityBaseList PersistentEntitySegment::getEntitiesByAttrValueList(const ::std::string& attrName, const NameList& attrValueList, const ::Ice::Current& c) const
458  {
459  EntityBaseList result;
460  const std::string fieldName = "attrs." + attrName + ".value.value";
462 
463  for (CollectionPrxList::const_iterator itColl = readCollections.begin(); itColl != readCollections.end(); ++itColl)
464  {
465  if (!*itColl)
466  {
467  continue;
468  }
469 
470  const DBStorableDataList dbEntities = (*itColl)->findByFieldValueList(fieldName, attrValueList);
471 
472  for (DBStorableDataList::const_iterator itEntity = dbEntities.begin(); itEntity != dbEntities.end(); ++itEntity)
473  {
474  EntityBasePtr entity = deserializeEntity(*itEntity);
475 
476  if (entity)
477  {
478  result.push_back(entity);
479  }
480  }
481  }
482 
483  return result;
484  }
485 
486 
487 
488 
489  Ice::Int PersistentEntitySegment::size(const ::Ice::Current& c) const
490  {
491  Ice::Int result = 0;
493 
494  for (CollectionPrxList::const_iterator it = readCollections.begin(); it != readCollections.end(); ++it)
495  {
496  if (!*it)
497  {
498  continue;
499  }
500 
501  result += (*it)->count();
502  }
503 
504  return result;
505  }
506 
507  void PersistentEntitySegment::print(const ::Ice::Current& c) const
508  {
509  //TODO implement
510  }
511 
512 
513  void PersistentEntitySegment::clear(const ::Ice::Current& c)
514  {
515  writeCollection->clear();
516  }
517 
519  {
520  Ice::Identity id;
521  id.name = (parentMemory ? parentMemory->getMemoryName() : "") + "_" + segmentName;
522  return id;
523  }
524 
525  std::string PersistentEntitySegment::getSegmentName(const Ice::Current&) const
526  {
527  return segmentName;
528  }
529 
530  EntityIdList PersistentEntitySegment::getAllEntityIds(const ::Ice::Current& c) const
531  {
534  }
535 
537  {
538  EntityIdList result;
539 
540  for (CollectionPrxList::const_iterator it = readCollections.begin(); it != readCollections.end(); ++it)
541  {
542  if (!*it)
543  {
544  continue;
545  }
546 
547  const EntityIdList collIds = (*it)->findAllIds();
548  result.insert(result.end(), collIds.begin(), collIds.end());
549  }
550  return result;
551 
552  }
553 
554  EntityBaseList PersistentEntitySegment::getAllEntities(const ::Ice::Current& c) const
555  {
556  EntityBaseList result;
558 
559  for (const auto& col : readCollections)
560  {
561  if (!col)
562  {
563  continue;
564  }
565 
566  for (const auto& dbEntity : col->findAll())
567  {
568  auto entity = deserializeEntity(dbEntity);
569 
570  if (entity)
571  {
572  result.push_back(std::move(entity));
573  }
574  }
575  }
576 
577  return result;
578  }
579 
580  IdEntityMap PersistentEntitySegment::getIdEntityMap(const ::Ice::Current& c) const
581  {
582  IdEntityMap result;
583 
584  for (auto&& entity : getAllEntities())
585  {
586  result.insert({entity->getId(), std::move(entity)});
587  }
588 
589  return result;
590  }
591 
592  EntityBasePtr PersistentEntitySegment::deserializeEntity(const DBStorableData& dbEntity) const
593  {
594  std::unique_lock lock(dbSerializerMutex);
595  EntityBasePtr entity;
596 
597  try
598  {
599  entity = EntityBasePtr::dynamicCast(dbSerializer->deserializeIceObject(dbEntity));
600  }
601  catch (const armarx::JSONException& ex)
602  {
603  entity = EntityBasePtr();
604  }
605 
606  return entity;
607  }
608 
609 
610 
611 
612  EntityRefBasePtr memoryx::PersistentEntitySegment::getEntityRefById(const std::string& id, const Ice::Current& c) const
613  {
614  auto entity = getEntityById(id);
615 
616  if (!entity)
617  {
618  return NULL;
619  }
620 
621  auto proxy = EntityMemorySegmentInterfacePrx::uncheckedCast(c.adapter->createProxy(getIceId()));
622  SegmentedMemoryPtr mem = SegmentedMemoryPtr::dynamicCast(parentMemory);
623  std::string memName = mem->getMemoryName();
624  auto memoryProxy = MemoryInterfacePrx::checkedCast(c.adapter->getCommunicator()->stringToProxy(memName));
625  EntityRefPtr ref = new EntityRef(entity,
626  segmentName,
627  memName,
628  memoryProxy,
629  proxy);
630  return ref;
631  }
632 
633  EntityRefBasePtr memoryx::PersistentEntitySegment::getEntityRefByName(const std::string& name, const Ice::Current& c) const
634  {
635  auto entity = getEntityByName(name);
636 
637  if (!entity)
638  {
639  return NULL;
640  }
641 
642  auto proxy = EntityMemorySegmentInterfacePrx::uncheckedCast(c.adapter->createProxy(getIceId()));
643  SegmentedMemoryPtr mem = SegmentedMemoryPtr::dynamicCast(parentMemory);
644  std::string memName = mem->getMemoryName();
645  auto memoryProxy = MemoryInterfacePrx::checkedCast(c.adapter->getCommunicator()->stringToProxy(memName));
646  EntityRefPtr ref = new EntityRef(entity,
647  segmentName,
648  memName,
649  memoryProxy,
650  proxy);
651  return ref;
652  }
653 
654 
655 
656  void PersistentEntitySegment::setEntityAttribute(const std::string& entityId, const EntityAttributeBasePtr& attribute, const Ice::Current& c)
657  {
658  EntityBasePtr entity = getEntityById(entityId);
659  if (!entity)
660  {
661  throw EntityNotFoundException();
662  }
663  entity->putAttribute(attribute);
664  DBStorableData dbEntity;
665  {
666  std::unique_lock lock(dbSerializerMutex);
667  dbEntity = dbSerializer->serializeIceObject(entity);
668  }
670 
671  writeCollection->update(dbEntity);
672  }
673 
674  void PersistentEntitySegment::setEntityAttributes(const std::string& entityId, const EntityAttributeList& attributeMap, const Ice::Current& c)
675  {
676  EntityBasePtr entity = getEntityById(entityId);
677  if (!entity)
678  {
679  throw EntityNotFoundException();
680  }
681  for (auto attribute : attributeMap)
682  {
683  entity->putAttribute(attribute);
684  }
685  {
686  DBStorableData dbEntity;
687  {
688  std::unique_lock lock(dbSerializerMutex);
689  dbEntity = dbSerializer->serializeIceObject(entity);
690  }
692  writeCollection->update(dbEntity);
693  }
694  }
695 
696 
697  void memoryx::PersistentEntitySegment::setParentMemory(const MemoryInterfacePtr& memory, const Ice::Current&)
698  {
699  this->parentMemory = memory;
700  }
701 
702  EntityRefList PersistentEntitySegment::findRefsByQuery(const std::string& query, const Ice::Current& c)
703  {
704  EntityRefList result;
706 
707  for (CollectionPrxList::const_iterator it = readCollections.begin(); it != readCollections.end(); ++it)
708  {
709  if (!*it)
710  {
711  continue;
712  }
713 
714  CollectionInterfacePrx prx = *it;
715  const DBStorableDataList data = prx->findByQuery(query);
716 
717  for (const DBStorableData& e : data)
718  {
719  EntityBasePtr entity = deserializeEntity(e);
720 
721  if (entity)
722  {
723  auto proxy = EntityMemorySegmentInterfacePrx::uncheckedCast(c.adapter->createProxy(getIceId()));
724  SegmentedMemoryPtr mem = SegmentedMemoryPtr::dynamicCast(parentMemory);
725  std::string memName = mem->getMemoryName();
726  auto memoryProxy = MemoryInterfacePrx::checkedCast(c.adapter->getCommunicator()->stringToProxy(memName));
727  EntityRefPtr ref = new EntityRef(entity,
728  segmentName,
729  memName,
730  memoryProxy,
731  proxy);
732  result.push_back(ref);
733  }
734  }
735 
736  }
737 
738  return result;
739  }
740 
741  void PersistentEntitySegment::setSegmentName(const std::string& segmentName, const Ice::Current&)
742  {
743  this->segmentName = segmentName;
744  }
745 }
memoryx::PersistentEntitySegment::setSingleRWCollection
void setSingleRWCollection(const CollectionInterfacePrx &coll, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: PersistentEntitySegment.cpp:123
memoryx::PersistentEntitySegment::getReadCollectionsNS
NameList getReadCollectionsNS(const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: PersistentEntitySegment.cpp:53
memoryx::PersistentEntitySegment::getIdEntityMap
IdEntityMap getIdEntityMap(const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: PersistentEntitySegment.cpp:580
memoryx::PersistentEntitySegment::addEntityList
EntityIdList addEntityList(const EntityBaseList &entityList, const Ice::Current &=Ice::emptyCurrent) override
addEntityList adds all entities contained in \entityList to this segment and returns a list of create...
Definition: PersistentEntitySegment.cpp:221
memoryx::PersistentEntitySegment::findRefsByQuery
EntityRefList findRefsByQuery(const std::string &query, const Ice::Current &c) override
retrieves Entity Refs that match the query.
Definition: PersistentEntitySegment.cpp:702
cyberglove_with_calib_22dof.ic
ic
Definition: cyberglove_with_calib_22dof.py:22
SegmentedMemory.h
memoryx::PersistentEntitySegment::setEntityAttributes
void setEntityAttributes(const std::string &entityId, const EntityAttributeList &attributeMap, const Ice::Current &) override
Definition: PersistentEntitySegment.cpp:674
armarx::VariantType::EntityRef
const armarx::VariantTypeId EntityRef
Definition: EntityRef.h:30
memoryx::PersistentEntitySegment::updateEntity
void updateEntity(const ::std::string &entityId, const EntityBasePtr &update, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: PersistentEntitySegment.cpp:244
memoryx::PersistentEntitySegment::dbSerializerMutex
std::recursive_mutex dbSerializerMutex
Definition: PersistentEntitySegment.h:228
memoryx::PersistentEntitySegment::setWriteCollection
void setWriteCollection(const CollectionInterfacePrx &coll, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: PersistentEntitySegment.cpp:115
JSONObject.h
memoryx::PersistentEntitySegment::parentMemory
MemoryInterfacePtr parentMemory
Definition: PersistentEntitySegment.h:221
memoryx::PersistentEntitySegment::setParentMemory
void setParentMemory(const MemoryInterfacePtr &memory, const Ice::Current &) override
Definition: PersistentEntitySegment.cpp:697
memoryx::PersistentEntitySegment::updateEntityThreadUnsafe
virtual void updateEntityThreadUnsafe(const ::std::string &entityId, const EntityBasePtr &update)
Definition: PersistentEntitySegment.cpp:250
memoryx::PersistentEntitySegment::print
void print(const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: PersistentEntitySegment.cpp:507
memoryx::PersistentEntitySegment::addEntity
std::string addEntity(const EntityBasePtr &entity, const ::Ice::Current &c=Ice::emptyCurrent) override
addEntity add new entity and return the newly generated entity ID
Definition: PersistentEntitySegment.cpp:135
memoryx::SegmentUtilImplementations::getReadLock
ScopedSharedLockPtr getReadLock(const Ice::Current &c) const
Definition: SegmentUtilImplementations.cpp:45
memoryx::PersistentEntitySegment::getEntityRefByName
EntityRefBasePtr getEntityRefByName(const std::string &name, const Ice::Current &c) const override
Definition: PersistentEntitySegment.cpp:633
PersistentEntitySegment.h
MongoSerializer.h
memoryx::PersistentEntitySegment::removeAllEntities
void removeAllEntities(const ::Ice::Current &c=Ice::emptyCurrent) override
removeAllEntities collects all entities managed by this memory segment and removes them from the segm...
Definition: PersistentEntitySegment.cpp:283
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
memoryx::PersistentEntitySegment::getObjectTypeId
std::string getObjectTypeId(const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: PersistentEntitySegment.cpp:130
memoryx::PersistentEntitySegment::removeEntityThreadUnsafe
virtual void removeEntityThreadUnsafe(const ::std::string &entityId)
Definition: PersistentEntitySegment.cpp:270
memoryx::PersistentEntitySegment::size
Ice::Int size(const ::Ice::Current &=Ice::emptyCurrent) const override
size counts the number of memoryx::Entity instances contained available reachable throuhg memoryx::Pe...
Definition: PersistentEntitySegment.cpp:489
memoryx::PersistentEntitySegment::getSegmentName
std::string getSegmentName(const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: PersistentEntitySegment.cpp:525
memoryx::PersistentEntitySegment::addEntityThreadUnsafe
virtual std::string addEntityThreadUnsafe(const EntityBasePtr &entity)
Definition: PersistentEntitySegment.cpp:142
memoryx::PersistentEntitySegment::setSegmentName
void setSegmentName(const std::string &segmentName, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: PersistentEntitySegment.cpp:741
memoryx::PersistentEntitySegment::getAllEntities
EntityBaseList getAllEntities(const ::Ice::Current &=Ice::emptyCurrent) const override
getAllEntities returns a list of all entities managed by this memory segment
Definition: PersistentEntitySegment.cpp:554
memoryx::PersistentEntitySegment::~PersistentEntitySegment
~PersistentEntitySegment() override
Definition: PersistentEntitySegment.cpp:49
memoryx::PersistentEntitySegment::getAllEntityIdsThreadUnsafe
virtual EntityIdList getAllEntityIdsThreadUnsafe() const
Definition: PersistentEntitySegment.cpp:536
memoryx::PersistentEntitySegment::writeCollection
CollectionInterfacePrx writeCollection
Definition: PersistentEntitySegment.h:226
IceInternal::Handle< ::Ice::Communicator >
memoryx::PersistentEntitySegment::upsertEntityByNameThreadUnsafe
virtual std::string upsertEntityByNameThreadUnsafe(const std::string &entityName, const EntityBasePtr &entity)
Definition: PersistentEntitySegment.cpp:205
memoryx::PersistentEntitySegment::PersistentEntitySegment
PersistentEntitySegment(CollectionInterfacePrx entityCollection, Ice::CommunicatorPtr ic, bool useMongoIds=true)
Definition: PersistentEntitySegment.cpp:41
EntityRef.h
memoryx::PersistentEntitySegment::getEntityByNameThreadUnsafe
virtual EntityBasePtr getEntityByNameThreadUnsafe(const ::std::string &name) const
Definition: PersistentEntitySegment.cpp:406
GfxTL::Identity
void Identity(MatrixXX< N, N, T > *a)
Definition: MatrixXX.h:523
memoryx::SegmentUtilImplementations::getWriteLock
ScopedUniqueLockPtr getWriteLock(const Ice::Current &c) const
Definition: SegmentUtilImplementations.cpp:56
memoryx::PersistentEntitySegment::getEntityById
EntityBasePtr getEntityById(const ::std::string &entityId, const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: PersistentEntitySegment.cpp:363
ARMARX_ERROR_S
#define ARMARX_ERROR_S
Definition: Logging.h:209
data
uint8_t data[1]
Definition: EtherCATFrame.h:68
memoryx::PersistentEntitySegment::getEntityByName
EntityBasePtr getEntityByName(const ::std::string &name, const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: PersistentEntitySegment.cpp:399
memoryx::PersistentEntitySegment::getEntityRefById
EntityRefBasePtr getEntityRefById(const std::string &id, const Ice::Current &) const override
Definition: PersistentEntitySegment.cpp:612
memoryx::PersistentEntitySegment::deserializeEntity
EntityBasePtr deserializeEntity(const DBStorableData &dbEntity) const
Definition: PersistentEntitySegment.cpp:592
memoryx::PersistentEntitySegment::upsertEntityListThreadUnsafe
virtual EntityIdList upsertEntityListThreadUnsafe(const EntityBaseList &entityList)
Definition: PersistentEntitySegment.cpp:179
memoryx::PersistentEntitySegment::addReadCollection
void addReadCollection(const CollectionInterfacePrx &coll, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: PersistentEntitySegment.cpp:78
memoryx::PersistentEntitySegment::getEntityByIdThreadUnsafe
virtual EntityBasePtr getEntityByIdThreadUnsafe(const ::std::string &entityId) const
Definition: PersistentEntitySegment.cpp:371
memoryx::PersistentEntitySegment::upsertEntity
std::string upsertEntity(const std::string &entityId, const EntityBasePtr &entity, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: PersistentEntitySegment.cpp:153
memoryx::PersistentEntitySegment::hasEntityByNameThreadUnsafe
bool hasEntityByNameThreadUnsafe(const std::string &entityName) const
Definition: PersistentEntitySegment.cpp:340
memoryx::PersistentEntitySegment::setEntityAttribute
void setEntityAttribute(const std::string &entityId, const EntityAttributeBasePtr &attribute, const Ice::Current &) override
Definition: PersistentEntitySegment.cpp:656
memoryx::PersistentEntitySegment::hasEntityByIdThreadUnsafe
bool hasEntityByIdThreadUnsafe(const std::string &entityId) const
Definition: PersistentEntitySegment.cpp:301
armarx::armem::server::ltm::util::mongodb::detail::update
bool update(mongocxx::collection &coll, const nlohmann::json &query, const nlohmann::json &update)
Definition: mongodb.cpp:67
memoryx::PersistentEntitySegment::upsertEntityList
EntityIdList upsertEntityList(const EntityBaseList &entityList, const Ice::Current &=Ice::emptyCurrent) override
Definition: PersistentEntitySegment.cpp:173
memoryx::PersistentEntitySegment::getIceId
::Ice::Identity getIceId(const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: PersistentEntitySegment.cpp:518
memoryx::PersistentEntitySegment::addEntityListThreadUnsafe
virtual EntityIdList addEntityListThreadUnsafe(const EntityBaseList &entityList)
Definition: PersistentEntitySegment.cpp:227
ExpressionException.h
memoryx::PersistentEntitySegment::getEntitiesByAttrValue
EntityBaseList getEntitiesByAttrValue(const ::std::string &attrName, const ::std::string &attrValue, const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: PersistentEntitySegment.cpp:427
memoryx::PersistentEntitySegment::clear
void clear(const ::Ice::Current &=Ice::emptyCurrent) override
clear removes all elements from the current memoryx::PersistentEntitySegment::writeCollection
Definition: PersistentEntitySegment.cpp:513
memoryx::MongoSerializer
Definition: MongoSerializer.h:40
memoryx::SegmentUtilImplementations::ScopedUniqueLockPtr
std::unique_ptr< ScopedSharedLock > ScopedUniqueLockPtr
Definition: SegmentUtilImplementations.h:64
memoryx::PersistentEntitySegment::useMongoIds
bool useMongoIds
Definition: PersistentEntitySegment.h:230
ARMARX_CHECK_EXPRESSION
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
Definition: ExpressionException.h:73
memoryx::PersistentEntitySegment::removeEntity
void removeEntity(const ::std::string &entityId, const ::Ice::Current &=Ice::emptyCurrent) override
removeEntity removes an entity with the ID entityId
Definition: PersistentEntitySegment.cpp:263
memoryx::PersistentEntitySegment::hasEntityByName
bool hasEntityByName(const std::string &entityName, const Ice::Current &=Ice::emptyCurrent) const override
Definition: PersistentEntitySegment.cpp:334
memoryx::PersistentEntitySegment::upsertEntityByName
std::string upsertEntityByName(const std::string &entityName, const EntityBasePtr &entity, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: PersistentEntitySegment.cpp:199
Entity.h
memoryx::PersistentEntitySegment::clearReadCollections
void clearReadCollections(const ::Ice::Current &=Ice::emptyCurrent) override
Definition: PersistentEntitySegment.cpp:71
armarx::VariantType::Int
const VariantTypeId Int
Definition: Variant.h:916
ARMARX_INFO_S
#define ARMARX_INFO_S
Definition: Logging.h:195
memoryx::PersistentEntitySegment::getAllEntityIds
EntityIdList getAllEntityIds(const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: PersistentEntitySegment.cpp:530
memoryx::PersistentEntitySegment::getEntitiesByAttrValueList
EntityBaseList getEntitiesByAttrValueList(const ::std::string &attrName, const NameList &attrValueList, const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: PersistentEntitySegment.cpp:457
Logging.h
memoryx::PersistentEntitySegment::upsertEntityThreadUnsafe
virtual std::string upsertEntityThreadUnsafe(const std::string &entityId, const EntityBasePtr &entity)
Definition: PersistentEntitySegment.cpp:159
memoryx::SegmentUtilImplementations::ScopedSharedLockPtr
std::unique_ptr< ScopedSharedLock > ScopedSharedLockPtr
Definition: SegmentUtilImplementations.h:62
memoryx::PersistentEntitySegment::readCollections
CollectionPrxList readCollections
Definition: PersistentEntitySegment.h:223
memoryx::PersistentEntitySegment::dbSerializer
MongoSerializerPtr dbSerializer
Definition: PersistentEntitySegment.h:227
memoryx::PersistentEntitySegment::hasEntityById
bool hasEntityById(const std::string &entityId, const Ice::Current &=Ice::emptyCurrent) const override
Definition: PersistentEntitySegment.cpp:295
memoryx::PersistentEntitySegment::segmentName
std::string segmentName
Definition: PersistentEntitySegment.h:233
memoryx::PersistentEntitySegment::getWriteCollectionNS
std::string getWriteCollectionNS(const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: PersistentEntitySegment.cpp:110