PriorKnowledge.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::PriorKnowledge
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 
29 #include <MemoryX/interface/components/CommonStorageInterface.h>
30 #include <MemoryX/interface/components/PriorKnowledgeInterface.h>
31 
32 namespace memoryx
33 {
34 
36  {
37  public:
39  {
40  defineRequiredProperty<std::string>(
41  "ClassCollections",
42  "Comma separated list of MongoDB collection (<db>.<collection>) which store known "
43  "object classes. First collection will be used for writing.");
44  defineOptionalProperty<std::string>(
45  "RelationCollections",
46  "",
47  "Comma separated list of MongoDB collection (<db>.<collection>) which store known "
48  "object classes relations. First collection will be used for writing.");
49  defineOptionalProperty<std::string>(
50  "GraphCollections",
51  "",
52  "Comma separated list of MongoDB collection (<db>.<collection>) which store "
53  "graphs. First collection will be used for writing.");
54  }
55  };
56 
57  using EntityMap = std::map<std::string, EntityBasePtr>;
58 
59  /*!
60  * \brief The PriorKnowledge class provides a database with common sense and/or prior knowldge.
61  *
62  * See \ref priorknowledge "memoryx::PriorKnowledge" - common sense knowledge database.
63  */
65  virtual public PriorKnowledgeInterface,
66  virtual public SegmentedMemory,
67  virtual public armarx::Component
68  {
69  public:
70  // inherited from Component
71  std::string
72  getDefaultName() const override
73  {
74  return "PriorKnowledge";
75  }
76 
77  void onInitComponent() override;
78  void onConnectComponent() override;
79 
80  /**
81  * @see PropertyUser::createPropertyDefinitions()
82  */
85  {
87  new PriorKnowledgePropertyDefinitions(getConfigIdentifier()));
88  }
89 
90  void clear(const ::Ice::Current& = Ice::emptyCurrent) override;
91 
93  getObjectAdapter() const override
94  {
95  return Component::getObjectAdapter();
96  }
97 
98  // implementation of PriorKnowledgeInterface
99  PersistentObjectClassSegmentBasePrx
100  getObjectClassesSegment(const ::Ice::Current& = Ice::emptyCurrent) const override;
101 
102  PersistentRelationSegmentBasePrx
103  getRelationsSegment(const ::Ice::Current& = Ice::emptyCurrent) const override;
104 
105  GraphMemorySegmentBasePrx
106  getGraphSegment(const ::Ice::Current& c = Ice::emptyCurrent) const override;
107 
108  CommonStorageInterfacePrx
109  getCommonStorage(const ::Ice::Current& = Ice::emptyCurrent) const override;
110 
111  bool hasGraphSegment(const Ice::Current& c = Ice::emptyCurrent) const override;
112 
113  bool isPriorCollection(const ::std::string& collNS,
114  const ::Ice::Current& = Ice::emptyCurrent) override;
115 
116  protected:
117  CommonStorageInterfacePrx dataBasePrx;
118 
119  NameList classCollNames;
121  NameList graphCollNames;
122 
123  void setSegmentReadCollections(const PersistentEntitySegmentBasePtr& segmentPrx,
124  const NameList& collNameList);
125 
126  // MemoryInterface interface
127  public:
128  std::string getMemoryName(const Ice::Current&) const override;
129  AbstractMemorySegmentPrx addGenericSegment(const std::string& segmentName,
130  const Ice::Current&) override;
131  };
132 
134 
135 } // namespace memoryx
memoryx::EntityMap
std::map< std::string, EntityBasePtr > EntityMap
Definition: PriorKnowledge.h:57
SegmentedMemory.h
memoryx::PriorKnowledge::relationCollNames
NameList relationCollNames
Definition: PriorKnowledge.h:120
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:345
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
memoryx::PriorKnowledge::getObjectAdapter
Ice::ObjectAdapterPtr getObjectAdapter() const override
Definition: PriorKnowledge.h:93
memoryx::SegmentedMemory
The SegmentedMemory class provides an interface for organizing memories with segmented data structure...
Definition: SegmentedMemory.h:46
IceInternal::Handle<::Ice::ObjectAdapter >
memoryx::PriorKnowledge::dataBasePrx
CommonStorageInterfacePrx dataBasePrx
Definition: PriorKnowledge.h:117
ARMARXCOMPONENT_IMPORT_EXPORT
#define ARMARXCOMPONENT_IMPORT_EXPORT
Definition: ImportExportComponent.h:38
memoryx::PriorKnowledgePropertyDefinitions::PriorKnowledgePropertyDefinitions
PriorKnowledgePropertyDefinitions(std::string prefix)
Definition: PriorKnowledge.h:38
memoryx::PriorKnowledge
The PriorKnowledge class provides a database with common sense and/or prior knowldge.
Definition: PriorKnowledge.h:64
memoryx::PriorKnowledge::getDefaultName
std::string getDefaultName() const override
Retrieve default name of component.
Definition: PriorKnowledge.h:72
memoryx::PriorKnowledge::classCollNames
NameList classCollNames
Definition: PriorKnowledge.h:119
Component.h
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:91
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:69
memoryx::PriorKnowledge::graphCollNames
NameList graphCollNames
Definition: PriorKnowledge.h:121
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::ComponentPropertyDefinitions::ComponentPropertyDefinitions
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
Definition: Component.cpp:35
armarx::PropertyDefinitionsPtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
Definition: forward_declarations.h:35
memoryx::PriorKnowledge::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: PriorKnowledge.h:84
memoryx::PriorKnowledgePropertyDefinitions
Definition: PriorKnowledge.h:35
ImportExportComponent.h