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_store_LockFactory_ 00008 #define _lucene_store_LockFactory_ 00009 00010 //#include "Lock.h" 00011 00012 00013 CL_CLASS_DEF(store,LuceneLock) 00014 CL_CLASS_DEF(store,NoLock) 00015 00016 CL_NS_DEF(store) 00017 class LocksType; 00018 00019 class LockFactory: LUCENE_BASE { 00020 protected: 00021 00022 TCHAR* lockPrefix; 00023 00024 public: 00025 00026 LockFactory(); 00027 virtual ~LockFactory(); 00028 00029 void setLockPrefix( TCHAR* lockPrefix ); 00030 TCHAR* getLockPrefix(); 00031 00032 virtual LuceneLock* makeLock( const char* lockName )=0; 00033 virtual void clearLock( const char* lockName )=0; 00034 00035 }; 00036 00037 class SingleInstanceLockFactory: public LockFactory { 00038 private: 00039 LocksType* locks; 00040 00041 public: 00042 SingleInstanceLockFactory(); 00043 ~SingleInstanceLockFactory(); 00044 00045 LuceneLock* makeLock( const char* lockName ); 00046 void clearLock( const char* lockName ); 00047 }; 00048 00049 class NoLockFactory: public LockFactory { 00050 public: 00051 static NoLockFactory* singleton; 00052 static NoLock* singletonLock; 00053 00054 static NoLockFactory* getNoLockFactory(); 00055 LuceneLock* makeLock( const char* lockName ); 00056 void clearLock( const char* lockName ); 00057 00059 static void shutdown(); 00060 }; 00061 00062 class FSLockFactory: public LockFactory { 00063 private: 00064 const char* lockDir; 00065 00066 public: 00067 FSLockFactory( const char* lockDir=NULL ); 00068 ~FSLockFactory(); 00069 00070 void setLockDir( const char* lockDir ); 00071 00072 LuceneLock* makeLock( const char* lockName ); 00073 void clearLock( const char* lockName ); 00074 }; 00075 00076 CL_NS_END 00077 #endif