knowrob
2.1.0
A Knowledge Base System for Cognition-enabled Robots
|
#include <RedlandModel.h>
Public Member Functions | |
RedlandModel () | |
~RedlandModel () override | |
void | setStorageType (RedlandStorageType storageType) |
void | setStorageHashType (RedlandHashType hashType) |
void | setHost (std::string_view host) |
void | setDatabase (std::string_view database) |
void | setUser (std::string_view user) |
void | setPassword (std::string_view password) |
void | setStorageDirectory (std::string_view dir=".") |
void | setHashesStorage (RedlandHashType hashType, std::string_view dir=".") |
void | setMemoryStorage () |
void | setRaptorWorld (librdf_world *world) |
void | setOrigin (std::string_view origin) |
auto | storageType () const |
bool | isInitialized () const |
bool | initializeBackend () |
bool | initializeBackend (const PropertyTree &config) override |
bool | load (const URI &uri, semweb::TripleFormat tripleFormat) |
bool | sparql (std::string_view queryString, const BindingsHandler &callback) const override |
bool | insertOne (const Triple &triple) override |
bool | insertAll (const TripleContainerPtr &triples) override |
bool | removeOne (const Triple &triple) override |
bool | removeAll (const TripleContainerPtr &triples) override |
bool | removeAllWithOrigin (std::string_view origin) override |
bool | isPersistent () const override |
bool | contains (const Triple &triple) override |
void | batch (const TripleHandler &callback) const override |
void | batchOrigin (std::string_view origin, const TripleHandler &callback) override |
void | match (const TriplePattern &query, const TripleVisitor &visitor) override |
RedlandModel () | |
~RedlandModel () override | |
void | setStorageType (RedlandStorageType storageType) |
void | setStorageHashType (RedlandHashType hashType) |
void | setHost (std::string_view host) |
void | setDatabase (std::string_view database) |
void | setUser (std::string_view user) |
void | setPassword (std::string_view password) |
void | setStorageDirectory (std::string_view dir=".") |
void | setHashesStorage (RedlandHashType hashType, std::string_view dir=".") |
void | setMemoryStorage () |
void | setRaptorWorld (librdf_world *world) |
void | setOrigin (std::string_view origin) |
auto | storageType () const |
bool | isInitialized () const |
bool | initializeBackend () |
bool | initializeBackend (const PropertyTree &config) override |
bool | load (const URI &uri, semweb::TripleFormat tripleFormat) |
bool | sparql (std::string_view queryString, const BindingsHandler &callback) const override |
bool | insertOne (const Triple &triple) override |
bool | insertAll (const TripleContainerPtr &triples) override |
bool | removeOne (const Triple &triple) override |
bool | removeAll (const TripleContainerPtr &triples) override |
bool | removeAllWithOrigin (std::string_view origin) override |
bool | isPersistent () const override |
bool | contains (const Triple &triple) override |
void | batch (const TripleHandler &callback) const override |
void | batchOrigin (std::string_view origin, const TripleHandler &callback) override |
void | match (const TriplePattern &query, const TripleVisitor &visitor) override |
Public Member Functions inherited from knowrob::SPARQLBackend | |
SPARQLBackend (SPARQLFlags flags) | |
bool | query (const SPARQLQuery &query, const BindingsHandler &callback) const |
void | query (const GraphQueryPtr &query, const BindingsHandler &callback) override |
void | count (const ResourceCounter &callback) const override |
SPARQLBackend (SPARQLFlags flags) | |
bool | query (const SPARQLQuery &query, const BindingsHandler &callback) const |
void | query (const GraphQueryPtr &query, const BindingsHandler &callback) override |
void | count (const ResourceCounter &callback) const override |
Public Member Functions inherited from knowrob::QueryableStorage | |
QueryableStorage (StorageFeatures features=StorageFeature::NothingSpecial) | |
~QueryableStorage () override=default | |
virtual void | foreach (const TripleVisitor &visitor) const |
std::vector< VersionedOriginPtr > | getOrigins () |
std::optional< std::string > | getVersionOfOrigin (std::string_view origin) |
void | setVersionOfOrigin (std::string_view origin, std::string_view version) |
void | dropSessionOrigins () |
GraphQueryExpansionPtr | expand (const GraphQueryPtr &q) |
QueryableStorage (StorageFeatures features=StorageFeature::NothingSpecial) | |
~QueryableStorage () override=default | |
virtual void | foreach (const TripleVisitor &visitor) const |
std::vector< VersionedOriginPtr > | getOrigins () |
std::optional< std::string > | getVersionOfOrigin (std::string_view origin) |
void | setVersionOfOrigin (std::string_view origin, std::string_view version) |
void | dropSessionOrigins () |
GraphQueryExpansionPtr | expand (const GraphQueryPtr &q) |
Public Member Functions inherited from knowrob::Storage | |
Storage (StorageFeatures features=StorageFeature::NothingSpecial) | |
virtual | ~Storage ()=default |
PluginLanguage | storageLanguage () const |
const auto & | vocabulary () const |
void | setVocabulary (std::shared_ptr< Vocabulary > vocabulary) |
bool | supports (StorageFeature feature) const |
std::optional< std::string > | getVersionOfOrigin (std::string_view origin) const |
void | setVersionOfOrigin (std::string_view origin, std::optional< std::string_view > version) |
Storage (StorageFeatures features=StorageFeature::NothingSpecial) | |
virtual | ~Storage ()=default |
PluginLanguage | storageLanguage () const |
const auto & | vocabulary () const |
void | setVocabulary (std::shared_ptr< Vocabulary > vocabulary) |
bool | supports (StorageFeature feature) const |
std::optional< std::string > | getVersionOfOrigin (std::string_view origin) const |
void | setVersionOfOrigin (std::string_view origin, std::optional< std::string_view > version) |
Public Member Functions inherited from knowrob::DataSourceHandler | |
DataSourceHandler ()=default | |
virtual | ~DataSourceHandler ()=default |
void | addDataHandler (const std::string &format, const DataSourceLoader &fn) |
bool | loadDataSource (const DataSourcePtr &dataSource) |
bool | hasDataHandler (const DataSourcePtr &dataSource) const |
DataSourceHandler ()=default | |
virtual | ~DataSourceHandler ()=default |
void | addDataHandler (const std::string &format, const DataSourceLoader &fn) |
bool | loadDataSource (const DataSourcePtr &dataSource) |
bool | hasDataHandler (const DataSourcePtr &dataSource) const |
Static Public Attributes | |
static constexpr std::string_view | QUERY_LANGUAGE_SPARQL = "sparql" |
Static Public Attributes inherited from knowrob::QueryableStorage | |
static AtomPtr | versionProperty = IRIAtom::Tabled("http://knowrob.org/kb/knowrob.owl#hasVersionOfOrigin") |
Protected Member Functions | |
RedlandURI & | xsdURI (XSDType xsdType) |
std::string | getStorageOptions () const |
void | knowrobToRaptor (const Triple &triple, raptor_statement *raptorTriple) |
void | knowrobToRaptor (const TriplePattern &pat, raptor_statement *raptorTriple) |
raptor_term * | knowrobToRaptor (const TermPtr &term) |
librdf_node * | getContextNode (std::string_view origin) |
librdf_node * | getContextNode (const Triple &triple) |
RedlandURI & | xsdURI (XSDType xsdType) |
std::string | getStorageOptions () const |
void | knowrobToRaptor (const Triple &triple, raptor_statement *raptorTriple) |
void | knowrobToRaptor (const TriplePattern &pat, raptor_statement *raptorTriple) |
raptor_term * | knowrobToRaptor (const TermPtr &term) |
librdf_node * | getContextNode (std::string_view origin) |
librdf_node * | getContextNode (const Triple &triple) |
Protected Member Functions inherited from knowrob::Storage | |
void | enableFeature (StorageFeature feature) |
void | setStorageLanguage (PluginLanguage storageLanguage) |
void | enableFeature (StorageFeature feature) |
void | setStorageLanguage (PluginLanguage storageLanguage) |
Protected Member Functions inherited from knowrob::DataSourceHandler | |
virtual bool | loadDataSourceWithUnknownFormat (const DataSourcePtr &) |
virtual bool | loadDataSourceWithUnknownFormat (const DataSourcePtr &) |
Protected Attributes | |
librdf_world * | ownedWorld_ |
librdf_world * | world_ |
librdf_model * | model_ |
librdf_storage * | storage_ |
RedlandURI | xsdURIs_ [static_cast< int >(XSDType::LAST)] |
std::map< std::string, librdf_node *, std::less<> > | contextNodes_ |
std::string | storageName_ |
std::optional< std::string > | origin_ |
std::optional< std::string > | host_ |
std::optional< std::string > | port_ |
std::optional< std::string > | database_ |
std::optional< std::string > | user_ |
std::optional< std::string > | password_ |
std::optional< std::string > | storageDir_ |
std::optional< RedlandHashType > | hashType_ |
RedlandStorageType | storageType_ |
std::string | storageOptions_ |
Protected Attributes inherited from knowrob::SPARQLBackend | |
SPARQLFlags | sparqlFlags_ |
Protected Attributes inherited from knowrob::Storage | |
std::map< std::string, std::string > | originVersions_ |
std::shared_ptr< Vocabulary > | vocabulary_ |
StorageFeatures | features_ |
PluginLanguage | storageLanguage_ |
Protected Attributes inherited from knowrob::DataSourceHandler | |
std::map< std::string, DataSourceLoader > | dataSourceHandler_ |
Additional Inherited Members | |
Static Public Member Functions inherited from knowrob::QueryableStorage | |
static std::shared_ptr< AnswerYes > | yes (const GraphPathQueryPtr &original, const GraphQueryExpansionPtr &expansion, const BindingsPtr &bindings) |
static std::shared_ptr< AnswerNo > | no (const GraphPathQueryPtr &q) |
static std::shared_ptr< AnswerYes > | yes (const GraphPathQueryPtr &original, const GraphQueryExpansionPtr &expansion, const BindingsPtr &bindings) |
static std::shared_ptr< AnswerNo > | no (const GraphPathQueryPtr &q) |
Interface for a Redland model. A redland model is a triple store that can be queried with SPARQL. It can interface with different storage types, such as in-memory, MySQL, PostgreSQL, and SQLite, and can load and save triples in different formats, such as RDF/XML, Turtle, and N-Triples. It can further interface with SPARQL endpoints.
Definition at line 52 of file RedlandModel.h.
RedlandModel::RedlandModel | ( | ) |
Definition at line 79 of file RedlandModel.cpp.
|
override |
Definition at line 88 of file RedlandModel.cpp.
knowrob::RedlandModel::RedlandModel | ( | ) |
|
override |
|
overridevirtual |
Iterate over all triples in the model.
callback | the callback to handle the triples. |
Implements knowrob::QueryableStorage.
Definition at line 437 of file RedlandModel.cpp.
|
overridevirtual |
Iterate over all triples in the model.
callback | the callback to handle the triples. |
Implements knowrob::QueryableStorage.
|
overridevirtual |
Iterate over all triples in the model that have a given origin.
origin | the origin of the triples. |
callback | the callback to handle the triples. |
Implements knowrob::QueryableStorage.
Definition at line 451 of file RedlandModel.cpp.
|
overridevirtual |
Iterate over all triples in the model that have a given origin.
origin | the origin of the triples. |
callback | the callback to handle the triples. |
Implements knowrob::QueryableStorage.
|
overridevirtual |
triple | a framed triple. |
Reimplemented from knowrob::QueryableStorage.
Definition at line 460 of file RedlandModel.cpp.
|
overridevirtual |
triple | a framed triple. |
Reimplemented from knowrob::QueryableStorage.
|
protected |
Definition at line 557 of file RedlandModel.cpp.
|
protected |
|
protected |
Definition at line 545 of file RedlandModel.cpp.
|
protected |
|
protected |
Definition at line 259 of file RedlandModel.cpp.
|
protected |
bool RedlandModel::initializeBackend | ( | ) |
Initialize the backend.
Definition at line 174 of file RedlandModel.cpp.
bool knowrob::RedlandModel::initializeBackend | ( | ) |
Initialize the backend.
|
overridevirtual |
Initialize this backend from a property tree.
config | a property tree. |
Implements knowrob::Storage.
Definition at line 222 of file RedlandModel.cpp.
|
overridevirtual |
Initialize this backend from a property tree.
config | a property tree. |
Implements knowrob::Storage.
|
overridevirtual |
Add assertions to this backend.
triples | a set of triples. |
Implements knowrob::Storage.
Definition at line 362 of file RedlandModel.cpp.
|
overridevirtual |
Add assertions to this backend.
triples | a set of triples. |
Implements knowrob::Storage.
|
overridevirtual |
Add an assertion to this backend.
triple | a triple. |
Implements knowrob::Storage.
Definition at line 352 of file RedlandModel.cpp.
|
overridevirtual |
Add an assertion to this backend.
triple | a triple. |
Implements knowrob::Storage.
bool RedlandModel::isInitialized | ( | ) | const |
Definition at line 117 of file RedlandModel.cpp.
bool knowrob::RedlandModel::isInitialized | ( | ) | const |
|
overridevirtual |
Implements knowrob::QueryableStorage.
Definition at line 121 of file RedlandModel.cpp.
|
overridevirtual |
Implements knowrob::QueryableStorage.
|
protected |
Definition at line 568 of file RedlandModel.cpp.
|
protected |
|
protected |
Definition at line 603 of file RedlandModel.cpp.
|
protected |
|
protected |
Definition at line 587 of file RedlandModel.cpp.
|
protected |
bool RedlandModel::load | ( | const URI & | uri, |
semweb::TripleFormat | tripleFormat | ||
) |
Load an URI into the model. Note that in case of SPARQL endpoints, this does not mean al data is copied into the model.
uri | the uri to load. |
tripleFormat | the format of the triples. |
Definition at line 297 of file RedlandModel.cpp.
bool knowrob::RedlandModel::load | ( | const URI & | uri, |
semweb::TripleFormat | tripleFormat | ||
) |
Load an URI into the model. Note that in case of SPARQL endpoints, this does not mean al data is copied into the model.
uri | the uri to load. |
tripleFormat | the format of the triples. |
|
overridevirtual |
query | a framed triple pattern. |
visitor | a function that is called for each matching framed triple. |
Reimplemented from knowrob::QueryableStorage.
Definition at line 468 of file RedlandModel.cpp.
|
overridevirtual |
query | a framed triple pattern. |
visitor | a function that is called for each matching framed triple. |
Reimplemented from knowrob::QueryableStorage.
|
overridevirtual |
Delete all matching statements from this backend.
triples | a set of triples. |
Implements knowrob::Storage.
Definition at line 384 of file RedlandModel.cpp.
|
overridevirtual |
Delete all matching statements from this backend.
triples | a set of triples. |
Implements knowrob::Storage.
|
overridevirtual |
Delete all statements with a given origin from this backend.
origin | the origin of the statements to be deleted. |
Implements knowrob::Storage.
Definition at line 399 of file RedlandModel.cpp.
|
overridevirtual |
Delete all statements with a given origin from this backend.
origin | the origin of the statements to be deleted. |
Implements knowrob::Storage.
|
overridevirtual |
Delete the first matching statement from this backend.
triple | a triple. |
Implements knowrob::Storage.
Definition at line 375 of file RedlandModel.cpp.
|
overridevirtual |
Delete the first matching statement from this backend.
triple | a triple. |
Implements knowrob::Storage.
void RedlandModel::setDatabase | ( | std::string_view | database | ) |
database | the database name. |
Definition at line 142 of file RedlandModel.cpp.
void knowrob::RedlandModel::setDatabase | ( | std::string_view | database | ) |
database | the database name. |
void RedlandModel::setHashesStorage | ( | RedlandHashType | hashType, |
std::string_view | dir = "." |
||
) |
Set the storage type to "hashes".
hashType | the hash type. |
dir | the directory for the hashes storage. |
Definition at line 162 of file RedlandModel.cpp.
void knowrob::RedlandModel::setHashesStorage | ( | RedlandHashType | hashType, |
std::string_view | dir = "." |
||
) |
Set the storage type to "hashes".
hashType | the hash type. |
dir | the directory for the hashes storage. |
void RedlandModel::setHost | ( | std::string_view | host | ) |
host | the host of the database. |
Definition at line 138 of file RedlandModel.cpp.
void knowrob::RedlandModel::setHost | ( | std::string_view | host | ) |
host | the host of the database. |
void RedlandModel::setMemoryStorage | ( | ) |
Set the storage type to "memory".
Definition at line 170 of file RedlandModel.cpp.
void knowrob::RedlandModel::setMemoryStorage | ( | ) |
Set the storage type to "memory".
|
inline |
If set assume triples in this backend have this as a default origin.
origin | the origin of the triples. |
Definition at line 121 of file RedlandModel.h.
|
inline |
If set assume triples in this backend have this as a default origin.
origin | the origin of the triples. |
Definition at line 121 of file RedlandModel.h.
void RedlandModel::setPassword | ( | std::string_view | password | ) |
password | the password for the database. |
Definition at line 150 of file RedlandModel.cpp.
void knowrob::RedlandModel::setPassword | ( | std::string_view | password | ) |
password | the password for the database. |
void RedlandModel::setRaptorWorld | ( | librdf_world * | world | ) |
If not set, the model will create its own.
world | a redland world. |
Definition at line 158 of file RedlandModel.cpp.
void knowrob::RedlandModel::setRaptorWorld | ( | librdf_world * | world | ) |
If not set, the model will create its own.
world | a redland world. |
void RedlandModel::setStorageDirectory | ( | std::string_view | dir = "." | ) |
dir | the directory for the storage. |
Definition at line 154 of file RedlandModel.cpp.
void knowrob::RedlandModel::setStorageDirectory | ( | std::string_view | dir = "." | ) |
dir | the directory for the storage. |
void RedlandModel::setStorageHashType | ( | RedlandHashType | hashType | ) |
Set the "hash-type" parameter of the storage.
hashType | the hash type. |
Definition at line 134 of file RedlandModel.cpp.
void knowrob::RedlandModel::setStorageHashType | ( | RedlandHashType | hashType | ) |
Set the "hash-type" parameter of the storage.
hashType | the hash type. |
void RedlandModel::setStorageType | ( | RedlandStorageType | storageType | ) |
Set the storage type.
storageType | the storage type. |
Definition at line 130 of file RedlandModel.cpp.
void knowrob::RedlandModel::setStorageType | ( | RedlandStorageType | storageType | ) |
Set the storage type.
storageType | the storage type. |
void RedlandModel::setUser | ( | std::string_view | user | ) |
user | the user name for the database. |
Definition at line 146 of file RedlandModel.cpp.
void knowrob::RedlandModel::setUser | ( | std::string_view | user | ) |
user | the user name for the database. |
|
overridevirtual |
Run a SPARQL query on the model.
queryString | the query to run. |
callback | the callback to handle the results. |
Implements knowrob::SPARQLBackend.
Definition at line 490 of file RedlandModel.cpp.
|
overridevirtual |
Run a SPARQL query on the model.
queryString | the query to run. |
callback | the callback to handle the results. |
Implements knowrob::SPARQLBackend.
|
inline |
|
inline |
|
protected |
Definition at line 564 of file RedlandModel.cpp.
|
protected |
|
protected |
Definition at line 196 of file RedlandModel.h.
|
protected |
Definition at line 203 of file RedlandModel.h.
|
protected |
Definition at line 207 of file RedlandModel.h.
|
protected |
Definition at line 201 of file RedlandModel.h.
|
protected |
Definition at line 187 of file RedlandModel.h.
|
protected |
Definition at line 200 of file RedlandModel.h.
|
protected |
Definition at line 185 of file RedlandModel.h.
|
protected |
Definition at line 205 of file RedlandModel.h.
|
protected |
Definition at line 202 of file RedlandModel.h.
|
staticconstexpr |
Definition at line 54 of file RedlandModel.h.
|
protected |
Definition at line 188 of file RedlandModel.h.
|
protected |
Definition at line 206 of file RedlandModel.h.
|
protected |
Definition at line 198 of file RedlandModel.h.
|
protected |
Definition at line 209 of file RedlandModel.h.
|
protected |
Definition at line 208 of file RedlandModel.h.
|
protected |
Definition at line 204 of file RedlandModel.h.
|
protected |
Definition at line 186 of file RedlandModel.h.
|
protected |
Definition at line 192 of file RedlandModel.h.