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_RAMDirectory_ 00008 #define _lucene_store_RAMDirectory_ 00009 00010 00011 //#include "Lock.h" 00012 #include "Directory.h" 00013 CL_CLASS_DEF(store,RAMFile) 00014 //#include "CLucene/util/VoidMap.h" 00015 //#include "CLucene/util/Arrays.h" 00016 00017 CL_NS_DEF(store) 00018 00025 class CLUCENE_EXPORT RAMDirectory:public Directory{ 00026 typedef CL_NS(util)::CLHashMap<const char*,RAMFile*, 00027 CL_NS(util)::Compare::Char, CL_NS(util)::Equals::Char, 00028 CL_NS(util)::Deletor::acArray , CL_NS(util)::Deletor::Object<RAMFile> > FileMap; 00029 protected: 00031 virtual bool doDeleteFile(const char* name); 00032 00043 void _copyFromDir(Directory* dir, bool closeDir); 00044 FileMap* files; // unlike the java Hashtable, FileMap is not synchronized, and all access must be protected by a lock 00045 public: 00046 int64_t sizeInBytes; 00047 00048 DEFINE_MUTABLE_MUTEX(files_mutex) // mutable: const methods must also be able to synchronize properly 00049 00050 00051 void list(std::vector<std::string>* names) const; 00052 00054 RAMDirectory(); 00055 00059 virtual ~RAMDirectory(); 00060 00061 RAMDirectory(Directory* dir); 00062 00068 RAMDirectory(const char* dir); 00069 00071 bool fileExists(const char* name) const; 00072 00074 int64_t fileModified(const char* name) const; 00075 00077 int64_t fileLength(const char* name) const; 00078 00080 virtual void renameFile(const char* from, const char* to); 00081 00083 void touchFile(const char* name); 00084 00087 virtual IndexOutput* createOutput(const char* name); 00088 00090 IndexInput* openInput(const char* name); 00091 00092 virtual void close(); 00093 00094 TCHAR* toString() const; 00095 00096 static const char* DirectoryType(); 00097 const char* getDirectoryType(); 00098 }; 00099 CL_NS_END 00100 #endif