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