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