knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
DataSource.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_DATA_SOURCES_H_
7 #define KNOWROB_DATA_SOURCES_H_
8 
9 #include <string>
10 #include "knowrob/URI.h"
11 #include "knowrob/semweb/Vocabulary.h"
12 
13 namespace knowrob {
17  enum class DataSourceType {
18  ONTOLOGY,
20  };
21 
26  class DataSource {
27  public:
35 
39  const auto &uri() const { return uri_(); }
40 
44  const auto &path() const { return uri_.path(); }
45 
49  const auto &format() const { return format_; }
50 
55 
59  auto name() const { return getNameFromURI(uri()); }
60 
64  auto version() const { return getVersionFromURI(uri()); }
65 
72  static std::string getNameFromURI(const std::string &uriString);
73 
83  static std::string getVersionFromURI(const std::string &uriString);
84 
89  static bool isVersionString(const std::string &versionString);
90 
97  static std::shared_ptr<DataSource>
98  create(const VocabularyPtr &vocabulary, const boost::property_tree::ptree &config);
99 
100  protected:
103  URI uri_;
104  };
105 
106  // alias
107  using DataSourcePtr = std::shared_ptr<DataSource>;
108 }
109 
110 #endif //KNOWROB_DATA_SOURCES_H_
static std::string getNameFromURI(const std::string &uriString)
DataSourceType dataSourceType_
Definition: DataSource.h:101
static std::string getNameFromURI(const std::string &uriString)
Definition: DataSource.cpp:36
static std::string getVersionFromURI(const std::string &uriString)
Definition: DataSource.cpp:48
const auto & path() const
Definition: DataSource.h:44
auto name() const
Definition: DataSource.h:59
const auto & format() const
Definition: DataSource.h:49
const auto & uri() const
Definition: DataSource.h:39
auto version() const
Definition: DataSource.h:64
DataSourceType dataSourceType() const
Definition: DataSource.h:54
static std::shared_ptr< DataSource > create(const VocabularyPtr &vocabulary, const boost::property_tree::ptree &config)
static std::string getVersionFromURI(const std::string &uriString)
std::string format_
Definition: DataSource.h:102
DataSource(URI uri, std::string_view format, DataSourceType dataSourceType)
static bool isVersionString(const std::string &versionString)
const std::string & path() const
Definition: URI.h:57
TermRule & string()
Definition: terms.cpp:63
DataSourceType
Definition: DataSource.h:17
std::shared_ptr< DataSource > DataSourcePtr
Definition: DataSource.h:107
std::shared_ptr< Vocabulary > VocabularyPtr
Definition: Vocabulary.h:233