/src/libtomahawk/database/fuzzyindex.h

http://github.com/tomahawk-player/tomahawk · C Header · 88 lines · 56 code · 15 blank · 17 comment · 0 complexity · ec17a1e8e13a927d075455b9fa06dd3b MD5 · raw file

  1. /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
  2. *
  3. * Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
  4. *
  5. * Tomahawk is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * Tomahawk is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef FUZZYINDEX_H
  19. #define FUZZYINDEX_H
  20. #include <QObject>
  21. #include <QMap>
  22. #include <QHash>
  23. #include <QString>
  24. #include <QMutex>
  25. #include "Query.h"
  26. namespace lucene
  27. {
  28. namespace analysis
  29. {
  30. class SimpleAnalyzer;
  31. }
  32. namespace store
  33. {
  34. class Directory;
  35. }
  36. namespace index
  37. {
  38. class IndexReader;
  39. class IndexWriter;
  40. }
  41. namespace search
  42. {
  43. class IndexSearcher;
  44. }
  45. }
  46. class DatabaseImpl;
  47. class FuzzyIndex : public QObject
  48. {
  49. Q_OBJECT
  50. public:
  51. explicit FuzzyIndex( QObject* parent, bool wipe = false );
  52. ~FuzzyIndex();
  53. void beginIndexing();
  54. void endIndexing();
  55. void appendFields( const QMap< unsigned int, QMap< QString, QString > >& trackData );
  56. signals:
  57. void indexReady();
  58. public slots:
  59. void loadLuceneIndex();
  60. QMap< int, float > search( const Tomahawk::query_ptr& query );
  61. QMap< int, float > searchAlbum( const Tomahawk::query_ptr& query );
  62. private slots:
  63. void updateIndex();
  64. bool wipeIndex();
  65. private:
  66. QMutex m_mutex;
  67. QString m_lucenePath;
  68. lucene::analysis::SimpleAnalyzer* m_analyzer;
  69. lucene::store::Directory* m_luceneDir;
  70. lucene::index::IndexReader* m_luceneReader;
  71. lucene::search::IndexSearcher* m_luceneSearcher;
  72. };
  73. #endif // FUZZYINDEX_H