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
29#include <MemoryX/interface/components/PriorKnowledgeInterface.h>
31
32namespace memoryx
33{
34 /**
35 * @class PriorAttributeEnrichmentFusion
36 * @ingroup WorkingMemory
37 */
39 virtual public EntityFusionMethod
40 {
41 public:
42 /// Creates a new PriorAttributeEnrichmentFusion
43 PriorAttributeEnrichmentFusion(const PriorKnowledgeInterfacePrx& priorKnowledgePrx,
44 bool forceOverwrite = false);
45
46 void initEntityInPlace(const EntityBasePtr& updateEntity);
47
48 /**
49 * This method should be called each time a new entity (currently: object instance) is created and
50 * performs attribute enrichment for it. Concretely, it complements the entity with attributes of the corresponding
51 * class stored in PriorKnowledge. If entity class is not specified or absent in PriorKnoledge, no action will be taken.
52 * If the same attribute exists both in the entity and in its class definition, value from entity will be used.
53 *
54 * @param updateEntity entity
55 * @return entity enriched with prior attributes
56 */
57 EntityBasePtr initEntity(const EntityBasePtr& updateEntity,
58 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,
70 const EntityBasePtr& newEntity,
71 const ::Ice::Current&) override;
72
73
74 private:
75 void addPriorAttrs(const EntityBasePtr& entity) const;
76 void copyMissingAttrs(const EntityBasePtr& srcEntity,
77 const EntityBasePtr& destEntity) const;
78
79 PriorKnowledgeInterfacePrx priorKnowledgePrx;
80 bool forceOverwrite;
81 };
82} // namespace memoryx
#define ARMARXCORE_IMPORT_EXPORT
EntityFusionMethod(std::string methodName)
Constructs a new fusion method.
PriorAttributeEnrichmentFusion(const PriorKnowledgeInterfacePrx &priorKnowledgePrx, bool forceOverwrite=false)
Creates a new PriorAttributeEnrichmentFusion.
EntityBasePtr initEntity(const EntityBasePtr &updateEntity, const ::Ice::Current &=Ice::emptyCurrent) override
This method should be called each time a new entity (currently: object instance) is created and perfo...
void initEntityInPlace(const EntityBasePtr &updateEntity)
EntityBasePtr fuseEntity(const EntityBasePtr &oldEntity, const EntityBasePtr &newEntity, const ::Ice::Current &) override
This method should be called each time an existing entity gets updated.
VirtualRobot headers.