00001 #ifndef TAGCOLL_BASIC_DISK_INDEX_H 00002 #define TAGCOLL_BASIC_DISK_INDEX_H 00003 00008 /* 00009 * Copyright (C) 2006 Enrico Zini <enrico@debian.org> 00010 * 00011 * This program is free software; you can redistribute it and/or modify 00012 * it under the terms of the GNU General Public License as published by 00013 * the Free Software Foundation; either version 2 of the License, or 00014 * (at your option) any later version. 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU General Public License 00022 * along with this program; if not, write to the Free Software 00023 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00024 */ 00025 00026 #include <tagcoll/Collection.h> 00027 #include <tagcoll/Serializer.h> 00028 #include <tagcoll/Exception.h> 00029 #include <tagcoll/IntDiskIndex.h> 00030 #include <tagcoll/StringIndex.h> 00031 #include <tagcoll/InputMerger.h> 00032 00033 namespace Tagcoll 00034 { 00035 00043 class BasicStringDiskIndex : public MasterMMapIndex, public IntDiskIndex<std::string, std::string> 00044 { 00045 protected: 00046 StringIndex pkgs; 00047 StringIndex tags; 00048 00049 public: 00056 BasicStringDiskIndex(const std::string& file); 00057 virtual ~BasicStringDiskIndex() {} 00058 00059 const std::string& filename() const { return m_filename; } 00060 00061 static void remove(const std::string& dir); 00062 }; 00063 00064 class BasicStringDiskIndexer : public Consumer<std::string, std::string> 00065 { 00066 protected: 00067 InputMerger<std::string, std::string> cache; 00068 StringIndexer pkgs; 00069 StringIndexer tags; 00070 00071 virtual void consumeItemUntagged(const std::string& item); 00072 virtual void consumeItem(const std::string& item, const OpSet<std::string>& tags); 00073 00074 public: 00075 virtual ~BasicStringDiskIndexer() {} 00076 00077 void write(const std::string& file); 00078 }; 00079 00080 00081 }; 00082 00083 // vim:set ts=4 sw=4: 00084 #endif