knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
knowrob::Storage Class Referenceabstract

#include <Storage.h>

Inheritance diagram for knowrob::Storage:
Collaboration diagram for knowrob::Storage:

Public Member Functions

 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
 
virtual bool insertOne (const Triple &triple)=0
 
virtual bool insertAll (const TripleContainerPtr &triples)=0
 
virtual bool removeOne (const Triple &triple)=0
 
virtual bool removeAll (const TripleContainerPtr &triples)=0
 
virtual bool removeAllWithOrigin (std::string_view origin)=0
 
virtual bool initializeBackend (const PropertyTree &config)=0
 
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
 
virtual bool insertOne (const Triple &triple)=0
 
virtual bool insertAll (const TripleContainerPtr &triples)=0
 
virtual bool removeOne (const Triple &triple)=0
 
virtual bool removeAll (const TripleContainerPtr &triples)=0
 
virtual bool removeAllWithOrigin (std::string_view origin)=0
 
virtual bool initializeBackend (const PropertyTree &config)=0
 
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
 

Protected Member Functions

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

std::map< std::string, std::string > originVersions_
 
std::shared_ptr< Vocabularyvocabulary_
 
StorageFeatures features_
 
PluginLanguage storageLanguage_
 
- Protected Attributes inherited from knowrob::DataSourceHandler
std::map< std::string, DataSourceLoaderdataSourceHandler_
 

Friends

class StorageManager
 

Detailed Description

A data backend is a component that stores extensional data. Note that data backends do not do reification internally – reification is only handled via BackendInterface. Meaning that data backends without support for triple context can just ignore any contextual parameters handed to them.

Definition at line 59 of file Storage.h.

Constructor & Destructor Documentation

◆ Storage() [1/2]

knowrob::Storage::Storage ( StorageFeatures  features = StorageFeature::NothingSpecial)
inlineexplicit

Definition at line 61 of file Storage.h.

PluginLanguage storageLanguage_
Definition: Storage.h:145
StorageFeatures features_
Definition: Storage.h:144

◆ ~Storage() [1/2]

virtual knowrob::Storage::~Storage ( )
virtualdefault

◆ Storage() [2/2]

knowrob::Storage::Storage ( StorageFeatures  features = StorageFeature::NothingSpecial)
inlineexplicit

Definition at line 61 of file Storage.h.

◆ ~Storage() [2/2]

virtual knowrob::Storage::~Storage ( )
virtualdefault

Member Function Documentation

◆ enableFeature() [1/2]

void knowrob::Storage::enableFeature ( StorageFeature  feature)
inlineprotected

Definition at line 147 of file Storage.h.

147 { features_ = features_ | feature; }

◆ enableFeature() [2/2]

void knowrob::Storage::enableFeature ( StorageFeature  feature)
inlineprotected

Definition at line 147 of file Storage.h.

147 { features_ = features_ | feature; }

◆ getVersionOfOrigin() [1/2]

std::optional<std::string> knowrob::Storage::getVersionOfOrigin ( std::string_view  origin) const
inline

Definition at line 125 of file Storage.h.

125  {
126  auto it = originVersions_.find(origin.data());
127  if (it != originVersions_.end()) {
128  return it->second;
129  }
130  return std::nullopt;
131  }
std::map< std::string, std::string > originVersions_
Definition: Storage.h:142

◆ getVersionOfOrigin() [2/2]

std::optional<std::string> knowrob::Storage::getVersionOfOrigin ( std::string_view  origin) const
inline

Definition at line 125 of file Storage.h.

125  {
126  auto it = originVersions_.find(origin.data());
127  if (it != originVersions_.end()) {
128  return it->second;
129  }
130  return std::nullopt;
131  }

◆ initializeBackend() [1/2]

virtual bool knowrob::Storage::initializeBackend ( const PropertyTree config)
pure virtual

Initialize this backend from a property tree.

Parameters
configa property tree.
Returns
true on success

Implemented in knowrob::RedlandModel, knowrob::MongoKnowledgeGraph, knowrob::RedlandModel, knowrob::MongoKnowledgeGraph, knowrob::PrologBackend, and knowrob::PrologBackend.

◆ initializeBackend() [2/2]

virtual bool knowrob::Storage::initializeBackend ( const PropertyTree config)
pure virtual

Initialize this backend from a property tree.

Parameters
configa property tree.
Returns
true on success

