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

#include <Transaction.h>

Inheritance diagram for knowrob::transaction::Remove:
Collaboration diagram for knowrob::transaction::Remove:

Public Member Functions

 Remove (const std::shared_ptr< QueryableStorage > &queryable, const std::shared_ptr< Vocabulary > &vocabulary)
 
 Remove (const std::shared_ptr< QueryableStorage > &queryable, const std::shared_ptr< Vocabulary > &vocabulary)
 
- Public Member Functions inherited from knowrob::transaction::Transaction
 Transaction (const std::shared_ptr< QueryableStorage > &queryable, const std::shared_ptr< Vocabulary > &vocabulary, bool isRemoval)
 
virtual ~Transaction ()=default
 
void addBackend (const std::shared_ptr< NamedBackend > &backend)
 
bool commit (const Triple &triple)
 
bool commit (const Triple &triple, const IRIAtomPtr &reifiedName)
 
bool commit (const TripleContainerPtr &triples)
 
bool commit (const TripleContainerPtr &triples, const ReifiedNames &reifiedNames)
 
 Transaction (const std::shared_ptr< QueryableStorage > &queryable, const std::shared_ptr< Vocabulary > &vocabulary, bool isRemoval)
 
virtual ~Transaction ()=default
 
void addBackend (const std::shared_ptr< NamedBackend > &backend)
 
bool commit (const Triple &triple)
 
bool commit (const Triple &triple, const IRIAtomPtr &reifiedName)
 
bool commit (const TripleContainerPtr &triples)
 
bool commit (const TripleContainerPtr &triples, const ReifiedNames &reifiedNames)
 

Protected Member Functions

bool doCommit (const Triple &triple, const StoragePtr &backend) override
 
bool doCommit (const TripleContainerPtr &triples, const StoragePtr &backend) override
 
void updateVocabulary (const Triple &triple) override
 
bool doCommit (const Triple &triple, const StoragePtr &backend) override
 
bool doCommit (const TripleContainerPtr &triples, const StoragePtr &backend) override
 
void updateVocabulary (const Triple &triple) override
 
- Protected Member Functions inherited from knowrob::transaction::Transaction
bool commitProtected (const TripleContainerPtr &triple, const StoragePtr &backend)
 
IRIAtomPtr queryReifiedName (const Triple &triple)
 
bool commitProtected (const TripleContainerPtr &triple, const StoragePtr &backend)
 
IRIAtomPtr queryReifiedName (const Triple &triple)
 

Additional Inherited Members

- Static Protected Member Functions inherited from knowrob::transaction::Transaction
static std::shared_ptr< ThreadPool::RunnercreateTripleWorker (const TripleContainerPtr &triples, const std::function< void(const TriplePtr &)> &fn)
 
static std::shared_ptr< ThreadPool::RunnercreateTripleWorker (const TripleContainerPtr &triples, const std::function< void(const TriplePtr &)> &fn)
 
- Protected Attributes inherited from knowrob::transaction::Transaction
std::shared_ptr< Vocabularyvocabulary_
 
std::shared_ptr< QueryableStoragequeryable_
 
std::vector< std::shared_ptr< NamedBackend > > backends_
 
bool isRemoval_
 

Detailed Description

A data removal transaction.

Definition at line 110 of file Transaction.h.

Constructor & Destructor Documentation

◆ Remove() [1/2]

knowrob::transaction::Remove::Remove ( const std::shared_ptr< QueryableStorage > &  queryable,
const std::shared_ptr< Vocabulary > &  vocabulary 
)
inline

Definition at line 112 of file Transaction.h.

113  : Transaction(queryable, vocabulary, true) {}
Transaction(const std::shared_ptr< QueryableStorage > &queryable, const std::shared_ptr< Vocabulary > &vocabulary, bool isRemoval)
Definition: Transaction.h:25

◆ Remove() [2/2]

knowrob::transaction::Remove::Remove ( const std::shared_ptr< QueryableStorage > &  queryable,
const std::shared_ptr< Vocabulary > &  vocabulary 
)
inline

Definition at line 112 of file Transaction.h.

113  : Transaction(queryable, vocabulary, true) {}

Member Function Documentation

◆ doCommit() [1/4]

bool Remove::doCommit ( const Triple triple,
const StoragePtr backend 
)
overrideprotectedvirtual

Implements knowrob::transaction::Transaction.

Definition at line 189 of file Transaction.cpp.

189  {
190  return backend->removeOne(triple);
191 }

◆ doCommit() [2/4]

bool knowrob::transaction::Remove::doCommit ( const Triple triple,
const StoragePtr backend 
)
overrideprotectedvirtual

◆ doCommit() [3/4]

bool Remove::doCommit ( const TripleContainerPtr triples,
const StoragePtr backend 
)
overrideprotectedvirtual

Implements knowrob::transaction::Transaction.

Definition at line 197 of file Transaction.cpp.

197  {
198  return backend->removeAll(triples);
199 }

◆ doCommit() [4/4]

bool knowrob::transaction::Remove::doCommit ( const TripleContainerPtr triples,
const StoragePtr backend 
)
overrideprotectedvirtual

◆ updateVocabulary() [1/2]

void Remove::updateVocabulary ( const Triple triple)
overrideprotectedvirtual

Implements knowrob::transaction::Transaction.

Definition at line 252 of file Transaction.cpp.

252  {
253  // remove subclass and subproperty relations from the vocabulary.
254  if (isSubClassOfIRI(triple.predicate())) {
255  auto sub = vocabulary_->defineClass(triple.subject());
256  auto sup = vocabulary_->defineClass(triple.valueAsString());
257  sub->removeDirectParent(sup, triple.graph());
258  } else if (isSubPropertyOfIRI(triple.predicate())) {
259  auto sub = vocabulary_->defineProperty(triple.subject());
260  auto sup = vocabulary_->defineProperty(triple.valueAsString());
261  sub->removeDirectParent(sup, triple.graph());
262  }
263 }
virtual std::string_view valueAsString() const =0
virtual std::optional< std::string_view > graph() const =0
virtual std::string_view subject() const =0
virtual std::string_view predicate() const =0
std::shared_ptr< Vocabulary > vocabulary_
Definition: Transaction.h:71
bool isSubClassOfIRI(std::string_view iri)
Definition: rdfs.cpp:9
bool isSubPropertyOfIRI(std::string_view iri)
Definition: rdfs.cpp:12

◆ updateVocabulary() [2/2]

void knowrob::transaction::Remove::updateVocabulary ( const Triple triple)
overrideprotectedvirtual

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