Soprano
2.7.4
|
00001 /* 00002 * This file is part of Soprano Project. 00003 * 00004 * Copyright (C) 2006 Daniele Galdi <daniele.galdi@gmail.com> 00005 * Copyright (C) 2007 Sebastian Trueg <trueg@kde.org> 00006 * 00007 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Library General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2 of the License, or (at your option) any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Library General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Library General Public License 00018 * along with this library; see the file COPYING.LIB. If not, write to 00019 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00020 * Boston, MA 02110-1301, USA. 00021 */ 00022 00023 #ifndef SOPRANO_MODEL_H 00024 #define SOPRANO_MODEL_H 00025 00026 #include <QtCore/QObject> 00027 #include <QtCore/QList> 00028 00029 #include "soprano_export.h" 00030 #include "error.h" 00031 #include "sopranotypes.h" 00032 #include "node.h" 00033 00034 class QTextStream; 00035 00036 namespace Soprano 00037 { 00038 class QueryLegacy; 00039 class QueryResultIterator; 00040 class Statement; 00041 class StatementIterator; 00042 class NodeIterator; 00043 namespace Query { 00044 class Query; 00045 } 00046 00094 class SOPRANO_EXPORT Model : public QObject, public Error::ErrorCache 00095 { 00096 Q_OBJECT 00097 00098 public: 00099 virtual ~Model(); 00100 00102 00107 virtual Error::ErrorCode addStatement( const Statement &statement ) = 0; 00108 00112 Error::ErrorCode addStatement( const Node& subject, const Node& predicate, const Node& object, const Node& context = Node() ); 00113 00117 Error::ErrorCode addStatements( const QList<Statement> &statements ); 00119 00121 00129 virtual Error::ErrorCode removeStatement( const Statement &statement ) = 0; 00130 00134 Error::ErrorCode removeStatement( const Node& subject, const Node& predicate, const Node& object, const Node& context = Node() ); 00135 00143 virtual Error::ErrorCode removeAllStatements( const Statement &statement ) = 0; 00144 00153 Error::ErrorCode removeAllStatements( const Node& subject, const Node& predicate, const Node& object, const Node& context = Node() ); 00154 00158 Error::ErrorCode removeStatements( const QList<Statement> &statements ); 00159 00163 Error::ErrorCode removeContext( const Node& ); 00164 00168 Error::ErrorCode removeAllStatements(); 00170 00171 00173 00181 virtual StatementIterator listStatements( const Statement &partial ) const = 0; 00182 00193 StatementIterator listStatements( const Node& subject, const Node& predicate, const Node& object, const Node& context = Node() ) const; 00194 00200 StatementIterator listStatements() const; 00201 00207 StatementIterator listStatementsInContext( const Node &context ) const; 00208 00214 virtual NodeIterator listContexts() const = 0; 00215 00228 // virtual QueryResultIterator executeQuery( const Query::Query& query ) const = 0; 00229 00248 virtual QueryResultIterator executeQuery( const QString& query, Query::QueryLanguage language, const QString& userQueryLanguage = QString() ) const = 0; 00250 00251 00253 00262 virtual bool containsAnyStatement( const Statement &statement ) const = 0; 00263 00272 bool containsAnyStatement( const Node& subject, const Node& predicate, const Node& object, const Node& context = Node() ) const; 00273 00284 virtual bool containsStatement( const Statement &statement ) const = 0; 00285 00289 bool containsStatement( const Node& subject, const Node& predicate, const Node& object, const Node& context = Node() ) const; 00290 00294 bool containsContext( const Node &context ) const; 00295 00299 virtual bool isEmpty() const = 0; 00300 00305 virtual int statementCount() const = 0; 00307 00308 00310 00315 virtual Error::ErrorCode write( QTextStream &os ) const; 00317 00318 00320 00325 virtual Node createBlankNode() = 0; 00327 00328 Q_SIGNALS: 00334 void statementsAdded(); 00335 00341 void statementsRemoved(); 00342 00347 void statementAdded( const Soprano::Statement& statement ); 00348 00358 void statementRemoved( const Soprano::Statement& statement ); 00359 00360 protected: 00361 Model(); 00362 00363 private: 00367 Model( const Model& ); 00368 Model& operator=( const Model& ); 00369 00370 class Private; 00371 Private* const d; 00372 }; 00373 } 00374 00375 #endif