knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
StorageInterface.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_STORAGE_INTERFACE_H
7 #define KNOWROB_STORAGE_INTERFACE_H
8 
9 #include "knowrob/storage/QueryableStorage.h"
10 #include "StorageManager.h"
11 #include "Transaction.h"
12 
13 namespace knowrob {
18  class StorageInterface {
19  public:
24  Insert, Remove
25  };
31  };
32 
33  explicit StorageInterface(const std::shared_ptr<StorageManager> &backendManager)
35 
39  auto &vocabulary() const { return backendManager_->vocabulary(); }
40 
44  auto &backendManager() const { return backendManager_; }
45 
54  std::shared_ptr<transaction::Transaction> createTransaction(
55  const QueryableBackendPtr &queryable,
58  const std::vector<std::shared_ptr<NamedBackend>> &backends = {});
59 
65  bool removeAllWithOrigin(std::string_view origin);
66 
74  bool mergeInsert(const QueryableBackendPtr &backend, const Triple &triple);
75 
82  bool contains(const QueryableBackendPtr &backend, const Triple &triple) const;
83 
89  static void foreach(const QueryableBackendPtr &backend, const TripleVisitor &visitor);
90 
96  static void batch(const QueryableBackendPtr &backend, const TripleHandler &callback);
97 
105  void match(const QueryableBackendPtr &backend, const TriplePattern &query,
106  const TripleVisitor &visitor) const;
107 
115  void query(const QueryableBackendPtr &backend, const GraphQueryPtr &q, const BindingsHandler &callback) const;
116 
125 
126  protected:
127  std::shared_ptr<StorageManager> backendManager_;
128 
130  const TokenBufferPtr &resultStream) const;
131  };
132 
133 } // knowrob
134 
135 #endif //KNOWROB_STORAGE_INTERFACE_H
static void batch(const QueryableBackendPtr &backend, const TripleHandler &callback)
TokenBufferPtr getAnswerCursor(const QueryableBackendPtr &backend, const GraphPathQueryPtr &query)
void query(const QueryableBackendPtr &backend, const GraphQueryPtr &q, const BindingsHandler &callback) const
std::shared_ptr< transaction::Transaction > createTransaction(const QueryableBackendPtr &queryable, TransactionType type, BackendSelection mode=Excluding, const std::vector< std::shared_ptr< NamedBackend >> &backends={})
StorageInterface(const std::shared_ptr< StorageManager > &backendManager)
bool removeAllWithOrigin(std::string_view origin)
void match(const QueryableBackendPtr &backend, const TriplePattern &query, const TripleVisitor &visitor) const
std::shared_ptr< StorageManager > backendManager_
void pushIntoCursor(const QueryableBackendPtr &backend, const GraphPathQueryPtr &query, const TokenBufferPtr &resultStream) const
void query(const QueryableBackendPtr &backend, const GraphQueryPtr &q, const BindingsHandler &callback) const
bool mergeInsert(const QueryableBackendPtr &backend, const Triple &triple)
bool contains(const QueryableBackendPtr &backend, const Triple &triple) const
const IRIAtomPtr type
Definition: rdf.h:15
std::function< void(const TriplePtr &)> TripleVisitor
std::shared_ptr< TokenBuffer > TokenBufferPtr
Definition: TokenBuffer.h:43
std::function< void(const BindingsPtr &)> BindingsHandler
Definition: Bindings.h:152
std::function< void(const TripleContainerPtr &)> TripleHandler
std::shared_ptr< GraphQuery > GraphQueryPtr
Definition: GraphQuery.h:65
std::shared_ptr< QueryableStorage > QueryableBackendPtr
std::shared_ptr< GraphPathQuery > GraphPathQueryPtr