Implemented in knowrob::RedlandModel, knowrob::MongoKnowledgeGraph, knowrob::RedlandModel, knowrob::MongoKnowledgeGraph, knowrob::PrologBackend, and knowrob::PrologBackend.

◆ insertAll() [1/2]

virtual bool knowrob::Storage::insertAll ( const TripleContainerPtr triples)
pure virtual

Add assertions to this backend.

Parameters
triplesa set of triples.
Returns
true on success

Implemented in knowrob::RedlandModel, knowrob::MongoKnowledgeGraph, knowrob::PrologBackend, knowrob::RedlandModel, knowrob::MongoKnowledgeGraph, and knowrob::PrologBackend.

◆ insertAll() [2/2]

virtual bool knowrob::Storage::insertAll ( const TripleContainerPtr triples)
pure virtual

Add assertions to this backend.

Parameters
triplesa set of triples.
Returns
true on success

Implemented in knowrob::RedlandModel, knowrob::MongoKnowledgeGraph, knowrob::PrologBackend, knowrob::RedlandModel, knowrob::MongoKnowledgeGraph, and knowrob::PrologBackend.

◆ insertOne() [1/2]

virtual bool knowrob::Storage::insertOne ( const Triple triple)
pure virtual

Add an assertion to this backend.

Parameters
triplea triple.
Returns
true on success

Implemented in knowrob::RedlandModel, knowrob::MongoKnowledgeGraph, knowrob::PrologBackend, knowrob::RedlandModel, knowrob::MongoKnowledgeGraph, and knowrob::PrologBackend.

◆ insertOne() [2/2]

virtual bool knowrob::Storage::insertOne ( const Triple triple)
pure virtual

Add an assertion to this backend.

Parameters
triplea triple.
Returns
true on success

Implemented in knowrob::RedlandModel, knowrob::MongoKnowledgeGraph, knowrob::PrologBackend, knowrob::RedlandModel, knowrob::MongoKnowledgeGraph, and knowrob::PrologBackend.

◆ removeAll() [1/2]

virtual bool knowrob::Storage::removeAll ( const TripleContainerPtr triples)
pure virtual

Delete all matching statements from this backend.

Parameters
triplesa set of triples.

Implemented in knowrob::RedlandModel, knowrob::MongoKnowledgeGraph, knowrob::PrologBackend, knowrob::RedlandModel, knowrob::MongoKnowledgeGraph, and knowrob::PrologBackend.

◆ removeAll() [2/2]

virtual bool knowrob::Storage::removeAll ( const TripleContainerPtr triples)
pure virtual

Delete all matching statements from this backend.

Parameters
triplesa set of triples.

Implemented in knowrob::RedlandModel, knowrob::MongoKnowledgeGraph, knowrob::PrologBackend, knowrob::RedlandModel, knowrob::MongoKnowledgeGraph, and knowrob::PrologBackend.

◆ removeAllWithOrigin() [1/2]

virtual bool knowrob::Storage::removeAllWithOrigin ( std::string_view  origin)
pure virtual

Delete all statements with a given origin from this backend.

Parameters
originthe origin of the statements to be deleted.

Implemented in knowrob::RedlandModel, knowrob::MongoKnowledgeGraph, knowrob::PrologBackend, knowrob::RedlandModel, knowrob::MongoKnowledgeGraph, and knowrob::PrologBackend.

◆ removeAllWithOrigin() [2/2]

virtual bool knowrob::Storage::removeAllWithOrigin ( std::string_view  origin)
pure virtual

Delete all statements with a given origin from this backend.

Parameters
originthe origin of the statements to be deleted.

Implemented in knowrob::RedlandModel, knowrob::MongoKnowledgeGraph, knowrob::PrologBackend, knowrob::RedlandModel, knowrob::MongoKnowledgeGraph, and knowrob::PrologBackend.

◆ removeOne() [1/2]

virtual bool knowrob::Storage::removeOne ( const Triple triple)
pure virtual

Delete the first matching statement from this backend.

Parameters
triplea triple.

Implemented in knowrob::RedlandModel, knowrob::MongoKnowledgeGraph, knowrob::PrologBackend, knowrob::RedlandModel, knowrob::MongoKnowledgeGraph, and knowrob::PrologBackend.

◆ removeOne() [2/2]

virtual bool knowrob::Storage::removeOne ( const Triple triple)
pure virtual

Delete the first matching statement from this backend.

