Soprano
2.7.2
|
00001 /* 00002 * This file is part of Soprano Project. 00003 * 00004 * Copyright (C) 2009 Sebastian Trueg <trueg@kde.org> 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Library General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Library General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Library General Public License 00017 * along with this library; see the file COPYING.LIB. If not, write to 00018 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 */ 00021 00022 #ifndef SOPRANO_GRAPH_H 00023 #define SOPRANO_GRAPH_H 00024 00025 #include <QtCore/QList> 00026 #include <QtCore/QSharedDataPointer> 00027 #include <QtCore/QDebug> 00028 00029 #include "soprano_export.h" 00030 #include "error.h" 00031 #include "sopranotypes.h" 00032 #include "node.h" 00033 #include "statement.h" 00034 00035 00036 namespace Soprano 00037 { 00038 class StatementIterator; 00039 class NodeIterator; 00040 00060 class SOPRANO_EXPORT Graph 00061 { 00062 public: 00066 Graph(); 00067 00071 Graph( const Graph& ); 00072 00078 Graph( const QList<Statement>& ); 00079 00083 ~Graph(); 00084 00086 00091 void addStatement( const Statement& statement ); 00092 00096 void addStatement( const Node& subject, const Node& predicate, const Node& object, const Node& context = Node() ); 00097 00101 void addStatements( const QList<Statement>& statements ); 00103 00105 00113 void removeStatement( const Statement& statement ); 00114 00118 void removeStatement( const Node& subject, const Node& predicate, const Node& object, const Node& context = Node() ); 00119 00127 void removeAllStatements( const Statement& statement = Statement() ); 00128 00137 void removeAllStatements( const Node& subject, const Node& predicate, const Node& object, const Node& context = Node() ); 00138 00142 void removeStatements( const QList<Statement>& statements ); 00143 00147 void removeContext( const Node& ); 00149 00150 00152 00160 StatementIterator listStatements( const Statement& partial = Statement() ) const; 00161 00172 StatementIterator listStatements( const Node& subject, const Node& predicate, const Node& object, const Node& context = Node() ) const; 00173 00179 StatementIterator listStatementsInContext( const Node& context ) const; 00180 00186 NodeIterator listContexts() const; 00188 00189 00191 00200 bool containsAnyStatement( const Statement& statement ) const; 00201 00210 bool containsAnyStatement( const Node& subject, const Node& predicate, const Node& object, const Node& context = Node() ) const; 00211 00222 bool containsStatement( const Statement& statement ) const; 00223 00227 bool containsStatement( const Node& subject, const Node& predicate, const Node& object, const Node& context = Node() ) const; 00228 00232 bool containsContext( const Node& context ) const; 00233 00237 bool isEmpty() const; 00238 00243 int statementCount() const; 00245 00247 00250 QList<Statement> toList() const; 00252 00254 00257 QSet<Statement> toSet() const; 00259 00267 Graph& operator=( const Graph& g ); 00268 00272 Graph& operator=( const QList<Statement>& statements ); 00273 00277 Graph operator+( const Graph& g ) const; 00278 00282 Graph operator+( const Statement& s ) const; 00283 00288 Graph& operator+=( const Graph& g ); 00289 00294 Graph& operator+=( const Statement& s ); 00295 00300 Graph operator-( const Graph& ) const; 00301 00306 Graph operator-( const Statement& s ) const; 00307 00312 Graph& operator-=( const Graph& g ); 00313 00318 Graph& operator-=( const Statement& s ); 00319 00323 Graph& operator<<( const Graph& ); 00324 00328 Graph& operator<<( const Statement& ); 00329 00336 bool operator==( const Graph& g ) const; 00337 00344 bool operator!=( const Graph& g ) const; 00346 00347 private: 00348 class Private; 00349 QSharedDataPointer<Private> d; 00350 }; 00351 00352 SOPRANO_EXPORT QDebug operator<<(QDebug dbg, const Graph& graph); 00353 } 00354 00355 #endif