PriorAttributeEnrichmentFusion.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::Core
17 * @author Alexey Kozlov <kozlov@kit.edu>
18 * @copyright 2012 Alexey Kozlov
19 * @license http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 
23 #pragma once
24 
25 #include <string>
26 
28 
30 #include <MemoryX/interface/components/PriorKnowledgeInterface.h>
31 
32 
33 namespace memoryx
34 {
35  /**
36  * @class PriorAttributeEnrichmentFusion
37  * @ingroup WorkingMemory
38  */
40  virtual public EntityFusionMethod
41  {
42  public:
43 
44  /// Creates a new PriorAttributeEnrichmentFusion
45  PriorAttributeEnrichmentFusion(const PriorKnowledgeInterfacePrx& priorKnowledgePrx, bool forceOverwrite = false);
46 
47  void initEntityInPlace(const EntityBasePtr& updateEntity);
48 
49  /**
50  * This method should be called each time a new entity (currently: object instance) is created and
51  * performs attribute enrichment for it. Concretely, it complements the entity with attributes of the corresponding
52  * class stored in PriorKnowledge. If entity class is not specified or absent in PriorKnoledge, no action will be taken.
53  * If the same attribute exists both in the entity and in its class definition, value from entity will be used.
54  *
55  * @param updateEntity entity
56  * @return entity enriched with prior attributes
57  */
58  EntityBasePtr initEntity(const EntityBasePtr& updateEntity, const ::Ice::Current& = Ice::emptyCurrent) override;
59 
60  /**
61  * This method should be called each time an existing entity gets updated. It checks whether entity class has changed
62  * and if this is a case, adds/removes prior attributes accordingly.
63  *
64  * @param oldEntity entity before update
65  * @param newEntity entity after update
66  *
67  * @return entity enriched with prior attributes
68  */
69  EntityBasePtr fuseEntity(const EntityBasePtr& oldEntity, const EntityBasePtr& newEntity, const ::Ice::Current&) override;
70 
71 
72  private:
73 
74  void addPriorAttrs(const EntityBasePtr& entity) const;
75  void copyMissingAttrs(const EntityBasePtr& srcEntity, const EntityBasePtr& destEntity) const;
76 
77  PriorKnowledgeInterfacePrx priorKnowledgePrx;
78  bool forceOverwrite;
79 
80  };
81 }
82 
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
memoryx::PriorAttributeEnrichmentFusion
Definition: PriorAttributeEnrichmentFusion.h:39
memoryx::EntityFusionMethod
Interface for fusion methods used for entities in working memory.
Definition: EntityFusionMethod.h:43
ImportExport.h
ARMARXCORE_IMPORT_EXPORT
#define ARMARXCORE_IMPORT_EXPORT
Definition: ImportExport.h:38
EntityFusionMethod.h