Parameters
triplea triple.

Implemented in knowrob::RedlandModel, knowrob::MongoKnowledgeGraph, knowrob::PrologBackend, knowrob::RedlandModel, knowrob::MongoKnowledgeGraph, and knowrob::PrologBackend.

◆ setStorageLanguage() [1/2]

void knowrob::Storage::setStorageLanguage ( PluginLanguage  storageLanguage)
inlineprotected

Definition at line 149 of file Storage.h.

PluginLanguage storageLanguage() const
Definition: Storage.h:68

◆ setStorageLanguage() [2/2]

void knowrob::Storage::setStorageLanguage ( PluginLanguage  storageLanguage)
inlineprotected

Definition at line 149 of file Storage.h.

◆ setVersionOfOrigin() [1/2]

void knowrob::Storage::setVersionOfOrigin ( std::string_view  origin,
std::optional< std::string_view >  version 
)
inline

Definition at line 133 of file Storage.h.

133  {
134  if (version) {
135  originVersions_[origin.data()] = version.value().data();
136  } else {
137  originVersions_.erase(origin.data());
138  }
139  }

◆ setVersionOfOrigin() [2/2]

void knowrob::Storage::setVersionOfOrigin ( std::string_view  origin,
std::optional< std::string_view >  version 
)
inline

Definition at line 133 of file Storage.h.

133  {
134  if (version) {
135  originVersions_[origin.data()] = version.value().data();
136  } else {
137  originVersions_.erase(origin.data());
138  }
139  }

◆ setVocabulary() [1/2]

void knowrob::Storage::setVocabulary ( std::shared_ptr< Vocabulary vocabulary)
inline

Set the vocabulary of this backend.

Parameters
vocabularya vocabulary.

Definition at line 79 of file Storage.h.

79 { vocabulary_ = std::move(vocabulary); }
const auto & vocabulary() const
Definition: Storage.h:73
std::shared_ptr< Vocabulary > vocabulary_
Definition: Storage.h:143

◆ setVocabulary() [2/2]

void knowrob::Storage::setVocabulary ( std::shared_ptr< Vocabulary vocabulary)
inline

Set the vocabulary of this backend.

Parameters
vocabularya vocabulary.

Definition at line 79 of file Storage.h.

79 { vocabulary_ = std::move(vocabulary); }

◆ storageLanguage() [1/2]

PluginLanguage knowrob::Storage::storageLanguage ( ) const
inline
Returns
the language of the storage plugin.

Definition at line 68 of file Storage.h.

68 { return storageLanguage_; }

◆ storageLanguage() [2/2]

PluginLanguage knowrob::Storage::storageLanguage ( ) const
inline
Returns
the language of the storage plugin.

Definition at line 68 of file Storage.h.

68 { return storageLanguage_; }

◆ supports() [1/2]

bool knowrob::Storage::supports ( StorageFeature  feature) const
inline
Returns
true if the backend supports re-assignment of variables within query pipelines.

Definition at line 84 of file Storage.h.

84 { return features_ & feature; }

◆ supports() [2/2]

bool knowrob::Storage::supports ( StorageFeature  feature) const
inline
Returns
true if the backend supports re-assignment of variables within query pipelines.

Definition at line 84 of file Storage.h.

84 { return features_ & feature; }

◆ vocabulary() [1/2]

const auto& knowrob::Storage::vocabulary ( ) const
inline
Returns
the vocabulary of this backend.

Definition at line 73 of file Storage.h.

73 { return vocabulary_; }

◆ vocabulary() [2/2]

const auto& knowrob::Storage::vocabulary ( ) const
inline
Returns
the vocabulary of this backend.

Definition at line 73 of file Storage.h.

73 { return vocabulary_; }

Friends And Related Function Documentation

◆ StorageManager

Definition at line 151 of file Storage.h.

Member Data Documentation

◆ features_

StorageFeatures knowrob::Storage::features_
protected

Definition at line 144 of file Storage.h.

◆ originVersions_

std::map< std::string, std::string > knowrob::Storage::originVersions_
protected

Definition at line 142 of file Storage.h.

◆ storageLanguage_

PluginLanguage knowrob::Storage::storageLanguage_
protected

Definition at line 145 of file Storage.h.

◆ vocabulary_

std::shared_ptr< Vocabulary > knowrob::Storage::vocabulary_
protected

Definition at line 143 of file Storage.h.


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