• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

NepomukDaemons

sopranoindexmanager.cpp

Go to the documentation of this file.
00001 /*
00002    Copyright (C) 2007-2008 Sebastian Trueg <trueg@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU General Public License as
00006    published by the Free Software Foundation; either version 2 of
00007    the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU General Public License
00015    along with this library; see the file COPYING.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017    Boston, MA 02110-1301, USA.
00018  */
00019 
00020 #include "sopranoindexmanager.h"
00021 #include "sopranoindexwriter.h"
00022 #include "sopranoindexreader.h"
00023 #include "nepomukmainmodel.h"
00024 
00025 #include <strigi/strigiconfig.h>
00026 
00027 #include <Soprano/Client/DBusClient>
00028 #include <Soprano/Index/IndexFilterModel>
00029 #include <Soprano/Index/CLuceneIndex>
00030 #include <Soprano/Util/MutexModel>
00031 #include <Soprano/Client/DBusModel>
00032 #include <Soprano/Client/LocalSocketClient>
00033 
00034 #include <QtCore/QDir>
00035 #include <QtCore/QDebug>
00036 #include <QtCore/QString>
00037 
00038 
00039 class Strigi::Soprano::IndexManager::Private
00040 {
00041 public:
00042     Private()
00043         : repository( 0 ),
00044           writer( 0 ),
00045           reader( 0 ) {
00046     }
00047 
00048     ::Soprano::Model* repository;
00049     IndexWriter* writer;
00050     IndexReader* reader;
00051 };
00052 
00053 
00054 extern "C" {
00055 // we do not use REGISTER_STRIGI_INDEXMANAGER as we do have to perform some additional checks
00056 STRIGI_EXPORT Strigi::IndexManager* createIndexManager( const char* )
00057 {
00058     Nepomuk::MainModel* model = new Nepomuk::MainModel();
00059     if( model->isValid() ) {
00060         return new Strigi::Soprano::IndexManager( model );
00061     }
00062     else {
00063         delete model;
00064         return 0;
00065     }
00066 }
00067 
00068 STRIGI_EXPORT void deleteIndexManager( Strigi::IndexManager* m )
00069 {
00070     delete m;
00071 }
00072 }
00073 
00074 Strigi::Soprano::IndexManager::IndexManager( ::Soprano::Model* model )
00075 {
00076     d = new Private;
00077     d->repository = model;
00078 }
00079 
00080 
00081 Strigi::Soprano::IndexManager::~IndexManager()
00082 {
00083     qDebug() << "Cleaning up SopranoIndexManager";
00084     delete d->reader;
00085     delete d->writer;
00086     delete d->repository;
00087     delete d;
00088 }
00089 
00090 
00091 Strigi::IndexReader* Strigi::Soprano::IndexManager::indexReader()
00092 {
00093     if ( !d->reader ) {
00094         qDebug() << "(Soprano::IndexManager) creating IndexReader";
00095         d->reader = new Strigi::Soprano::IndexReader( d->repository );
00096     }
00097 
00098     return d->reader;
00099 }
00100 
00101 
00102 Strigi::IndexWriter* Strigi::Soprano::IndexManager::indexWriter()
00103 {
00104     if ( !d->writer ) {
00105         qDebug() << "(Soprano::IndexManager) creating IndexWriter";
00106         d->writer = new Strigi::Soprano::IndexWriter( d->repository );
00107     }
00108 
00109     return d->writer;
00110 }

NepomukDaemons

Skip menu "NepomukDaemons"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • KCMShell
  • KNotify
  • KStyles
  • Nepomuk Daemons
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal