knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
knowrob::SPARQLService Class Reference

#include <SPARQLService.h>

Inheritance diagram for knowrob::SPARQLService:
Collaboration diagram for knowrob::SPARQLService:

Public Member Functions

 SPARQLService (const URI &uri, semweb::TripleFormat format)
 
 SPARQLService (const URI &uri, std::string_view format)
 
bool load (const TripleHandler &callback) override
 
 SPARQLService (const URI &uri, semweb::TripleFormat format)
 
 SPARQLService (const URI &uri, std::string_view format)
 
bool load (const TripleHandler &callback) override
 
- Public Member Functions inherited from knowrob::OntologySource
 OntologySource (const URI &uri, std::string_view format)
 
virtual ~OntologySource ()=default
 
void setFrame (const GraphSelectorPtr &frame)
 
const auto & frame () const
 
void setParentOrigin (std::string_view parentOrigin)
 
auto & parentOrigin () const
 
std::string_view origin () const
 
const auto & imports () const
 
void setImports (const std::vector< std::string > &imports)
 
 OntologySource (const URI &uri, std::string_view format)
 
virtual ~OntologySource ()=default
 
void setFrame (const GraphSelectorPtr &frame)
 
const auto & frame () const
 
void setParentOrigin (std::string_view parentOrigin)
 
auto & parentOrigin () const
 
std::string_view origin () const
 
const auto & imports () const
 
void setImports (const std::vector< std::string > &imports)
 
- Public Member Functions inherited from knowrob::DataSource
 DataSource (URI uri, std::string_view format, DataSourceType dataSourceType)
 
const auto & uri () const
 
const auto & path () const
 
const auto & format () const
 
DataSourceType dataSourceType () const
 
auto name () const
 
auto version () const
 
 DataSource (URI uri, std::string_view format, DataSourceType dataSourceType)
 
const auto & uri () const
 
const auto & path () const
 
const auto & format () const
 
DataSourceType dataSourceType () const
 
auto name () const
 
auto version () const
 

Protected Attributes

RedlandModel model_
 
- Protected Attributes inherited from knowrob::OntologySource
GraphSelectorPtr frame_
 
std::optional< std::string > parentOrigin_
 
std::string origin_
 
std::vector< std::string > imports_
 
- Protected Attributes inherited from knowrob::DataSource
DataSourceType dataSourceType_
 
std::string format_
 
URI uri_
 

Additional Inherited Members

- Static Public Member Functions inherited from knowrob::DataSource
static std::string getNameFromURI (const std::string &uriString)
 
static std::string getVersionFromURI (const std::string &uriString)
 
static bool isVersionString (const std::string &versionString)
 
static std::shared_ptr< DataSourcecreate (const VocabularyPtr &vocabulary, const boost::property_tree::ptree &config)
 
static std::string getNameFromURI (const std::string &uriString)
 
static std::string getVersionFromURI (const std::string &uriString)
 
static bool isVersionString (const std::string &versionString)
 
static std::shared_ptr< DataSourcecreate (const VocabularyPtr &vocabulary, const boost::property_tree::ptree &config)
 

Detailed Description

A SPARQL service is a data service that can be queried for triples.

Definition at line 19 of file SPARQLService.h.

Constructor & Destructor Documentation

◆ SPARQLService() [1/4]

SPARQLService::SPARQLService ( const URI uri,
semweb::TripleFormat  format 
)
Parameters
urithe URI of the SPARQL endpoint.
formatthe format of the triples in the endpoint.

Definition at line 11 of file SPARQLService.cpp.

13 }
const auto & format() const
Definition: DataSource.h:49
const auto & uri() const
Definition: DataSource.h:39
SPARQLService(const URI &uri, semweb::TripleFormat format)
std::string_view tripleFormatToString(TripleFormat format)

◆ SPARQLService() [2/4]

SPARQLService::SPARQLService ( const URI uri,
std::string_view  format 
)

s

Parameters
urithe URI of the SPARQL endpoint.
formatthe format of the triples in the endpoint.

Definition at line 15 of file SPARQLService.cpp.

17  // create a Redland model for the SPARQL endpoint
18  // Note that the model has interfaces for insert and remove triples, these won't
19  // interact with the SPARQL endpoint, but with the local storage of the model.
22  if (!model_.initializeBackend()) {
23  throw StorageError("Failed to initialize Redland backend for SPARQL endpoint at \"{}\".", uri());
24  }
25  // set up the model to interface with the SPARQL endpoint
27  throw StorageError("Failed to load URI of SPARQL endpoint at \"{}\".", uri());
28  }
29 }
OntologySource(const URI &uri, std::string_view format)
void setOrigin(std::string_view origin)
Definition: RedlandModel.h:121
bool load(const URI &uri, semweb::TripleFormat tripleFormat)
void setStorageType(RedlandStorageType storageType)
TripleFormat tripleFormatFromString(std::string_view format)

◆ SPARQLService() [3/4]

knowrob::SPARQLService::SPARQLService ( const URI uri,
semweb::TripleFormat  format 
)
Parameters
urithe URI of the SPARQL endpoint.
formatthe format of the triples in the endpoint.

◆ SPARQLService() [4/4]

knowrob::SPARQLService::SPARQLService ( const URI uri,
std::string_view  format 
)

s

Parameters
urithe URI of the SPARQL endpoint.
formatthe format of the triples in the endpoint.

Member Function Documentation

◆ load() [1/2]

bool SPARQLService::load ( const TripleHandler callback)
overridevirtual

Load triples from the SPARQL endpoint.

Parameters
callbackthe callback to handle the triples.
Returns
true if the triples were loaded successfully.

Implements knowrob::OntologySource.

Definition at line 31 of file SPARQLService.cpp.

31  {
32  // iterate over all triples in the SPARQL endpoint
33  model_.batch(callback);
34  return true;
35 }
void batch(const TripleHandler &callback) const override

◆ load() [2/2]

bool knowrob::SPARQLService::load ( const TripleHandler callback)
overridevirtual

Load triples from the SPARQL endpoint.

Parameters
callbackthe callback to handle the triples.
Returns
true if the triples were loaded successfully.

Implements knowrob::OntologySource.

Member Data Documentation

◆ model_

RedlandModel knowrob::SPARQLService::model_
protected

Definition at line 37 of file SPARQLService.h.


The documentation for this class was generated from the following files: