00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 00002 00003 /* 00004 Dataquay 00005 00006 A C++/Qt library for simple RDF datastore management with Redland. 00007 Copyright 2009 Chris Cannam. 00008 00009 Permission is hereby granted, free of charge, to any person 00010 obtaining a copy of this software and associated documentation 00011 files (the "Software"), to deal in the Software without 00012 restriction, including without limitation the rights to use, copy, 00013 modify, merge, publish, distribute, sublicense, and/or sell copies 00014 of the Software, and to permit persons to whom the Software is 00015 furnished to do so, subject to the following conditions: 00016 00017 The above copyright notice and this permission notice shall be 00018 included in all copies or substantial portions of the Software. 00019 00020 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00021 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00022 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00023 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR 00024 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 00025 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 00026 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00027 00028 Except as contained in this notice, the name of Chris Cannam 00029 shall not be used in advertising or otherwise to promote the sale, 00030 use or other dealings in this Software without prior written 00031 authorization. 00032 */ 00033 00034 #ifndef _DATAQUAY_TRANSACTIONAL_STORE_H_ 00035 #define _DATAQUAY_TRANSACTIONAL_STORE_H_ 00036 00037 #include "Transaction.h" 00038 00039 namespace Dataquay 00040 { 00041 00070 class TransactionalStore : public QObject, public Store 00071 { 00072 Q_OBJECT 00073 00074 public: 00089 enum DirectWriteBehaviour { 00090 NoAutoTransaction, 00091 AutoTransaction 00092 }; 00093 00103 TransactionalStore(Store *store, DirectWriteBehaviour dwb = NoAutoTransaction); 00104 00105 ~TransactionalStore(); 00106 00113 Transaction *startTransaction(); 00114 00115 // Store interface 00116 bool add(Triple t); 00117 bool remove(Triple t); 00118 void change(ChangeSet changes); 00119 void revert(ChangeSet changes); 00120 bool contains(Triple t) const; 00121 Triples match(Triple t) const; 00122 ResultSet query(QString sparql) const; 00123 Triple matchFirst(Triple t) const; 00124 Node queryFirst(QString sparql, QString bindingName) const; 00125 QUrl getUniqueUri(QString prefix) const; 00126 QUrl expand(QString uri) const; 00127 00128 signals: 00129 void transactionCommitted(); 00130 00131 private: 00132 class D; 00133 D *m_d; 00134 00135 class TSTransaction : public Transaction 00136 { 00137 public: 00138 // Store interface 00139 bool add(Triple t); 00140 bool remove(Triple t); 00141 void change(ChangeSet changes); 00142 void revert(ChangeSet changes); 00143 bool contains(Triple t) const; 00144 Triples match(Triple t) const; 00145 ResultSet query(QString sparql) const; 00146 Triple matchFirst(Triple t) const; 00147 Node queryFirst(QString sparql, QString bindingName) const; 00148 QUrl getUniqueUri(QString prefix) const; 00149 QUrl expand(QString uri) const; 00150 00151 // Transaction interface 00152 ChangeSet getChanges() const; 00153 void rollback(); 00154 00155 TSTransaction(TransactionalStore::D *td); 00156 virtual ~TSTransaction(); 00157 00158 private: 00159 class D; 00160 D *m_d; 00161 }; 00162 }; 00163 00164 } 00165 00166 #endif
1.5.7.1