28 #include "../../libraries/longtermmemory/WorkingMemorySnapshotListSegment.h"
29 #include "../../libraries/memorytypes/segment/KBMSegment.h"
30 #include "../../libraries/memorytypes/segment/OacMemorySegment.h"
31 #include "../../libraries/memorytypes/segment/PersistentDMPDataSegment.h"
32 #include "../../libraries/memorytypes/segment/PersistentObjectClassSegment.h"
33 #include "../../libraries/memorytypes/segment/PersistentObjectInstanceSegment.h"
34 #include "../../libraries/memorytypes/segment/PersistentPredictionDataSegment.h"
35 #include "../../libraries/memorytypes/segment/PersistentProfilerDataSegment.h"
36 #include "../../libraries/memorytypes/segment/PersistentResourceProfileSegment.h"
37 #include <MemoryX/interface/core/EntityBase.h>
38 #include <MemoryX/interface/memorytypes/MemoryEntities.h>
45 return "LongtermMemory";
53 const std::string clsCollNamesStr = getProperty<std::string>(
"ClassCollections").getValue();
61 priorKnowledgePrx = getProxy<PriorKnowledgeInterfacePrx>(
"PriorKnowledge");
62 const std::string snaplistCollectionName =
63 getProperty<std::string>(
"SnapshotListCollection").getValue();
64 const std::string oacCollectionName = getProperty<std::string>(
"OacCollection").getValue();
65 const std::string kbmCollectionName = getProperty<std::string>(
"KbmCollection").getValue();
66 const std::string dmpCollectionName = getProperty<std::string>(
"DmpCollection").getValue();
67 const std::string profilerCollectionName =
68 getProperty<std::string>(
"ProfilerDataCollection").getValue();
69 const std::string resourceProfileCollectionName =
70 getProperty<std::string>(
"ResourceProfileCollection").getValue();
71 const std::string predictionDataCollectionName =
72 getProperty<std::string>(
"PredictionDataCollection").getValue();
73 const std::string selfLocalisationCollectionName =
74 getProperty<std::string>(
"SelfLocalisationCollection").getValue();
78 CollectionInterfacePrx snapshotListCollection =
79 databaseInterfacePrx->requestCollection(snaplistCollectionName);
80 CollectionInterfacePrx oacCollection =
81 databaseInterfacePrx->requestCollection(oacCollectionName);
82 CollectionInterfacePrx kbmCollection =
83 databaseInterfacePrx->requestCollection(kbmCollectionName);
84 CollectionInterfacePrx dmpCollection =
85 databaseInterfacePrx->requestCollection(dmpCollectionName);
89 addSegment(LTM::SegmentNames::SNAPSHOTS, snapshotListSegment);
93 addSegment(LTM::SegmentNames::OACS, oacSegment);
95 PersistentEntitySegmentBasePtr kbmSegment =
new KBMSegment(kbmCollection,
ic);
96 addSegment(LTM::SegmentNames::KBM, kbmSegment);
98 CollectionInterfacePrx profilerCollection =
99 databaseInterfacePrx->requestCollection(profilerCollectionName);
103 CollectionInterfacePrx resourceProfileCollection =
104 databaseInterfacePrx->requestCollection(resourceProfileCollectionName);
105 addSegment(LTM::SegmentNames::RESOURCE_PROFILES,
108 CollectionInterfacePrx predictionDataCollection =
109 databaseInterfacePrx->requestCollection(predictionDataCollectionName);
110 addSegment(LTM::SegmentNames::PREDICTION_DATA,
113 CollectionInterfacePrx classColl =
storagePrx->requestCollection(classCollNames[0]);
116 addSegment(LTM::SegmentNames::OBJECTCLASSES, classesSegment);
119 addSegment(LTM::SegmentNames::DMP, dmpSegment);
121 CollectionInterfacePrx selfLocalisationCollection =
122 databaseInterfacePrx->requestCollection(selfLocalisationCollectionName);
125 addSegment(LTM::SegmentNames::SELF_LOCALISATION, selfLocalisationSegment);
127 ARMARX_INFO <<
"successfully connected long term memory";
130 WorkingMemorySnapshotListSegmentBasePrx
133 return WorkingMemorySnapshotListSegmentBasePrx::uncheckedCast(
137 PersistentObjectInstanceSegmentBasePrx
139 bool createIfMissing,
140 const ::Ice::Current&
c)
144 return PersistentObjectInstanceSegmentBasePrx::uncheckedCast(
147 else if (createIfMissing)
150 databaseInterfacePrx->requestCollection(segmentName),
ic);
151 return PersistentObjectInstanceSegmentBasePrx::uncheckedCast(
156 return PersistentObjectInstanceSegmentBasePrx();
162 const std::string& snapshotName,
163 const AbstractWorkingMemoryInterfacePrx& workingMemory,
164 const ::Ice::Current&)
166 WorkingMemorySnapshotListSegmentBasePrx snapshotListSegment =
169 if (snapshotListSegment)
171 snapshotListSegment->loadSnapshot(snapshotName, workingMemory);
177 const std::string& snapshotName,
178 const AbstractWorkingMemoryInterfacePrx& workingMemory,
179 const ::Ice::Current&)
181 WorkingMemorySnapshotListSegmentBasePrx snapshotListSegment =
184 if (snapshotListSegment)
186 return snapshotListSegment->createSnapshot(snapshotName, workingMemory);
194 WorkingMemorySnapshotInterfacePrx
196 const ::Ice::Current&)
198 WorkingMemorySnapshotListSegmentBasePrx snapshotListSegment =
201 if (snapshotListSegment)
203 return snapshotListSegment->openSnapshot(snapshotName);
207 return WorkingMemorySnapshotInterfacePrx();
213 const ::Ice::Current&)
215 WorkingMemorySnapshotListSegmentBasePrx snapshotListSegment =
218 if (snapshotListSegment)
220 return snapshotListSegment->removeSnapshot(snapshotName);
231 WorkingMemorySnapshotListSegmentBasePrx snapshotListSegment =
234 if (snapshotListSegment)
236 return snapshotListSegment->getSnapshotNames();
240 throw SnapshotNotFoundException(
"Snapshot segment not found!",
"");
250 PersistentProfilerDataSegmentBasePrx
253 return PersistentProfilerDataSegmentBasePrx::uncheckedCast(
257 PersistentPredictionDataSegmentBasePrx
260 return PersistentPredictionDataSegmentBasePrx::uncheckedCast(
261 getSegment(LTM::SegmentNames::PREDICTION_DATA,
c));
264 PersistentResourceProfileSegmentBasePrx
267 return PersistentResourceProfileSegmentBasePrx::uncheckedCast(
268 getSegment(LTM::SegmentNames::RESOURCE_PROFILES,
c));
271 OacMemorySegmentBasePrx
274 return OacMemorySegmentBasePrx::uncheckedCast(
getSegment(LTM::SegmentNames::OACS,
c));
280 return KBMSegmentBasePrx::uncheckedCast(
getSegment(LTM::SegmentNames::KBM,
c));
283 CommonStorageInterfacePrx
289 PersistentObjectClassSegmentBasePrx
292 return PersistentObjectClassSegmentBasePrx::uncheckedCast(
296 PersistentDMPDataSegmentBasePrx
299 return PersistentDMPDataSegmentBasePrx::uncheckedCast(
303 PersistentEntitySegmentBasePrx
306 return PersistentEntitySegmentBasePrx::uncheckedCast(
307 getSegment(LTM::SegmentNames::SELF_LOCALISATION,
c));
310 AbstractMemorySegmentPrx
315 getIceManager()->getCommunicator());
316 return addSegment(segmentName, segment);