00001 /* 00002 * This file is part of Soprano Project. 00003 * 00004 * Copyright (C) 2007 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_INFERENCE_MODEL_H_ 00023 #define _SOPRANO_INFERENCE_MODEL_H_ 00024 00025 #include "filtermodel.h" 00026 #include "soprano_export.h" 00027 00028 class QUrl; 00029 00030 namespace Soprano { 00031 00032 class Statement; 00033 00034 namespace Inference { 00035 00036 class Rule; 00037 00071 class SOPRANO_EXPORT InferenceModel : public FilterModel 00072 { 00073 Q_OBJECT 00074 00075 public: 00076 InferenceModel( Model* parent ); 00077 ~InferenceModel(); 00078 00083 Error::ErrorCode addStatement( const Statement& ); 00084 00088 Error::ErrorCode removeStatement( const Statement& ); 00089 00093 Error::ErrorCode removeAllStatements( const Statement& ); 00094 00100 void addRule( const Rule& ); 00101 00107 void setRules( const QList<Rule>& rules ); 00108 00109 using FilterModel::addStatement; 00110 using FilterModel::removeStatement; 00111 using FilterModel::removeAllStatements; 00112 00113 public Q_SLOTS: 00123 void performInference(); 00124 00130 void clearInference(); 00131 00146 void setCompressedSourceStatements( bool b ); 00147 00160 void setOptimizedQueriesEnabled( bool b ); 00161 00162 private: 00171 int inferStatement( const Statement& statement, bool recurse = false ); 00172 00181 int inferRule( const Rule& rule, bool recurse ); 00182 00187 QList<Node> inferedGraphsForStatement( const Statement& statement ) const; 00188 00193 QUrl storeUncompressedSourceStatement( const Statement& sourceStatement ); 00194 00195 class Private; 00196 Private* const d; 00197 }; 00198 } 00199 } 00200 00201 uint qHash( const Soprano::Node& node ); 00202 00203 #endif