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 #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
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 }