PatchCollection.h

Go to the documentation of this file.
00001 #ifndef TAGCOLL_PATCHCOLLECTION_H
00002 #define TAGCOLL_PATCHCOLLECTION_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/Patches.h>
00028 
00029 namespace Tagcoll
00030 {
00031 
00036 template<class ITEM, class TAG>
00037 class PatchCollection : public Collection<ITEM, TAG>
00038 {
00039 protected:
00040     const ReadonlyCollection<ITEM, TAG>& coll;
00041     PatchList<ITEM, TAG> changes;
00042 
00043     virtual void consumeItem(const ITEM& item, const OpSet<TAG>& tags);
00044 
00045     virtual OpSet<ITEM> getItemsHavingTag(const TAG& tag) const;
00046     virtual OpSet<TAG> getTagsOfItem(const ITEM& item) const;
00047 
00048 public:
00049     PatchCollection(const ReadonlyCollection<ITEM, TAG>& coll) : coll(coll) {}
00050     virtual ~PatchCollection() {}
00051 
00055     const PatchList<ITEM, TAG>& getChanges() const { return changes; }
00056 
00060     void resetChanges() { changes.clear(); }
00061 
00065     void setChanges(const PatchList<ITEM, TAG>& changes);
00066 
00070     void addChanges(const PatchList<ITEM, TAG>& changes);
00071 
00072     virtual bool hasTag(const TAG& tag) const;
00073 
00074     virtual OpSet<ITEM> getTaggedItems() const;
00075     virtual OpSet<TAG> getAllTags() const;
00076 
00077     virtual int getCardinality(const TAG& tag) const;
00078 
00079     virtual void applyChange(const PatchList<ITEM, TAG>& change);
00080 
00081     virtual void output(Consumer<ITEM, TAG>& consumer) const;
00082 };
00083 
00084 };
00085 
00086 // vim:set ts=4 sw=4:
00087 #endif

Generated on Sat Jan 17 03:28:21 2009 for libtagcoll by  doxygen 1.5.1