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_INDEX_MODEL_FILTER_H_ 00023 #define _SOPRANO_INDEX_MODEL_FILTER_H_ 00024 00025 #include "filtermodel.h" 00026 #include "soprano_export.h" 00027 00028 namespace Soprano { 00029 00030 namespace Query { 00031 class Query; 00032 } 00033 00044 namespace Index { 00045 00046 class CLuceneIndex; 00047 class QueryResult; 00048 00060 class SOPRANO_INDEX_EXPORT IndexFilterModel : public Soprano::FilterModel 00061 { 00062 public: 00072 IndexFilterModel( const QString& indexDir, Soprano::Model* model = 0 ); 00073 00082 IndexFilterModel( CLuceneIndex* index, Soprano::Model* model = 0 ); 00083 00087 ~IndexFilterModel(); 00088 00092 CLuceneIndex* index() const; 00093 00099 Soprano::Error::ErrorCode addStatement( const Soprano::Statement &statement ); 00100 00106 Soprano::Error::ErrorCode removeStatement( const Soprano::Statement &statement ); 00107 00113 Soprano::Error::ErrorCode removeAllStatements( const Soprano::Statement &statement ); 00114 00139 QueryResultIterator executeQuery( const QString& query, Query::QueryLanguage language, const QString& userQueryLanguage = QString() ) const; 00140 00141 /* 00142 * Extract full text matching parts of a %query and replace them with 00143 * results from an index %query. 00144 * 00145 * \param query The query to rewrite. 00146 * 00147 * \return A rewritten query stripped of all full test and regexp matching parts 00148 * and replaced by results from an index query. 00149 */ 00150 // Query::Query evaluateAndRewriteQuery( const Query::Query& query ) const; 00151 00162 void setTransactionCacheSize( int size ); 00163 00169 int transactionCacheSize() const; 00170 00179 void rebuildIndex(); 00180 00193 void addIndexOnlyPredicate( const QUrl& predicate ); 00194 00207 void setIndexOnlyPredicates( const QList<QUrl>& predicates ); 00208 00222 QList<QUrl> indexOnlyPredicates() const; 00223 00224 using FilterModel::addStatement; 00225 using FilterModel::removeStatement; 00226 using FilterModel::removeAllStatements; 00227 00228 private: 00229 class Private; 00230 Private* const d; 00231 }; 00232 } 00233 } 00234 00235 #endif