1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
|
/*
* Copyright 2005-2008 Fabrice Colin
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _INDEX_INTERFACE_H
#define _INDEX_INTERFACE_H
#include <string>
#include <set>
#include <map>
#include "Document.h"
#include "Visibility.h"
/// Interface implemented by indexes.
class PINOT_EXPORT IndexInterface
{
public:
IndexInterface(const IndexInterface &other) {};
virtual ~IndexInterface() {};
typedef enum { BY_LABEL = 0, BY_DIRECTORY, BY_FILE, BY_CONTAINER_FILE } NameType;
/// Returns false if the index couldn't be opened.
virtual bool isGood(void) const = 0;
/// Gets metadata.
virtual std::string getMetadata(const std::string &name) const = 0;
/// Sets metadata.
virtual bool setMetadata(const std::string &name, const std::string &value) const = 0;
/// Gets the index location.
virtual std::string getLocation(void) const = 0;
/// Returns a document's properties.
virtual bool getDocumentInfo(unsigned int docId, DocumentInfo &docInfo) const = 0;
/// Returns a document's terms count.
virtual unsigned int getDocumentTermsCount(unsigned int docId) const = 0;
/// Returns a document's terms.
virtual bool getDocumentTerms(unsigned int docId,
std::map<unsigned int, std::string> &wordsBuffer) const = 0;
/// Sets the list of known labels.
virtual bool setLabels(const std::set<std::string> &labels, bool resetLabels) = 0;
/// Gets the list of known labels.
virtual bool getLabels(std::set<std::string> &labels) const = 0;
/// Adds a label.
virtual bool addLabel(const std::string &name) = 0;
/// Deletes all references to a label.
virtual bool deleteLabel(const std::string &name) = 0;
/// Determines whether a document has a label.
virtual bool hasLabel(unsigned int docId, const std::string &name) const = 0;
/// Returns a document's labels.
virtual bool getDocumentLabels(unsigned int docId, std::set<std::string> &labels) const = 0;
/// Sets a document's labels.
virtual bool setDocumentLabels(unsigned int docId, const std::set<std::string> &labels,
bool resetLabels = true) = 0;
/// Sets documents' labels.
virtual bool setDocumentsLabels(const std::set<unsigned int> &docIds,
const std::set<std::string> &labels, bool resetLabels = true) = 0;
/// Checks whether the given URL is in the index.
virtual unsigned int hasDocument(const std::string &url) const = 0;
/// Gets terms with the same root.
virtual unsigned int getCloseTerms(const std::string &term, std::set<std::string> &suggestions) = 0;
/// Returns the ID of the last document.
virtual unsigned int getLastDocumentID(void) const = 0;
/// Returns the number of documents.
virtual unsigned int getDocumentsCount(const std::string &labelName = "") const = 0;
/// Lists documents.
virtual unsigned int listDocuments(std::set<unsigned int> &docIDList,
unsigned int maxDocsCount = 0, unsigned int startDoc = 0) const = 0;
/// Lists documents.
virtual bool listDocuments(const std::string &name, std::set<unsigned int> &docIds,
NameType type, unsigned int maxDocsCount = 0, unsigned int startDoc = 0) const = 0;
/// Indexes the given data.
virtual bool indexDocument(const Document &doc, const std::set<std::string> &labels,
unsigned int &docId) = 0;
/// Updates the given document.
virtual bool updateDocument(unsigned int docId, const Document &doc) = 0;
/// Updates a document's properties.
virtual bool updateDocumentInfo(unsigned int docId, const DocumentInfo &docInfo) = 0;
/// Unindexes the given document.
virtual bool unindexDocument(unsigned int docId) = 0;
/// Unindexes the given document.
virtual bool unindexDocument(const std::string &location) = 0;
/// Unindexes documents.
virtual bool unindexDocuments(const std::string &name, NameType type) = 0;
/// Unindexes all documents.
virtual bool unindexAllDocuments(void) = 0;
/// Flushes recent changes to the disk.
virtual bool flush(void) = 0;
/// Reopens the index.
virtual bool reopen(void) const = 0;
/// Resets the index.
virtual bool reset(void) = 0;
protected:
IndexInterface() { };
};
#endif // _INDEX_INTERFACE_H
|