00001 #ifndef TAGCOLL_TDB_DISK_INDEX_H
00002 #define TAGCOLL_TDB_DISK_INDEX_H
00003
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
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
00109 #endif