CLucene - a full-featured, c++ search engine
API Documentation
00001 /*------------------------------------------------------------------------------ 00002 * Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team 00003 * 00004 * Distributable under the terms of either the Apache License (Version 2.0) or 00005 * the GNU Lesser General Public License, as specified in the COPYING file. 00006 ------------------------------------------------------------------------------*/ 00007 #ifndef _lucene_search_CachingWrapperFilter_ 00008 #define _lucene_search_CachingWrapperFilter_ 00009 00010 #include "CLucene/util/BitSet.h" 00011 #include "CLucene/index/IndexReader.h" 00012 #include "Filter.h" 00013 00014 CL_NS_DEF(search) 00020 class AbstractCachingFilter: public Filter 00021 { 00022 class BitSetHolder: LUCENE_BASE{ 00023 bool deleteBs; 00024 public: 00025 BitSetHolder(CL_NS(util)::BitSet* bits, bool deleteBs); 00026 ~BitSetHolder(); 00027 CL_NS(util)::BitSet* bits; 00028 }; 00029 void closeCallback(CL_NS(index)::IndexReader* reader, void* param); 00030 typedef CL_NS(util)::CLHashMap<CL_NS(index)::IndexReader*, 00031 BitSetHolder*, 00032 CL_NS(util)::Compare::Void<CL_NS(index)::IndexReader>, 00033 CL_NS(util)::Equals::Void<CL_NS(index)::IndexReader>, 00034 CL_NS(util)::Deletor::Object<CL_NS(index)::IndexReader>, 00035 CL_NS(util)::Deletor::Object<BitSetHolder> > CacheType; 00036 00037 CacheType cache; 00038 00039 protected: 00040 AbstractCachingFilter( const AbstractCachingFilter& copy ); 00041 virtual CL_NS(util)::BitSet* doBits( CL_NS(index)::IndexReader* reader ) = 0; 00042 virtual bool doShouldDeleteBitSet( CL_NS(util)::BitSet* bits ){ return false; } 00043 AbstractCachingFilter(); 00044 public: 00045 virtual ~AbstractCachingFilter(); 00046 00049 CL_NS(util)::BitSet* bits( CL_NS(index)::IndexReader* reader ); 00050 00051 virtual Filter *clone() const = 0; 00052 virtual TCHAR *toString() = 0; 00053 00054 bool shouldDeleteBitSet( const CL_NS(util)::BitSet* bits ) const{ return false; } 00055 }; 00056 00062 class CachingWrapperFilter: public AbstractCachingFilter 00063 { 00064 private: 00065 Filter* filter; 00066 bool deleteFilter; 00067 protected: 00068 CachingWrapperFilter( const CachingWrapperFilter& copy ); 00069 CL_NS(util)::BitSet* doBits( CL_NS(index)::IndexReader* reader ); 00070 bool doShouldDeleteBitSet( CL_NS(util)::BitSet* bits ); 00071 public: 00072 CachingWrapperFilter( Filter* filter, bool deleteFilter=true ); 00073 ~CachingWrapperFilter(); 00074 00075 Filter *clone() const; 00076 TCHAR *toString(); 00077 }; 00078 00079 CL_NS_END 00080 #endif