Soprano  2.9.4
graph.h
Go to the documentation of this file.
1 /*
2  * This file is part of Soprano Project.
3  *
4  * Copyright (C) 2009 Sebastian Trueg <trueg@kde.org>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public License
17  * along with this library; see the file COPYING.LIB. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21 
22 #ifndef SOPRANO_GRAPH_H
23 #define SOPRANO_GRAPH_H
24 
25 #include <QtCore/QList>
26 #include <QtCore/QSharedDataPointer>
27 #include <QtCore/QDebug>
28 
29 #include "soprano_export.h"
30 #include "error.h"
31 #include "sopranotypes.h"
32 #include "node.h"
33 #include "statement.h"
34 
35 
36 namespace Soprano
37 {
38  class StatementIterator;
39  class NodeIterator;
40 
61  {
62  public:
66  Graph();
67 
71  Graph( const Graph& );
72 
78  Graph( const QList<Statement>& );
79 
83  ~Graph();
84 
86 
91  void addStatement( const Statement& statement );
92 
96  void addStatement( const Node& subject, const Node& predicate, const Node& object, const Node& context = Node() );
97 
101  void addStatements( const QList<Statement>& statements );
103 
105 
113  void removeStatement( const Statement& statement );
114 
118  void removeStatement( const Node& subject, const Node& predicate, const Node& object, const Node& context = Node() );
119 
127  void removeAllStatements( const Statement& statement = Statement() );
128 
137  void removeAllStatements( const Node& subject, const Node& predicate, const Node& object, const Node& context = Node() );
138 
142  void removeStatements( const QList<Statement>& statements );
143 
147  void removeContext( const Node& );
149 
150 
152 
160  StatementIterator listStatements( const Statement& partial = Statement() ) const;
161 
172  StatementIterator listStatements( const Node& subject, const Node& predicate, const Node& object, const Node& context = Node() ) const;
173 
179  StatementIterator listStatementsInContext( const Node& context ) const;
180 
186  NodeIterator listContexts() const;
188 
189 
191 
200  bool containsAnyStatement( const Statement& statement ) const;
201 
210  bool containsAnyStatement( const Node& subject, const Node& predicate, const Node& object, const Node& context = Node() ) const;
211 
222  bool containsStatement( const Statement& statement ) const;
223 
227  bool containsStatement( const Node& subject, const Node& predicate, const Node& object, const Node& context = Node() ) const;
228 
232  bool containsContext( const Node& context ) const;
233 
237  bool isEmpty() const;
238 
243  int statementCount() const;
245 
247 
250  QList<Statement> toList() const;
252 
254 
257  QSet<Statement> toSet() const;
259 
267  Graph& operator=( const Graph& g );
268 
272  Graph& operator=( const QList<Statement>& statements );
273 
277  Graph operator+( const Graph& g ) const;
278 
282  Graph operator+( const Statement& s ) const;
283 
288  Graph& operator+=( const Graph& g );
289 
294  Graph& operator+=( const Statement& s );
295 
300  Graph operator-( const Graph& ) const;
301 
306  Graph operator-( const Statement& s ) const;
307 
312  Graph& operator-=( const Graph& g );
313 
318  Graph& operator-=( const Statement& s );
319 
323  Graph& operator<<( const Graph& );
324 
328  Graph& operator<<( const Statement& );
329 
336  bool operator==( const Graph& g ) const;
337 
344  bool operator!=( const Graph& g ) const;
346 
347  private:
348  class Private;
350  };
351 
352  SOPRANO_EXPORT QDebug operator<<(QDebug dbg, const Graph& graph);
353 }
354 
355 #endif
QSet
soprano_export.h
Soprano::Vocabulary::RDF::subject
SOPRANO_EXPORT QUrl subject()
Soprano::Vocabulary::RDF::Statement
SOPRANO_EXPORT QUrl Statement()
Soprano::Vocabulary::RDF::predicate
SOPRANO_EXPORT QUrl predicate()
QSharedDataPointer< Private >
SOPRANO_EXPORT
#define SOPRANO_EXPORT
Definition: soprano_export.h:37
QList
Soprano::Statement
A Statement instance represents one RDF quadruple.
Definition: statement.h:47
sopranotypes.h
node.h
error.h
Soprano::operator<<
SOPRANO_EXPORT QDebug operator<<(QDebug dbg, const Graph &graph)
statement.h
Soprano::StatementIterator
An iterator that provides a stream of Statements.
Definition: statementiterator.h:75
Soprano
Definition: backend.h:35
Soprano::Graph
A simple collection of statements.
Definition: graph.h:60
Soprano::NodeIterator
An iterator that provides a stream of Nodes.
Definition: nodeiterator.h:72
Soprano::Node
A Node represents one RDF resource.
Definition: node.h:53
Soprano::Vocabulary::NRL::Graph
SOPRANO_EXPORT QUrl Graph()
Soprano::Vocabulary::SIL::context
SOPRANO_EXPORT QUrl context()