WorkingMemoryEntitySegment.h
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::WorkingMemory
17 * @author ALexey Kozlov ( kozlov at kit dot edu)
18 * @date 2012
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 
23 #pragma once
24 
25 #include <Ice/ObjectAdapter.h>
26 
30 
35 #include <MemoryX/interface/memorytypes/MemorySegments.h>
37 
38 namespace memoryx
39 {
40 
41  /*! This class represents segments in the \ref WorkingMemory
42  *
43  */
44  template <class T>
46  virtual public WorkingMemoryEntitySegmentBase,
47  public virtual SegmentUtilImplementations
48  {
49  friend class SegmentedMemory;
50 
51  public:
52  WorkingMemoryEntitySegment() : lastEntityId(0)
53  {
54  this->objectTypeId = T::ice_staticId();
55  // this->fusionMethod = fusionMethod ? fusionMethod : new AttributeEnrichementFusion();
56  }
57 
58  /**
59  * @brief getObjectTypeId returns the ice_staticId() of the entities stored inside this WorkingMemorySegment
60  * @return
61  */
62  std::string
63  getObjectTypeId(const ::Ice::Current& c = Ice::emptyCurrent) const override
64  {
65  return objectTypeId;
66  }
67 
68  void
69  addFusionMethod(const ::memoryx::EntityFusionMethodBasePtr& fusionMethod,
70  const ::Ice::Current& c = Ice::emptyCurrent) override
71  {
72  if (!fusionMethod)
73  {
74  throw armarx::LocalException("FusionMethod Ptr null");
75  }
76 
77  fusionMethods.push_back(fusionMethod);
78  }
79 
80  protected:
81  void
82  fuseEntity(const EntityBasePtr& entity)
83  {
84  // check whether entity is not null
85  if (!entity)
86  {
87  throw InvalidEntityException("entity is null");
88  }
89 
90  // check whether entity is of correct type
91  if (!entity->ice_isA(objectTypeId))
92  {
93  throw InvalidEntityException("invalid object id");
94  }
95 
96  // init fusion method(s)
97  EntityBasePtr newEntity = entity;
98 
99  for (FusionMethodList::iterator it = fusionMethods.begin(); it != fusionMethods.end();
100  ++it)
101  {
102  newEntity = (*it)->initEntity(newEntity);
103  }
104  }
105 
106  /**
107  * @brief adds the entity to the segment.
108  * @note Does not lock the segment! use AddEntity instead.
109  * @param newEntity
110  * @return id of new entity
111  * @see addEntity
112  */
113  std::string
114  addEntityThreadUnsafe(const EntityBasePtr& newEntity)
115  {
116 
117  // add to memory
118  std::string id = newEntity->getId();
119  {
120 
121 
122  // this dirty hack is needed to preserve ids when loading snapshots:
123  // - if entity has an ID set, use it and adjust lastEntityId accordingly (entity from snapshot)
124  // - otherwise, use lastEntityId+1 as new ID (normal case)
125  if (id.empty() || entityMap.find(id) != entityMap.end())
126  {
127  ++lastEntityId;
128  id = std::to_string(lastEntityId);
129  newEntity->setId(id);
130  }
131  else
132  {
133  try
134  {
135  const int intId = std::stoi(id);
136 
137  if (lastEntityId < intId)
138  {
139  lastEntityId = intId;
140  }
141  }
142  catch (std::exception const&)
143  {
144  }
145  }
146 
147  entityMap[id] = newEntity;
148 
149  // inform listeners
150  if (listenerProxy)
151  {
152  listenerProxy->reportEntityCreated(segmentName, newEntity);
153  }
154  }
155 
156  // return id of created object
157  return id;
158  }
159 
160 
161  public:
162  /*!
163  * \brief addEntity addes an entity to this segment. The registered fusion methods are applied in order to fuse the entity entry.
164  *
165  * When ObjectInstances are used as template parameter the \see PriorAttributeEnrichmentFusion is used to enrich the
166  * attributes by prior knowledge data (i.e. 3D models etc)
167  *
168  * \param entity The entity to add. The attributes of the added entry may be enriched by fusion methods (e.g. PriorAttributeEnrichmentFusion)
169  * \return The id of the newly created entry.
170  */
171  std::string
172  addEntity(const EntityBasePtr& entity, const ::Ice::Current& c = Ice::emptyCurrent) override
173  {
174  fuseEntity(entity);
175 
176  std::scoped_lock<std::mutex> lock(mutex);
177  return addEntityThreadUnsafe(entity);
178  }
179 
180  EntityIdList
181  addEntityList(const EntityBaseList& entityList, const ::Ice::Current& c) override
182  {
183  EntityIdList entityIds(entityList.size(), "");
184 
185  for (size_t i = 0; i < entityList.size(); i++)
186  {
187  try
188  {
189  entityIds[i] = addEntity(entityList[i], c);
190  }
191  catch (const memoryx::InvalidEntityException& e)
192  {
193  // don't handle this exception but return an empty string as ID for this specific entity
194  }
195  }
196 
197  return entityIds;
198  }
199 
200  std::string
201  upsertEntity(const std::string& entityId,
202  const EntityBasePtr& newEntity,
203  const ::Ice::Current& c = Ice::emptyCurrent) override
204  {
205  std::scoped_lock<std::mutex> lock(mutex);
206  if (hasEntityByIdThreadUnsafe(entityId))
207  {
208  updateEntityThreadUnsafe(entityId, newEntity, Ice::StringSeq());
209  return entityId;
210  }
211  else
212  {
213  return addEntityThreadUnsafe(newEntity);
214  }
215  }
216 
217  EntityIdList
218  upsertEntityList(const EntityBaseList& entityList, const ::Ice::Current& c) override
219  {
220  EntityIdList entityIds(entityList.size(), "");
221 
222  for (size_t i = 0; i < entityList.size(); i++)
223  {
224  try
225  {
226  entityIds[i] = upsertEntity(entityList[i]->getId(), entityList[i], c);
227  }
228  catch (const memoryx::InvalidEntityException& e)
229  {
230  // don't handle this exception but return an empty string as ID for this specific entity
231  }
232  }
233 
234  return entityIds;
235  }
236 
237  std::string
238  upsertEntityByName(const std::string& entityName,
239  const EntityBasePtr& newEntity,
240  const ::Ice::Current& c = Ice::emptyCurrent) override
241  {
242  std::scoped_lock<std::mutex> lock(mutex);
243  auto oldEntity = getEntityByNameThreadUnsafe(entityName);
244  if (oldEntity)
245  {
246  updateEntityThreadUnsafe(oldEntity->getId(), newEntity, Ice::StringSeq());
247  return oldEntity->getId();
248  }
249  else
250  {
251  return addEntityThreadUnsafe(newEntity);
252  }
253  }
254 
255  void
256  updateEntity(const std::string& entityId,
257  const EntityBasePtr& update,
258  const ::Ice::Current& c = Ice::emptyCurrent) override
259  {
260  updateEntity(entityId, update, Ice::StringSeq(), c);
261  }
262 
263  void
264  updateEntity(const std::string& entityId,
265  const EntityBasePtr& update,
266  const Ice::StringSeq& deactivatedFusionMethods,
267  const ::Ice::Current& c = Ice::emptyCurrent)
268  {
269  std::scoped_lock<std::mutex> lock(mutex);
270  updateEntityThreadUnsafe(entityId, update, deactivatedFusionMethods);
271  }
272 
273  protected:
274  void
275  updateEntityThreadUnsafe(const std::string& entityId,
276  const EntityBasePtr& update,
277  const Ice::StringSeq& deactivatedFusionMethods)
278  {
279 
280  // check whether entity is valid
281  if (!update)
282  {
283  ARMARX_FATAL_S << "invalid update";
284  throw InvalidEntityException();
285  }
286 
287  // check whether id is known
288  EntityBasePtr oldEntity = getEntityByIdUnsafe(entityId);
289 
290  if (!oldEntity)
291  {
292  throw EntityNotFoundException();
293  }
294 
295  // assure same name
296  if (update->getName() != oldEntity->getName())
297  {
298  ARMARX_FATAL_S << "Entity names do not match: New name = '" << update->getName()
299  << "', Old name = '" << oldEntity->getName()
300  << "', Entity id = " << entityId;
301  throw InvalidEntityException();
302  }
303 
304  // assure correct id
305  update->setId(entityId);
306 
307  // call fusion method(s)
308  EntityBasePtr newEntity = update;
309 
310 
311  for (FusionMethodList::iterator it = fusionMethods.begin(); it != fusionMethods.end();
312  ++it)
313  {
314  if (std::find(deactivatedFusionMethods.begin(),
315  deactivatedFusionMethods.end(),
316  (*it)->getMethodName()) == deactivatedFusionMethods.end())
317  {
318  newEntity = (*it)->fuseEntity(oldEntity, newEntity);
319  }
320  }
321 
322  entityMap[entityId] = newEntity;
323 
324  // inform listener
325  if (listenerProxy)
326  {
327  listenerProxy->reportEntityUpdated(
328  segmentName,
329  EntityPtr::dynamicCast(oldEntity->ice_clone()), // not safe if not cloned!
330  EntityPtr::dynamicCast(newEntity->ice_clone()));
331  }
332  }
333 
334  public:
335  void
336  removeEntity(const ::std::string& id, const ::Ice::Current& c = Ice::emptyCurrent) override
337  {
338  std::scoped_lock<std::mutex> lock(mutex);
339  IdEntityMap::iterator it = entityMap.find(id);
340 
341  if (it == entityMap.end())
342  {
343  throw EntityNotFoundException();
344  }
345 
346  EntityBasePtr entity = it->second;
347  entityMap.erase(it);
348 
349  if (listenerProxy)
350  {
351  listenerProxy->reportEntityRemoved(segmentName, entity);
352  }
353  }
354 
355  void
356  removeAllEntities(const ::Ice::Current& c = Ice::emptyCurrent) override
357  {
358  clear(c);
359  }
360 
361  void
362  setEntityAttribute(const std::string& entityId,
363  const EntityAttributeBasePtr& attribute,
364  const ::Ice::Current& c) override
365  {
366  std::scoped_lock<std::mutex> lock(mutex);
367  IdEntityMap::iterator it = entityMap.find(entityId);
368 
369  if (it == entityMap.end())
370  {
371  throw EntityNotFoundException();
372  }
373 
374  it->second->putAttribute(attribute);
375  }
376 
377  void
378  setEntityAttributes(const std::string& entityId,
379  const EntityAttributeList& attributeMap,
380  const ::Ice::Current& c) override
381  {
382  std::scoped_lock<std::mutex> lock(mutex);
383  IdEntityMap::iterator it = entityMap.find(entityId);
384 
385  if (it == entityMap.end())
386  {
387  throw EntityNotFoundException();
388  }
389 
390  for (auto attribute : attributeMap)
391  {
392  it->second->putAttribute(attribute);
393  }
394  }
395 
396  void
397  clear(const ::Ice::Current& c = Ice::emptyCurrent) override
398  {
399  {
400  std::scoped_lock<std::mutex> lock(mutex);
401 
402  for (auto entityMapIter = entityMap.begin(); entityMapIter != entityMap.end();)
403  {
404  EntityBasePtr entity = entityMapIter->second;
405 
406  if (listenerProxy)
407  {
408  listenerProxy->reportEntityRemoved(segmentName, entity);
409  }
410 
411  entityMapIter = entityMap.erase(entityMapIter);
412  }
413 
414  lastEntityId = 0;
415  }
416 
417  if (listenerProxy)
418  {
419  listenerProxy->reportMemoryCleared(segmentName);
420  }
421  }
422 
423  Ice::Int
424  size(const ::Ice::Current& c = Ice::emptyCurrent) const override
425  {
426  std::scoped_lock<std::mutex> lock(mutex);
427  return (Ice::Int)entityMap.size();
428  }
429 
430  bool
431  hasEntityById(const std::string& entityId, const ::Ice::Current& c) const override
432  {
433  std::scoped_lock<std::mutex> lock(mutex);
434  return hasEntityByIdThreadUnsafe(entityId);
435  }
436 
437  protected:
438  bool
439  hasEntityByIdThreadUnsafe(const std::string& entityId) const
440  {
441  IdEntityMap::const_iterator it = entityMap.find(entityId);
442  return it != entityMap.end();
443  }
444 
445  public:
446  bool
447  hasEntityByName(const std::string& entityName, const ::Ice::Current& c) const override
448  {
449  std::scoped_lock<std::mutex> lock(mutex);
450 
451  for (const auto& entity : entityMap)
452  {
453  if (entity.second && entity.second->getName() == entityName)
454  {
455  return true;
456  }
457  }
458 
459  return false;
460  }
461 
462  EntityBasePtr
463  getEntityById(const ::std::string& id) const
464  {
465  std::scoped_lock<std::mutex> lock(mutex);
466  return getEntityByIdUnsafe(id);
467  }
468 
469  EntityBasePtr
470  getEntityById(const ::std::string& id, const ::Ice::Current& c) const override
471  {
472  std::scoped_lock<std::mutex> lock(mutex);
473  IdEntityMap::const_iterator it = entityMap.find(id);
474 
475  if (it != entityMap.end())
476  {
477  // clone before return it because it could be manipulated afterwards
478  return EntityBasePtr::dynamicCast(it->second->ice_clone());
479  // return EntityBasePtr::dynamicCast(it->second);
480  }
481  else
482  {
483 
484  return EntityBasePtr();
485  }
486  }
487 
488  EntityBasePtr
489  getEntityByName(const ::std::string& name) const
490  {
491  std::scoped_lock<std::mutex> lock(mutex);
492  return getEntityByNameThreadUnsafe(name);
493  }
494 
495  protected:
496  EntityBasePtr
497  getEntityByNameThreadUnsafe(const ::std::string& name) const
498  {
499  for (IdEntityMap::const_iterator it = entityMap.begin(); it != entityMap.end(); ++it)
500  {
501 
502  if (it->second->getName() == name)
503  {
504  return EntityBasePtr::dynamicCast(it->second);
505  }
506  }
507 
508  std::string entities;
509 
510  for (auto e : entityMap)
511  {
512  entities += e.second->getName() + " ";
513  }
514 
515  ARMARX_INFO_S << "Could not find entity named " << name << " in entity list { "
516  << entities << " }";
517  return EntityBasePtr();
518  }
519 
520  public:
521  EntityBasePtr
522  getEntityByName(const ::std::string& name, const ::Ice::Current& c) const override
523  {
524  std::scoped_lock<std::mutex> lock(mutex);
525 
526  for (IdEntityMap::const_iterator it = entityMap.begin(); it != entityMap.end(); ++it)
527  {
528  // clone before giving it to ice because it could be manipulated afterwards
529  if (it->second->getName() == name)
530  {
531  return EntityBasePtr::dynamicCast(it->second->ice_clone());
532  }
533 
534  // return EntityBasePtr::dynamicCast(it->second);
535  }
536 
537  std::string entities;
538 
539  for (auto e : entityMap)
540  {
541  entities += e.second->getName() + " ";
542  }
543 
544  ARMARX_INFO_S << "Could not find entity named " << name << " in entity list { "
545  << entities << " }";
546  return EntityBasePtr();
547  }
548 
549  EntityBaseList
550  getEntitiesByAttrValue(const ::std::string& attrName,
551  const ::std::string& attrValue,
552  const ::Ice::Current& c) const override
553  {
554  NameList attrValueList;
555  attrValueList.push_back(attrValue);
556  return getEntitiesByAttrValueList(attrName, attrValueList, c);
557  }
558 
559  EntityBaseList
560  getEntitiesByAttrValue(const ::std::string& attrName, const ::std::string& attrValue) const
561  {
562  NameList attrValueList;
563  attrValueList.push_back(attrValue);
564  return getEntitiesByAttrValueList(attrName, attrValueList);
565  }
566 
567  EntityBaseList
568  getEntitiesByAttrValueList(const ::std::string& attrName,
569  const NameList& attrValueList) const
570  {
571  EntityBaseList result;
572 
573  std::scoped_lock<std::mutex> lock(mutex);
574  for (IdEntityMap::const_iterator it = entityMap.begin(); it != entityMap.end(); ++it)
575  {
576  const EntityAttributeBasePtr attr = it->second->getAttribute(attrName);
577 
578  if (attr)
579  {
580  for (NameList::const_iterator itVal = attrValueList.begin();
581  itVal != attrValueList.end();
582  ++itVal)
583  {
584  if (attr->hasValue(new armarx::Variant(*itVal)))
585  {
586  result.push_back(EntityBasePtr::dynamicCast(it->second));
587  break;
588  }
589  }
590  }
591  }
592 
593  return result;
594  }
595 
596  EntityBaseList
597  getEntitiesByAttrValueList(const ::std::string& attrName,
598  const NameList& attrValueList,
599  const ::Ice::Current& c) const override
600  {
601  EntityBaseList result;
602 
603  std::scoped_lock<std::mutex> lock(mutex);
604 
605  for (IdEntityMap::const_iterator it = entityMap.begin(); it != entityMap.end(); ++it)
606  {
607  const EntityAttributeBasePtr attr = it->second->getAttribute(attrName);
608 
609  if (attr)
610  {
611  for (NameList::const_iterator itVal = attrValueList.begin();
612  itVal != attrValueList.end();
613  ++itVal)
614  {
615  if (attr->hasValue(new armarx::Variant(*itVal)))
616  {
617  // clone before giving it to ice because it could be manipulated afterwards
618  result.push_back(EntityBasePtr::dynamicCast(it->second->ice_clone()));
619  break;
620  }
621  }
622  }
623  }
624 
625  return result;
626  }
627 
628  EntityIdList
629  getAllEntityIds(const Ice::Current& c = Ice::emptyCurrent) const override
630  {
631  EntityIdList result;
632  std::scoped_lock<std::mutex> lock(mutex);
633  for (IdEntityMap::const_iterator it = entityMap.begin(); it != entityMap.end(); ++it)
634  {
635  result.push_back(it->first);
636  }
637 
638  return result;
639  }
640 
641  EntityBaseList
642  getAllEntities(const Ice::Current& c = Ice::emptyCurrent) const override
643  {
644  EntityBaseList result;
645  std::scoped_lock<std::mutex> lock(mutex);
646  result.reserve(entityMap.size());
647 
648  for (const auto& entry : entityMap)
649  {
650  result.push_back(EntityBasePtr::dynamicCast(entry.second->ice_clone()));
651  }
652 
653  return result;
654  }
655 
656  IdEntityMap
657  getIdEntityMap(const Ice::Current& c = Ice::emptyCurrent) const override
658  {
659  IdEntityMap result;
660  std::scoped_lock<std::mutex> lock(mutex);
661 
662  for (const auto& entry : entityMap)
663  {
664  result.insert({entry.first, EntityBasePtr::dynamicCast(entry.second->ice_clone())});
665  }
666 
667  return result;
668  }
669 
670  void
671  print(const ::Ice::Current& c = Ice::emptyCurrent) const override
672  {
673  std::scoped_lock<std::mutex> lock(mutex);
674 
675  for (IdEntityMap::const_iterator it = entityMap.begin(); it != entityMap.end(); ++it)
676  {
677  ARMARX_INFO_S << EntityPtr::dynamicCast(it->second) << std::endl;
678  }
679  }
680 
681  std::string
682  getSegmentName(const ::Ice::Current& c = Ice::emptyCurrent) const override
683  {
684  return segmentName;
685  }
686 
687  /*!
688  * \brief getListener The topic on which changes are reported.
689  * \return NULL if disabled.
690  */
691  WorkingMemoryListenerInterfacePrx
692  getListenerProxy(const ::Ice::Current& c = Ice::emptyCurrent) override
693  {
694  return this->listenerProxy;
695  }
696 
697  protected:
698  IdEntityMap entityMap;
700 
701  protected:
702  // protected methods
703  void
704  setListenerProxy(const WorkingMemoryListenerInterfacePrx& listenerProxy,
705  const ::Ice::Current& c = Ice::emptyCurrent) override
706  {
707  this->listenerProxy = listenerProxy;
708  }
709 
710  // set segment name
711  void
712  setSegmentName(const std::string& segmentName,
713  const ::Ice::Current& c = Ice::emptyCurrent) override
714  {
715  this->segmentName = segmentName;
716  }
717 
718  void
719  setParentMemory(const MemoryInterfacePtr& memory, const ::Ice::Current& c) override
720  {
721  this->parentMemory = memory;
722  }
723 
725  std::string segmentName;
726  MemoryInterfacePtr parentMemory;
727 
728  // EntityMemorySegmentInterface interface
729  public:
730  EntityRefBasePtr
731  getEntityRefById(const std::string& id, const Ice::Current& c) const override
732  {
733  auto entity = getEntityById(id, c);
734 
735  if (!entity)
736  {
737  return NULL;
738  }
739 
740  auto proxy =
741  EntityMemorySegmentInterfacePrx::uncheckedCast(c.adapter->createProxy(c.id));
742  SegmentedMemoryPtr mem = SegmentedMemoryPtr::dynamicCast(parentMemory);
743  std::string memName = mem->getMemoryName();
744  auto memoryProxy = MemoryInterfacePrx::checkedCast(
745  c.adapter->getCommunicator()->stringToProxy(memName));
746  EntityRefPtr ref = new EntityRef(entity, segmentName, memName, memoryProxy, proxy);
747  return ref;
748  }
749 
750  EntityRefBasePtr
751  getEntityRefByName(const std::string& name, const Ice::Current& c) const override
752  {
753  if (!c.adapter)
754  {
755  ARMARX_ERROR_S << "adapter is NULL";
756  }
757 
758  auto entity = getEntityByName(name, c);
759 
760  if (!entity)
761  {
762  return NULL;
763  }
764 
765  SegmentedMemoryPtr mem = SegmentedMemoryPtr::dynamicCast(parentMemory);
766 
767  if (!mem)
768  {
769  ARMARX_ERROR_S << "non mem ptr";
770  }
771 
772 
773  std::string memName = mem->getMemoryName();
774  auto proxy =
775  EntityMemorySegmentInterfacePrx::uncheckedCast(c.adapter->createProxy(c.id));
776  auto memoryProxy = MemoryInterfacePrx::checkedCast(
777  c.adapter->getCommunicator()->stringToProxy(memName));
778  EntityRefPtr ref = new EntityRef(entity, segmentName, memName, memoryProxy, proxy);
779  return ref;
780  }
781 
782  // AbstractMemorySegment interface
783  public:
785  getIceId(const ::Ice::Current& c) const override
786  {
787  Ice::Identity id;
788  id.name = parentMemory->getMemoryName() + "_" + segmentName;
789  return id;
790  }
791 
792  protected:
793  EntityBasePtr
794  getEntityByIdUnsafe(const ::std::string& id) const
795  {
796  IdEntityMap::const_iterator it = entityMap.find(id);
797 
798  if (it != entityMap.end())
799  {
800  return EntityBasePtr::dynamicCast(it->second);
801  }
802  else
803  {
804 
805  return EntityBasePtr();
806  }
807  }
808  };
809 } // namespace memoryx
armarx::Variant
The Variant class is described here: Variants.
Definition: Variant.h:223
memoryx::WorkingMemoryEntitySegment::fusionMethod
EntityFusionMethodPtr fusionMethod
Definition: WorkingMemoryEntitySegment.h:724
memoryx::WorkingMemoryEntitySegment::WorkingMemoryEntitySegment
WorkingMemoryEntitySegment()
Definition: WorkingMemoryEntitySegment.h:52
memoryx::WorkingMemoryEntitySegment::setListenerProxy
void setListenerProxy(const WorkingMemoryListenerInterfacePrx &listenerProxy, const ::Ice::Current &c=Ice::emptyCurrent) override
Definition: WorkingMemoryEntitySegment.h:704
SegmentedMemory.h
armarx::VariantType::EntityRef
const armarx::VariantTypeId EntityRef
Definition: EntityRef.h:30
memoryx::WorkingMemoryEntitySegment::getAllEntities
EntityBaseList getAllEntities(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: WorkingMemoryEntitySegment.h:642
memoryx::WorkingMemoryEntitySegment::parentMemory
MemoryInterfacePtr parentMemory
Definition: WorkingMemoryEntitySegment.h:726
memoryx::WorkingMemoryEntitySegment::getEntityByName
EntityBasePtr getEntityByName(const ::std::string &name) const
Definition: WorkingMemoryEntitySegment.h:489
JSONObject.h
memoryx::WorkingMemoryEntitySegment::getSegmentName
std::string getSegmentName(const ::Ice::Current &c=Ice::emptyCurrent) const override
Definition: WorkingMemoryEntitySegment.h:682
memoryx::WorkingMemoryEntitySegment::getEntitiesByAttrValueList
EntityBaseList getEntitiesByAttrValueList(const ::std::string &attrName, const NameList &attrValueList, const ::Ice::Current &c) const override
Definition: WorkingMemoryEntitySegment.h:597
memoryx::WorkingMemoryEntitySegment::addEntityThreadUnsafe
std::string addEntityThreadUnsafe(const EntityBasePtr &newEntity)
adds the entity to the segment.
Definition: WorkingMemoryEntitySegment.h:114
memoryx::WorkingMemoryEntitySegment::getEntityRefByName
EntityRefBasePtr getEntityRefByName(const std::string &name, const Ice::Current &c) const override
Definition: WorkingMemoryEntitySegment.h:751
memoryx::WorkingMemoryEntitySegment::getIceId
Ice::Identity getIceId(const ::Ice::Current &c) const override
Definition: WorkingMemoryEntitySegment.h:785
memoryx::WorkingMemoryEntitySegment::segmentName
std::string segmentName
Definition: WorkingMemoryEntitySegment.h:725
memoryx::SegmentUtilImplementations
Definition: SegmentUtilImplementations.h:59
memoryx::WorkingMemoryEntitySegment::getEntitiesByAttrValue
EntityBaseList getEntitiesByAttrValue(const ::std::string &attrName, const ::std::string &attrValue, const ::Ice::Current &c) const override
Definition: WorkingMemoryEntitySegment.h:550
memoryx::WorkingMemoryEntitySegment::updateEntity
void updateEntity(const std::string &entityId, const EntityBasePtr &update, const ::Ice::Current &c=Ice::emptyCurrent) override
Definition: WorkingMemoryEntitySegment.h:256
memoryx::WorkingMemoryEntitySegment::upsertEntityByName
std::string upsertEntityByName(const std::string &entityName, const EntityBasePtr &newEntity, const ::Ice::Current &c=Ice::emptyCurrent) override
Definition: WorkingMemoryEntitySegment.h:238
memoryx::WorkingMemoryEntitySegment::updateEntity
void updateEntity(const std::string &entityId, const EntityBasePtr &update, const Ice::StringSeq &deactivatedFusionMethods, const ::Ice::Current &c=Ice::emptyCurrent)
Definition: WorkingMemoryEntitySegment.h:264
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
memoryx::WorkingMemoryEntitySegment::upsertEntityList
EntityIdList upsertEntityList(const EntityBaseList &entityList, const ::Ice::Current &c) override
Definition: WorkingMemoryEntitySegment.h:218
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
memoryx::WorkingMemoryEntitySegment::entityMap
IdEntityMap entityMap
Definition: WorkingMemoryEntitySegment.h:698
memoryx::WorkingMemoryEntitySegment::lastEntityId
int lastEntityId
Definition: WorkingMemoryEntitySegment.h:699
memoryx::WorkingMemoryEntitySegment::getIdEntityMap
IdEntityMap getIdEntityMap(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: WorkingMemoryEntitySegment.h:657
memoryx::WorkingMemoryEntitySegment::getEntityByNameThreadUnsafe
EntityBasePtr getEntityByNameThreadUnsafe(const ::std::string &name) const
Definition: WorkingMemoryEntitySegment.h:497
memoryx::WorkingMemoryEntitySegment::getAllEntityIds
EntityIdList getAllEntityIds(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: WorkingMemoryEntitySegment.h:629
memoryx::WorkingMemoryEntitySegment::size
Ice::Int size(const ::Ice::Current &c=Ice::emptyCurrent) const override
Definition: WorkingMemoryEntitySegment.h:424
cxxopts::empty
bool empty(const std::string &s)
Definition: cxxopts.hpp:234
memoryx::SegmentedMemory
The SegmentedMemory class provides an interface for organizing memories with segmented data structure...
Definition: SegmentedMemory.h:46
IceInternal::Handle< EntityFusionMethod >
EntityRef.h
memoryx::WorkingMemoryEntitySegment
Definition: WorkingMemoryEntitySegment.h:45
GfxTL::Identity
void Identity(MatrixXX< N, N, T > *a)
Definition: MatrixXX.h:570
memoryx::WorkingMemoryEntitySegment::getEntityById
EntityBasePtr getEntityById(const ::std::string &id, const ::Ice::Current &c) const override
Definition: WorkingMemoryEntitySegment.h:470
memoryx::WorkingMemoryEntitySegment::removeAllEntities
void removeAllEntities(const ::Ice::Current &c=Ice::emptyCurrent) override
Definition: WorkingMemoryEntitySegment.h:356
ARMARXCOMPONENT_IMPORT_EXPORT
#define ARMARXCOMPONENT_IMPORT_EXPORT
Definition: ImportExportComponent.h:38
memoryx::WorkingMemoryEntitySegment::removeEntity
void removeEntity(const ::std::string &id, const ::Ice::Current &c=Ice::emptyCurrent) override
Definition: WorkingMemoryEntitySegment.h:336
memoryx::WorkingMemoryEntitySegment::updateEntityThreadUnsafe
void updateEntityThreadUnsafe(const std::string &entityId, const EntityBasePtr &update, const Ice::StringSeq &deactivatedFusionMethods)
Definition: WorkingMemoryEntitySegment.h:275
memoryx::WorkingMemoryEntitySegment::setEntityAttribute
void setEntityAttribute(const std::string &entityId, const EntityAttributeBasePtr &attribute, const ::Ice::Current &c) override
Definition: WorkingMemoryEntitySegment.h:362
ARMARX_ERROR_S
#define ARMARX_ERROR_S
Definition: Logging.h:216
memoryx::WorkingMemoryEntitySegment::addFusionMethod
void addFusionMethod(const ::memoryx::EntityFusionMethodBasePtr &fusionMethod, const ::Ice::Current &c=Ice::emptyCurrent) override
Definition: WorkingMemoryEntitySegment.h:69
memoryx::WorkingMemoryEntitySegment::getEntityRefById
EntityRefBasePtr getEntityRefById(const std::string &id, const Ice::Current &c) const override
Definition: WorkingMemoryEntitySegment.h:731
SegmentUtilImplementations.h
memoryx::WorkingMemoryEntitySegment::setSegmentName
void setSegmentName(const std::string &segmentName, const ::Ice::Current &c=Ice::emptyCurrent) override
Definition: WorkingMemoryEntitySegment.h:712
memoryx::WorkingMemoryEntitySegment::print
void print(const ::Ice::Current &c=Ice::emptyCurrent) const override
Definition: WorkingMemoryEntitySegment.h:671
memoryx::WorkingMemoryEntitySegment::addEntity
std::string addEntity(const EntityBasePtr &entity, const ::Ice::Current &c=Ice::emptyCurrent) override
addEntity addes an entity to this segment. The registered fusion methods are applied in order to fuse...
Definition: WorkingMemoryEntitySegment.h:172
memoryx::WorkingMemoryEntitySegment::hasEntityByName
bool hasEntityByName(const std::string &entityName, const ::Ice::Current &c) const override
Definition: WorkingMemoryEntitySegment.h:447
memoryx::WorkingMemoryEntitySegment::getEntitiesByAttrValue
EntityBaseList getEntitiesByAttrValue(const ::std::string &attrName, const ::std::string &attrValue) const
Definition: WorkingMemoryEntitySegment.h:560
armarx::to_string
const std::string & to_string(const std::string &s)
Definition: StringHelpers.h:41
armarx::armem::server::ltm::util::mongodb::detail::update
bool update(mongocxx::collection &coll, const nlohmann::json &query, const nlohmann::json &update)
Definition: mongodb.cpp:68
Component.h
memoryx::WorkingMemoryEntitySegment::addEntityList
EntityIdList addEntityList(const EntityBaseList &entityList, const ::Ice::Current &c) override
Definition: WorkingMemoryEntitySegment.h:181
memoryx::WorkingMemoryEntitySegment::hasEntityByIdThreadUnsafe
bool hasEntityByIdThreadUnsafe(const std::string &entityId) const
Definition: WorkingMemoryEntitySegment.h:439
memoryx::WorkingMemoryEntitySegment::getEntityByName
EntityBasePtr getEntityByName(const ::std::string &name, const ::Ice::Current &c) const override
Definition: WorkingMemoryEntitySegment.h:522
memoryx::WorkingMemoryEntitySegment::fuseEntity
void fuseEntity(const EntityBasePtr &entity)
Definition: WorkingMemoryEntitySegment.h:82
Entity.h
armarx::VariantType::Int
const VariantTypeId Int
Definition: Variant.h:917
memoryx::WorkingMemoryEntitySegment::getListenerProxy
WorkingMemoryListenerInterfacePrx getListenerProxy(const ::Ice::Current &c=Ice::emptyCurrent) override
getListener The topic on which changes are reported.
Definition: WorkingMemoryEntitySegment.h:692
ARMARX_FATAL_S
#define ARMARX_FATAL_S
Definition: Logging.h:219
memoryx::WorkingMemoryEntitySegment::getEntityByIdUnsafe
EntityBasePtr getEntityByIdUnsafe(const ::std::string &id) const
Definition: WorkingMemoryEntitySegment.h:794
memoryx::WorkingMemoryEntitySegment::setEntityAttributes
void setEntityAttributes(const std::string &entityId, const EntityAttributeList &attributeMap, const ::Ice::Current &c) override
Definition: WorkingMemoryEntitySegment.h:378
memoryx::WorkingMemoryEntitySegment::hasEntityById
bool hasEntityById(const std::string &entityId, const ::Ice::Current &c) const override
Definition: WorkingMemoryEntitySegment.h:431
ARMARX_INFO_S
#define ARMARX_INFO_S
Definition: Logging.h:202
memoryx::WorkingMemoryEntitySegment::getEntityById
EntityBasePtr getEntityById(const ::std::string &id) const
Definition: WorkingMemoryEntitySegment.h:463
memoryx::WorkingMemoryEntitySegment::getEntitiesByAttrValueList
EntityBaseList getEntitiesByAttrValueList(const ::std::string &attrName, const NameList &attrValueList) const
Definition: WorkingMemoryEntitySegment.h:568
memoryx::WorkingMemoryEntitySegment::setParentMemory
void setParentMemory(const MemoryInterfacePtr &memory, const ::Ice::Current &c) override
Definition: WorkingMemoryEntitySegment.h:719
memoryx::WorkingMemoryEntitySegment::clear
void clear(const ::Ice::Current &c=Ice::emptyCurrent) override
Definition: WorkingMemoryEntitySegment.h:397
memoryx::WorkingMemoryEntitySegment::upsertEntity
std::string upsertEntity(const std::string &entityId, const EntityBasePtr &newEntity, const ::Ice::Current &c=Ice::emptyCurrent) override
Definition: WorkingMemoryEntitySegment.h:201
EntityFusionMethod.h
memoryx::WorkingMemoryEntitySegment::getObjectTypeId
std::string getObjectTypeId(const ::Ice::Current &c=Ice::emptyCurrent) const override
getObjectTypeId returns the ice_staticId() of the entities stored inside this WorkingMemorySegment
Definition: WorkingMemoryEntitySegment.h:63
ImportExportComponent.h