knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
Vocabulary.h
Go to the documentation of this file.
1 /*
2  * This file is part of KnowRob, please consult
3  * https://github.com/knowrob/knowrob for license details.
4  */
5 
6 #ifndef KNOWROB_VOCABULARY_H
7 #define KNOWROB_VOCABULARY_H
8 
9 #include <memory>
10 #include <string>
11 #include <string_view>
12 #include <map>
13 #include "Property.h"
14 #include "Class.h"
15 #include "ImportHierarchy.h"
16 
17 namespace knowrob {
22  class Vocabulary {
23  public:
25 
27 
33  void addResourceType(const std::string_view &resource_iri, const std::string_view &type_iri);
34 
39  bool isDefinedClass(const std::string_view &iri);
40 
45  semweb::ClassPtr getDefinedClass(const std::string_view &iri) const;
46 
51  std::vector<semweb::ClassPtr> getDefinedClassesWithPrefix(const std::string_view &prefix) const;
52 
57  std::vector<std::string_view> getDefinedClassNamesWithPrefix(const std::string_view &prefix) const;
58 
64  semweb::ClassPtr defineClass(const std::string_view &iri);
65 
73  void addSubClassOf(const std::string_view &subClass, const std::string_view &superClass,
74  std::optional<std::string_view> graph);
75 
81  bool isSubClassOf(const std::string_view &subClass, const std::string_view &superClass);
82 
87  bool isDefinedProperty(const std::string_view &iri);
88 
93  bool isDefinedReification(const std::string_view &iri);
94 
99  semweb::PropertyPtr getDefinedProperty(const std::string_view &iri) const;
100 
105  semweb::PropertyPtr getDefinedReification(const std::string_view &iri) const;
106 
111  std::vector<semweb::PropertyPtr> getDefinedPropertiesWithPrefix(const std::string_view &prefix) const;
112 
117  std::vector<std::string_view> getDefinedPropertyNamesWithPrefix(const std::string_view &prefix) const;
118 
124  semweb::PropertyPtr defineProperty(const std::string_view &iri);
125 
132 
140  void addSubPropertyOf(const std::string_view &subProperty, const std::string_view &superProperty,
141  std::optional<std::string_view> graph);
142 
148  void setInverseOf(const std::string_view &a, const std::string_view &b);
149 
154  void setPropertyFlag(const std::string_view &iri, semweb::PropertyFlag flag);
155 
161 
166  bool isAnnotationProperty(const std::string_view &iri);
167 
172  bool isObjectProperty(const std::string_view &iri);
173 
178  bool isDatatypeProperty(const std::string_view &iri);
179 
184  static bool isTaxonomicProperty(const std::string_view &iri);
185 
192  void setFrequency(const std::string_view &iri, uint64_t frequency);
193 
199  void increaseFrequency(const std::string_view &iri);
200 
207  uint64_t frequency(const std::string_view &iri) const;
208 
212  const std::shared_ptr<ImportHierarchy> &importHierarchy() const { return importHierarchy_; }
213 
220  template<typename T>
221  std::shared_ptr<T> define(const std::string_view &iri);
222 
223  protected:
224  std::map<std::string_view, semweb::ClassPtr, std::less<>> definedClasses_;
225  std::map<std::string_view, semweb::PropertyPtr, std::less<>> definedProperties_;
226  std::map<std::string_view, semweb::PropertyPtr, std::less<>> definedReifications_;
227  std::map<std::string_view, uint64_t> frequency_;
228  std::shared_ptr<ImportHierarchy> importHierarchy_;
229 
230  semweb::PropertyPtr defineProperty_(const std::shared_ptr<semweb::Property> &p);
231  };
232 
233  using VocabularyPtr = std::shared_ptr<Vocabulary>;
234 
235 } // knowrob
236 
237 #endif //KNOWROB_VOCABULARY_H
bool isDefinedProperty(const std::string_view &iri)
std::vector< semweb::PropertyPtr > getDefinedPropertiesWithPrefix(const std::string_view &prefix) const
bool isSubClassOf(const std::string_view &subClass, const std::string_view &superClass)
std::map< std::string_view, semweb::PropertyPtr, std::less<> > definedReifications_
Definition: Vocabulary.h:226
void increaseFrequency(const std::string_view &iri)
void setInverseOf(const std::string_view &a, const std::string_view &b)
std::vector< std::string_view > getDefinedClassNamesWithPrefix(const std::string_view &prefix) const
std::map< std::string_view, semweb::ClassPtr, std::less<> > definedClasses_
Definition: Vocabulary.h:224
void addSubPropertyOf(const std::string_view &subProperty, const std::string_view &superProperty, std::optional< std::string_view > graph)
std::vector< std::string_view > getDefinedPropertyNamesWithPrefix(const std::string_view &prefix) const
semweb::PropertyPtr defineProperty(const IRIAtomPtr &iri)
std::map< std::string_view, uint64_t > frequency_
Definition: Vocabulary.h:227
static bool isTaxonomicProperty(const std::string_view &iri)
semweb::PropertyPtr defineProperty_(const std::shared_ptr< semweb::Property > &p)
bool isDefinedClass(const std::string_view &iri)
void addSubClassOf(const std::string_view &subClass, const std::string_view &superClass, std::optional< std::string_view > graph)
semweb::ClassPtr defineClass(const std::string_view &iri)
void setPropertyFlag(const std::string_view &iri, semweb::PropertyFlag flag)
std::shared_ptr< ImportHierarchy > importHierarchy_
Definition: Vocabulary.h:228
semweb::PropertyPtr getDefinedReification(const std::string_view &iri) const
semweb::ClassPtr getDefinedClass(const std::string_view &iri) const
std::shared_ptr< T > define(const std::string_view &iri)
bool isDefinedReification(const std::string_view &iri)
semweb::PropertyPtr getDefinedProperty(const std::string_view &iri) const
std::vector< semweb::ClassPtr > getDefinedClassesWithPrefix(const std::string_view &prefix) const
void addResourceType(const std::string_view &resource_iri, const std::string_view &type_iri)
semweb::PropertyPtr defineProperty(const std::string_view &iri)
uint64_t frequency(const std::string_view &iri) const
Definition: Vocabulary.cpp:234
std::map< std::string_view, semweb::PropertyPtr, std::less<> > definedProperties_
Definition: Vocabulary.h:225
void setPropertyFlag(const IRIAtomPtr &iri, semweb::PropertyFlag flag)
const std::shared_ptr< ImportHierarchy > & importHierarchy() const
Definition: Vocabulary.h:212
bool isDatatypeProperty(const std::string_view &iri)
bool isAnnotationProperty(const std::string_view &iri)
bool isObjectProperty(const std::string_view &iri)
uint64_t frequency(const std::string_view &iri) const
void setFrequency(const std::string_view &iri, uint64_t frequency)
constexpr std::string_view prefix
Definition: owl.h:14
std::shared_ptr< Class > ClassPtr
Definition: Class.h:97
std::shared_ptr< Property > PropertyPtr
Definition: Property.h:175
IRIAtomPtr iri(std::string_view ns, std::string_view name)
Definition: IRIAtom.cpp:62
std::shared_ptr< IRIAtom > IRIAtomPtr
Definition: IRIAtom.h:57
std::shared_ptr< Vocabulary > VocabularyPtr
Definition: Vocabulary.h:233