Soprano  2.8.0
model.h
Go to the documentation of this file.
1 /*
2  * This file is part of Soprano Project.
3  *
4  * Copyright (C) 2006 Daniele Galdi <daniele.galdi@gmail.com>
5  * Copyright (C) 2007 Sebastian Trueg <trueg@kde.org>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public License
18  * along with this library; see the file COPYING.LIB. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 #ifndef SOPRANO_MODEL_H
24 #define SOPRANO_MODEL_H
25 
26 #include <QtCore/QObject>
27 #include <QtCore/QList>
28 
29 #include "soprano_export.h"
30 #include "error.h"
31 #include "sopranotypes.h"
32 #include "node.h"
33 
34 class QTextStream;
35 
36 namespace Soprano
37 {
38  class QueryLegacy;
39  class QueryResultIterator;
40  class Statement;
41  class StatementIterator;
42  class NodeIterator;
43  namespace Query {
44  class Query;
45  }
46 
95  {
96  Q_OBJECT
97 
98  public:
99  virtual ~Model();
100 
102 
107  virtual Error::ErrorCode addStatement( const Statement &statement ) = 0;
108 
112  Error::ErrorCode addStatement( const Node& subject, const Node& predicate, const Node& object, const Node& context = Node() );
113 
117  Error::ErrorCode addStatements( const QList<Statement> &statements );
119 
121 
129  virtual Error::ErrorCode removeStatement( const Statement &statement ) = 0;
130 
134  Error::ErrorCode removeStatement( const Node& subject, const Node& predicate, const Node& object, const Node& context = Node() );
135 
143  virtual Error::ErrorCode removeAllStatements( const Statement &statement ) = 0;
144 
153  Error::ErrorCode removeAllStatements( const Node& subject, const Node& predicate, const Node& object, const Node& context = Node() );
154 
158  Error::ErrorCode removeStatements( const QList<Statement> &statements );
159 
163  Error::ErrorCode removeContext( const Node& );
164 
168  Error::ErrorCode removeAllStatements();
170 
171 
173 
181  virtual StatementIterator listStatements( const Statement &partial ) const = 0;
182 
193  StatementIterator listStatements( const Node& subject, const Node& predicate, const Node& object, const Node& context = Node() ) const;
194 
200  StatementIterator listStatements() const;
201 
207  StatementIterator listStatementsInContext( const Node &context ) const;
208 
214  virtual NodeIterator listContexts() const = 0;
215 
228 // virtual QueryResultIterator executeQuery( const Query::Query& query ) const = 0;
229 
248  virtual QueryResultIterator executeQuery( const QString& query, Query::QueryLanguage language, const QString& userQueryLanguage = QString() ) const = 0;
250 
251 
253 
262  virtual bool containsAnyStatement( const Statement &statement ) const = 0;
263 
272  bool containsAnyStatement( const Node& subject, const Node& predicate, const Node& object, const Node& context = Node() ) const;
273 
284  virtual bool containsStatement( const Statement &statement ) const = 0;
285 
289  bool containsStatement( const Node& subject, const Node& predicate, const Node& object, const Node& context = Node() ) const;
290 
294  bool containsContext( const Node &context ) const;
295 
299  virtual bool isEmpty() const = 0;
300 
305  virtual int statementCount() const = 0;
307 
308 
310 
315  virtual Error::ErrorCode write( QTextStream &os ) const;
317 
318 
320 
325  virtual Node createBlankNode() = 0;
327 
328  Q_SIGNALS:
334  void statementsAdded();
335 
341  void statementsRemoved();
342 
347  void statementAdded( const Soprano::Statement& statement );
348 
358  void statementRemoved( const Soprano::Statement& statement );
359 
360  protected:
361  Model();
362 
363  private:
367  Model( const Model& );
368  Model& operator=( const Model& );
369 
370  class Private;
371  Private* const d;
372  };
373 }
374 
375 #endif