LongtermMemory.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::LongtermMemory
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 
30 #include <MemoryX/interface/components/CommonStorageInterface.h>
31 #include <MemoryX/interface/components/LongtermMemoryInterface.h>
32 #include <MemoryX/interface/components/PriorKnowledgeInterface.h>
34 
35 namespace memoryx
36 {
37 
39  {
40  public:
43  {
44  defineOptionalProperty<std::string>(
45  "SnapshotListCollection",
46  LTM::SegmentNames::SNAPSHOTS,
47  "Mongo collection holding a list of snapshots with corresponding metadata");
48  defineOptionalProperty<std::string>(
49  "OacCollection", LTM::SegmentNames::OACS, "Mongo collection holding all OACs");
50  defineOptionalProperty<std::string>(
51  "DmpCollection", LTM::SegmentNames::DMP, "Mongo collection holding all DMPs");
52  defineOptionalProperty<std::string>("KbmCollection",
53  LTM::SegmentNames::KBM,
54  "Mongo collection holding all KBM instances");
55  defineOptionalProperty<std::string>("ProfilerDataCollection",
56  "ltm_" + LTM::SegmentNames::PROFILER,
57  "Mongo collection for storing Profiler data");
58  defineOptionalProperty<std::string>("ResourceProfileCollection",
59  "ltm_" + LTM::SegmentNames::RESOURCE_PROFILES,
60  "Mongo collection for storing ResourceProfile");
61  defineOptionalProperty<std::string>("PredictionDataCollection",
62  "ltm_" + LTM::SegmentNames::PREDICTION_DATA,
63  "Mongo collection for storing ResourceProfile");
64  defineOptionalProperty<std::string>(
65  "SelfLocalisationCollection",
66  "ltm_" + LTM::SegmentNames::SELF_LOCALISATION,
67  "Mongo collection for storing self localisation results");
68  defineOptionalProperty<std::string>(
69  "ClassCollections",
70  "memdb.Longterm_Objects",
71  "Comma separated list of MongoDB collections (<db>.<collection>) which store known "
72  "object classes. First collection will be used for writing.");
73  }
74  };
75 
76  /*!
77  * \brief The LongtermMemory class provides persistent data that has been learned or copied as a snapshot from working memory.
78  *
79  * The LongtermMemory is a segmented memory and provides methods to store the current WorkingMemory into a snapshot and to fill the WorkingMemory with
80  * previously stored snapshots.
81  *
82  * See \ref longtermmemory "memoryx::LongtermMemory" - "offline" memory, built mostly from earlier experience
83  */
85  virtual public LongtermMemoryInterface,
86  virtual public AbstractLongtermMemory
87  {
88  public:
89  // inherited from AbstractLongtermMemory
90  std::string getDefaultName() const override;
91  void onInitLongtermMemory() override;
92  void onConnectLongtermMemory() override;
93 
94  std::string getMemoryName(const Ice::Current& = Ice::emptyCurrent) const override;
95 
96  // inherited from LongtermMemoryInterface
97  WorkingMemorySnapshotListSegmentBasePrx
98  getWorkingMemorySnapshotListSegment(const ::Ice::Current& = Ice::emptyCurrent) override;
99 
100  PersistentObjectInstanceSegmentBasePrx
101  getCustomInstancesSegment(const std::string& segmentName,
102  bool createIfMissing,
103  const ::Ice::Current& c = Ice::emptyCurrent) override;
104  OacMemorySegmentBasePrx getOacSegment(const ::Ice::Current& = Ice::emptyCurrent) override;
105  KBMSegmentBasePrx getKBMSegment(const Ice::Current&) override;
106  PersistentDMPDataSegmentBasePrx
107  getDMPSegment(const ::Ice::Current& = Ice::emptyCurrent) override;
108  PersistentProfilerDataSegmentBasePrx
109  getProfilerDataSegment(const Ice::Current& c = Ice::emptyCurrent) override;
110  PersistentPredictionDataSegmentBasePrx
111  getPredictionDataSegment(const Ice::Current& c = Ice::emptyCurrent) override;
112  PersistentResourceProfileSegmentBasePrx
113  getResourceProfileSegment(const Ice::Current& c = Ice::emptyCurrent) override;
114  PersistentEntitySegmentBasePrx
115  getSelfLocalisationSegment(const Ice::Current& c = Ice::emptyCurrent) override;
116 
117  PersistentObjectClassSegmentBasePrx
118  getObjectClassesSegment(const ::Ice::Current& c = Ice::emptyCurrent) const override;
119  CommonStorageInterfacePrx
120  getCommonStorage(const ::Ice::Current& c = Ice::emptyCurrent) const override;
121 
122  // snapshot management
123  void loadWorkingMemorySnapshot(const std::string& snapshotName,
124  const AbstractWorkingMemoryInterfacePrx& workingMemory,
125  const ::Ice::Current& = Ice::emptyCurrent) override;
126  bool saveWorkingMemorySnapshot(const std::string& snapshotName,
127  const AbstractWorkingMemoryInterfacePrx& workingMemory,
128  const ::Ice::Current& = Ice::emptyCurrent) override;
129  bool removeWorkingMemorySnapshot(const std::string& snapshotName,
130  const ::Ice::Current& = Ice::emptyCurrent) override;
131  WorkingMemorySnapshotInterfacePrx
132  openWorkingMemorySnapshot(const std::string& snapshotName,
133  const ::Ice::Current& = Ice::emptyCurrent) override;
134  NameList getSnapshotNames(const ::Ice::Current& = Ice::emptyCurrent) override;
135 
136  /**
137  * @see PropertyUser::createPropertyDefinitions()
138  */
141  {
143  new LongtermMemoryPropertyDefinitions(getConfigIdentifier()));
144  }
145 
146  AbstractMemorySegmentPrx addGenericSegment(const std::string& segmentName,
147  const Ice::Current&) override;
148 
149  private:
150  DatabaseInterfacePrx databaseInterfacePrx;
151  PriorKnowledgeInterfacePrx priorKnowledgePrx;
152  NameList classCollNames;
153  };
154 
156 } // namespace memoryx
SegmentedMemory.h
memoryx::LongtermMemoryPropertyDefinitions
Definition: LongtermMemory.h:38
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:345
MongoSerializer.h
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
AbstractLongtermMemory.h
ARMARXCOMPONENT_IMPORT_EXPORT
#define ARMARXCOMPONENT_IMPORT_EXPORT
Definition: ImportExportComponent.h:38
memoryx::LongtermMemory
The LongtermMemory class provides persistent data that has been learned or copied as a snapshot from ...
Definition: LongtermMemory.h:84
memoryx::AbstractLongtermMemory
Definition: AbstractLongtermMemory.h:46
memoryx::AbstractLongtermMemoryPropertyDefinitions
Definition: AbstractLongtermMemory.h:36
Component.h
IceUtil::Handle< class PropertyDefinitionContainer >
memoryx::LongtermMemory::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: LongtermMemory.h:140
memoryx::LongtermMemoryPropertyDefinitions::LongtermMemoryPropertyDefinitions
LongtermMemoryPropertyDefinitions(std::string prefix)
Definition: LongtermMemory.h:41
armarx::PropertyDefinitionsPtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
Definition: forward_declarations.h:35
ImportExportComponent.h