TDBDiskIndex.h

Go to the documentation of this file.
00001 #ifndef TAGCOLL_TDB_DISK_INDEX_H
00002 #define TAGCOLL_TDB_DISK_INDEX_H
00003 
00008 /*
00009  * Copyright (C) 2005  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/TDBFile.h>
00030 #include <map>
00031 
00032 #include <string>
00033 
00034 namespace Tagcoll
00035 {
00036 
00049 template<class ITEM, class TAG>
00050 class TDBDiskIndex : public Collection<ITEM, TAG>
00051 {
00052 protected:
00053     TDBFile pkgdb;
00054     TDBFile tagdb;
00055     const Converter<ITEM, std::string>& fromitem;
00056     const Converter<TAG, std::string>& fromtag;
00057     const Converter<std::string, ITEM>& toitem;
00058     const Converter<std::string, TAG>& totag;
00059 
00060     virtual void consumeItem(const ITEM& item, const OpSet<TAG>& tags);
00061     virtual void consumeItems(const OpSet<ITEM>& items, const OpSet<TAG>& tags);
00062 
00063     virtual OpSet<ITEM> getItemsHavingTag(const TAG& tag) const;
00064     virtual OpSet<TAG> getTagsOfItem(const ITEM& item) const;
00065 
00066 public:
00084     TDBDiskIndex(
00085             const std::string& pkgidx,
00086             const std::string& tagidx,
00087             const Converter<ITEM, std::string>& fromitem,
00088             const Converter<TAG, std::string>& fromtag,
00089             const Converter<std::string, ITEM>& toitem,
00090             const Converter<std::string, TAG>& totag,
00091             bool write = true);
00092     virtual ~TDBDiskIndex() {}
00093 
00094     virtual bool hasTag(const TAG& tag) const;
00095 
00096     virtual OpSet<ITEM> getTaggedItems() const;
00097     virtual OpSet<TAG> getAllTags() const;
00098 
00099     virtual int getCardinality(const TAG& tag) const;
00100 
00101     virtual void output(Consumer<ITEM, TAG>& consumer) const;
00102 
00103     virtual void applyChange(const PatchList<ITEM, TAG>& change);
00104 };
00105 
00106 };
00107 
00108 // vim:set ts=4 sw=4:
00109 #endif

Generated on Tue Aug 21 13:07:09 2007 for libtagcoll by  doxygen 1.5.3