00001 // 00002 // LibraryDictionary.h 00003 // 00004 // Copyright (c) Shareaza Development Team, 2002-2005. 00005 // This file is part of SHAREAZA (www.shareaza.com) 00006 // 00007 // Shareaza is free software; you can redistribute it 00008 // and/or modify it under the terms of the GNU General Public License 00009 // as published by the Free Software Foundation; either version 2 of 00010 // the License, or (at your option) any later version. 00011 // 00012 // Shareaza is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU General Public License 00018 // along with Shareaza; if not, write to the Free Software 00019 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 // 00021 00022 #if !defined(AFX_LIBRARYDICTIONARY_H__6C8B6129_DF70_4AE4_895B_7C7CE7CB3192__INCLUDED_) 00023 #define AFX_LIBRARYDICTIONARY_H__6C8B6129_DF70_4AE4_895B_7C7CE7CB3192__INCLUDED_ 00024 00025 #pragma once 00026 00027 class CLibraryWord; 00028 class CLibraryFile; 00029 class CQueryHashTable; 00030 class CQuerySearch; 00031 00032 00033 class CLibraryDictionary 00034 { 00035 // Construction 00036 public: 00037 CLibraryDictionary(); 00038 virtual ~CLibraryDictionary(); 00039 00040 // Attributes 00041 public: 00042 CQueryHashTable* m_pTable; 00043 protected: 00044 CMapStringToPtr m_pWords; 00045 BOOL m_bTable; 00046 DWORD m_nSearchCookie; 00047 00048 // Operations 00049 public: 00050 void Add(CLibraryFile* pFile); 00051 void Remove(CLibraryFile* pFile); 00052 BOOL BuildHashTable(); //Build hash table if needed 00053 void RebuildHashTable(); //Force hash table to re-build 00054 CQueryHashTable* GetHashTable(); 00055 void Clear(); 00056 CPtrList* Search(CQuerySearch* pSearch, int nMaximum = 0, BOOL bLocal = FALSE); 00057 protected: 00058 void ProcessFile(CLibraryFile* pFile, BOOL bAdd); 00059 int ProcessPhrase(CLibraryFile* pFile, const CString& strPhrase, BOOL bAdd, BOOL bLowercase = TRUE); 00060 inline void ProcessWord(CLibraryFile* pFile, const CString& strWord, BOOL bAdd); 00061 00062 }; 00063 00064 00065 class CLibraryWord 00066 { 00067 // Construction 00068 public: 00069 CLibraryWord(); 00070 ~CLibraryWord(); 00071 00072 // Attributes 00073 public: 00074 CLibraryFile** m_pList; 00075 DWORD m_nCount; 00076 00077 // Operations 00078 public: 00079 inline void Add(CLibraryFile* pFile); 00080 inline BOOL Remove(CLibraryFile* pFile); 00081 00082 }; 00083 00084 extern CLibraryDictionary LibraryDictionary; 00085 00086 #endif // !defined(AFX_LIBRARYDICTIONARY_H__6C8B6129_DF70_4AE4_895B_7C7CE7CB3192__INCLUDED_)