NepomukDaemons
sopranoindexmanager.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "sopranoindexmanager.h"
00021 #include "sopranoindexwriter.h"
00022 #include "sopranoindexreader.h"
00023
00024 #include <strigi/strigiconfig.h>
00025
00026 #include <Soprano/Client/DBusClient>
00027 #include <Soprano/Index/IndexFilterModel>
00028 #include <Soprano/Index/CLuceneIndex>
00029 #include <Soprano/Util/MutexModel>
00030 #include <Soprano/Client/DBusModel>
00031 #include <Soprano/Client/LocalSocketClient>
00032
00033 #include <QtCore/QDir>
00034 #include <QtCore/QDebug>
00035 #include <QtCore/QString>
00036
00037 #include <Nepomuk/ResourceManager>
00038
00039
00040 class Strigi::Soprano::IndexManager::Private
00041 {
00042 public:
00043 Private()
00044 : writer( 0 ),
00045 reader( 0 ) {
00046 }
00047
00048 IndexWriter* writer;
00049 IndexReader* reader;
00050 };
00051
00052
00053 extern "C" {
00054
00055 STRIGI_EXPORT Strigi::IndexManager* createIndexManager( const char* )
00056 {
00057 if( Nepomuk::ResourceManager::instance()->init() == 0 ) {
00058 return new Strigi::Soprano::IndexManager();
00059 }
00060 else {
00061 return 0;
00062 }
00063 }
00064
00065 STRIGI_EXPORT void deleteIndexManager( Strigi::IndexManager* m )
00066 {
00067 delete m;
00068 }
00069 }
00070
00071 Strigi::Soprano::IndexManager::IndexManager()
00072 {
00073 d = new Private;
00074 }
00075
00076
00077 Strigi::Soprano::IndexManager::~IndexManager()
00078 {
00079 qDebug() << "Cleaning up SopranoIndexManager";
00080 delete d->reader;
00081 delete d->writer;
00082 delete d;
00083 }
00084
00085
00086 Strigi::IndexReader* Strigi::Soprano::IndexManager::indexReader()
00087 {
00088 if ( !d->reader ) {
00089 qDebug() << "(Soprano::IndexManager) creating IndexReader";
00090 d->reader = new Strigi::Soprano::IndexReader( Nepomuk::ResourceManager::instance()->mainModel() );
00091 }
00092
00093 return d->reader;
00094 }
00095
00096
00097 Strigi::IndexWriter* Strigi::Soprano::IndexManager::indexWriter()
00098 {
00099 if ( !d->writer ) {
00100 qDebug() << "(Soprano::IndexManager) creating IndexWriter";
00101 d->writer = new Strigi::Soprano::IndexWriter( Nepomuk::ResourceManager::instance()->mainModel() );
00102 }
00103
00104 return d->writer;
00105 }