AbstractWorkingMemory.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
27
32#include <MemoryX/interface/components/CommonStorageInterface.h>
33#include <MemoryX/interface/components/LongtermMemoryInterface.h>
34#include <MemoryX/interface/components/PriorKnowledgeInterface.h>
35#include <MemoryX/interface/workingmemory/AbstractWorkingMemoryInterface.h>
36
37namespace memoryx
38{
39
41 {
42 public:
45 {
46 defineOptionalProperty<bool>("UsePriorMemory", true, "Switch prior knowledge on/off.");
47
49 "PriorMemoryName", "PriorKnowledge", "Name of PriorKnowledge Ice component");
50
52 "UseLongtermMemory", true, "Switch longterm memory on/off.");
53
55 "LongtermMemoryName", "LongtermMemory", "Name of LongtermMemory Ice component");
56
58 "PublishUpdates",
59 true,
60 "Publish scene updates (ObjectCreated/Updated/Removed) on IceStrom topic");
61
63 "UpdatesTopicName",
64 "WorkingMemoryUpdates",
65 "Name of IceStrom topic to publish scene updates on");
66
68 "SnapshotToLoad",
69 "",
70 "Name of Snapshot that should be loaded on start up. Leave empty for none.");
71 }
72 };
73
75 {
76 WorkingMemoryUpdaterBasePrx proxy;
77 WorkingMemoryUpdaterBasePtr pointer;
78 };
79
80 using MemoryUpdaterMap = std::map<std::string, MemoryUpdaterEntry>;
81
83 virtual public AbstractWorkingMemoryInterface,
84 virtual public SegmentedMemory,
85 virtual public armarx::Component
86 {
87 public:
88 // inherited from Component
89 std::string
90 getDefaultName() const override
91 {
92 return "AbstractWorkingMemory";
93 }
94
95 void onInitComponent() override;
96 void onConnectComponent() override;
97
98 // TODO: exit or destructor: clean all segments and updaters in order to resolve cyclic pointer dependencies
99
100 /**
101 * @see PropertyUser::createPropertyDefinitions()
102 */
109
111 getObjectAdapter() const override
112 {
113 return Component::getObjectAdapter();
114 }
115
116 // implementation of WorkingMemoryInterface
117 AbstractMemorySegmentPrx addSegment(const std::string& segmentName,
118 const AbstractMemorySegmentPtr& segment,
119 const ::Ice::Current& = Ice::emptyCurrent) override;
120
121 WorkingMemoryUpdaterBasePrx
122 registerUpdater(const std::string& updaterName,
123 const WorkingMemoryUpdaterBasePtr& updater,
124 const ::Ice::Current& = Ice::emptyCurrent) override;
125 WorkingMemoryUpdaterBasePrx getUpdater(const std::string& updaterName,
126 const ::Ice::Current& = Ice::emptyCurrent) override;
127 void unregisterUpdater(const std::string& updaterName,
128 const ::Ice::Current& = Ice::emptyCurrent) override;
129
130 /*!
131 * \brief getListenerTopicName The topic name.
132 * \return
133 */
134 std::string
136 {
137 return updatesTopicName;
138 }
139
140 AbstractMemorySegmentPrx
141 addGenericSegment(const std::string& segmentName, const Ice::Current&) override
142 {
143 WorkingMemoryEntitySegmentBasePtr segment = new WorkingMemoryEntitySegment<Entity>();
144 return addSegment(segmentName, segment);
145 }
146
147 // misc
148 void clear(const ::Ice::Current& = Ice::emptyCurrent) override;
149 void print(const ::Ice::Current& = Ice::emptyCurrent) const override;
150
151 protected:
152 // subclass hooks
153 virtual void onInitWorkingMemory() = 0;
154 virtual void onConnectWorkingMemory() = 0;
155
156 CommonStorageInterfacePrx dataBasePrx;
157 PriorKnowledgeInterfacePrx priorKnowledgePrx;
158 LongtermMemoryInterfacePrx longtermMemoryPrx;
159 WorkingMemoryListenerInterfacePrx listenerPrx;
161
163 mutable std::shared_mutex updaterMutex;
164
169
170 std::string priorMemoryName;
172 std::string updatesTopicName;
173 };
174
176
177} // namespace memoryx
#define ARMARXCOMPONENT_IMPORT_EXPORT
Default component property definition container.
Definition Component.h:70
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
Definition Component.cpp:46
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition Component.h:94
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition Component.cpp:90
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
PropertyDefinition< PropertyType > & defineOptionalProperty(const std::string &name, PropertyType defaultValue, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
AbstractMemorySegmentPrx addSegment(const std::string &segmentName, const AbstractMemorySegmentPtr &segment, const ::Ice::Current &=Ice::emptyCurrent) override
CommonStorageInterfacePrx dataBasePrx
std::string getListenerTopicName()
getListenerTopicName The topic name.
AbstractMemorySegmentPrx addGenericSegment(const std::string &segmentName, const Ice::Current &) override
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Ice::ObjectAdapterPtr getObjectAdapter() const override
PriorKnowledgeInterfacePrx priorKnowledgePrx
virtual void onConnectWorkingMemory()=0
WorkingMemoryListenerInterfacePrx listenerPrx
virtual void onInitWorkingMemory()=0
LongtermMemoryInterfacePrx longtermMemoryPrx
std::string getDefaultName() const override
Retrieve default name of component.
::IceInternal::Handle<::Ice::ObjectAdapter > ObjectAdapterPtr
Definition IceManager.h:52
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
VirtualRobot headers.
IceUtil::Handle< AbstractWorkingMemory > AbstractWorkingMemoryPtr
std::map< std::string, MemoryUpdaterEntry > MemoryUpdaterMap
IceUtil::Handle< MongoSerializer > MongoSerializerPtr
Definition EntityRef.h:41
WorkingMemoryUpdaterBasePrx proxy
WorkingMemoryUpdaterBasePtr pointer