1/*------------------------------------------------------------------------------
2* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
3*
4* Distributable under the terms of either the Apache License (Version 2.0) or
5* the GNU Lesser General Public License, as specified in the COPYING file.
6------------------------------------------------------------------------------*/
7#ifndef _lucene_search_Filter_
8#define _lucene_search_Filter_
9
10#if defined(_LUCENE_PRAGMA_ONCE)
11# pragma once
12#endif
13
14#include "CLucene/index/IndexReader.h"
15#include "CLucene/util/BitSet.h"
16
17CL_NS_DEF(search)
18 // Abstract base class providing a mechanism to restrict searches to a subset
19 // of an index.
20 class Filter: LUCENE_BASE {
21 public:
22 virtual ~Filter(){
23 }
24
25 virtual Filter* clone() const = 0;
26
27 /**
28 * Returns a BitSet with true for documents which should be permitted in
29 * search results, and false for those that should not.
30 * MEMORY: read shouldDeleteBitSet
31 */
32 virtual CL_NS(util)::BitSet* bits(CL_NS(index)::IndexReader* reader)=0;
33
34 /**
35 * Because of the problem of cached bitsets with the CachingWrapperFilter,
36 * CLucene has no way of knowing whether to delete the bitset returned from bits().
37 * To properly clean memory from bits(), pass the bitset to this function. The
38 * Filter should be deleted if this function returns true.
39 */
40 virtual bool shouldDeleteBitSet(const CL_NS(util)::BitSet* bs) const{ return true; }
41
42 //Creates a user-readable version of this query and returns it as as string
43 virtual TCHAR* toString()=0;
44 };
45CL_NS_END
46#endif
47