Dataquay 0.8
TransactionalStore.h
Go to the documentation of this file.
1/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3/*
4 Dataquay
5
6 A C++/Qt library for simple RDF datastore management.
7 Copyright 2009-2012 Chris Cannam.
8
9 Permission is hereby granted, free of charge, to any person
10 obtaining a copy of this software and associated documentation
11 files (the "Software"), to deal in the Software without
12 restriction, including without limitation the rights to use, copy,
13 modify, merge, publish, distribute, sublicense, and/or sell copies
14 of the Software, and to permit persons to whom the Software is
15 furnished to do so, subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be
18 included in all copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
24 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
25 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
28 Except as contained in this notice, the name of Chris Cannam
29 shall not be used in advertising or otherwise to promote the sale,
30 use or other dealings in this Software without prior written
31 authorization.
32*/
33
34#ifndef DATAQUAY_TRANSACTIONAL_STORE_H
35#define DATAQUAY_TRANSACTIONAL_STORE_H
36
37#include "Transaction.h"
38
39namespace Dataquay
40{
41
73class TransactionalStore : public QObject, public Store
74{
75 Q_OBJECT
76
77public:
96
107
114
122
123 // Store interface
124 bool add(Triple t);
125 bool remove(Triple t);
126 void change(ChangeSet changes);
127 void revert(ChangeSet changes);
128 bool contains(Triple t) const;
130 ResultSet query(QString sparql) const;
133 Node queryOnce(QString sparql, QString bindingName) const;
134 Uri getUniqueUri(QString prefix) const;
136 Uri expand(QString uri) const;
137 void save(QString filename) const;
138 void import(QUrl url, ImportDuplicatesMode idm, QString format = "");
139 void importString(QString encodedRdf, Uri baseUri,
140 ImportDuplicatesMode idm, QString format = "");
142
143signals:
152
161
162private:
163 class D;
164 D *m_d;
165
166 class TSTransaction : public Transaction
167 {
168 public:
169 // Store interface
170 bool add(Triple t);
171 bool remove(Triple t);
172 void change(ChangeSet changes);
173 void revert(ChangeSet changes);
174 bool contains(Triple t) const;
175 Triples match(Triple t) const;
176 ResultSet query(QString sparql) const;
177 Node complete(Triple t) const;
178 Triple matchOnce(Triple t) const;
179 Node queryOnce(QString sparql, QString bindingName) const;
180 Uri getUniqueUri(QString prefix) const;
181 Node addBlankNode();
182 Uri expand(QString uri) const;
183 void save(QString filename) const;
184 void import(QUrl url, ImportDuplicatesMode idm, QString format = "");
185 void importString(QString encodedRdf, Uri baseUri,
186 ImportDuplicatesMode idm, QString format = "");
187 Features getSupportedFeatures() const;
188
189 // Transaction interface
190 void commit();
191 void rollback();
192 ChangeSet getCommittedChanges() const;
193 ChangeSet getChanges() const;
194
195 TSTransaction(TransactionalStore::D *td);
196 virtual ~TSTransaction();
197
198 private:
199 TSTransaction(const TSTransaction &);
200 TSTransaction &operator=(const TSTransaction &);
201 class D;
202 D *m_d;
203 };
204};
205
206}
207
208#endif
Node represents a single RDF node, with conversions to and from variant types.
Definition Node.h:65
Store is an abstract interface for Dataquay RDF data stores.
Definition Store.h:72
QSet< Feature > Features
Definition Store.h:290
ImportDuplicatesMode
ImportDuplicatesMode determines the outcome when an import operation encounters a triple in the impor...
Definition Store.h:222
Transaction is an abstract interface for classes that read and write an RDF Store within the context ...
Definition Transaction.h:53
TransactionalStore is an RDF data store implementing the Store interface, providing transaction suppo...
void change(ChangeSet changes)
Atomically apply the sequence of add/remove changes described in the given ChangeSet.
bool remove(Triple t)
Remove a triple from the store.
void importString(QString encodedRdf, Uri baseUri, ImportDuplicatesMode idm, QString format="")
Import the RDF document encoded in the given string into the current store (in addition to its existi...
Node addBlankNode()
Create and return a new blank node.
~TransactionalStore()
Delete the TransactionalStore.
bool contains(Triple t) const
Return true if the store contains the given triple, false otherwise.
void transactionCommitted(const ChangeSet &cs)
Emitted after a transaction has been committed.
ResultSet query(QString sparql) const
Run a SPARQL query against the store and return its results.
Node complete(Triple t) const
Given a triple in which any two nodes are specified and the other is a wildcard node of type Nothing,...
void transactionCommitted()
Emitted after a transaction has been committed.
void revert(ChangeSet changes)
Atomically apply the sequence of add/remove changes described in the given ChangeSet,...
DirectWriteBehaviour
DirectWriteBehaviour controls how TransactionalStore responds when called directly (not through a Tra...
Triples match(Triple t) const
Return all triples matching the given wildcard triple.
TransactionalStore(Store *store, DirectWriteBehaviour dwb=NoAutoTransaction)
Create a TransactionalStore operating on the given (presumably non-transactional) data store.
bool add(Triple t)
Add a triple to the store.
Uri getUniqueUri(QString prefix) const
Get a new URI, starting with the given prefix (e.g.
Transaction * startTransaction()
Start a transaction and obtain a Transaction through which to carry out its operations.
Features getSupportedFeatures() const
Retrieve the set of optional features supported by this Store implementation.
Triple matchOnce(Triple t) const
Return a triple from the store that matches the given wildcard triple, or the empty triple if none ma...
void save(QString filename) const
Export the store to an RDF/TTL file with the given filename.
Node queryOnce(QString sparql, QString bindingName) const
Run a SPARQL query against the store and return the node of the first result for the given query bind...
Uri expand(QString uri) const
Expand the given URI (which may use local namespaces) and prefix-expand it, returning the result as a...
Triple represents an RDF statement made up of three Node objects.
Definition Triple.h:48
A list of RDF triples.
Definition Triple.h:111
Uri represents a single URI.
Definition Uri.h:77
QList< Change > ChangeSet
A sequence of add/remove operations such as may be enacted by a transaction.
Definition Store.h:63
QList< Dictionary > ResultSet
A list of Dictionary types, used to contain a sequence of query results.
Definition Store.h:52