00001 #ifndef TAGCOLL_CHANGES_H
00002 #define TAGCOLL_CHANGES_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #pragma interface
00025
00026 #include <tagcoll/TagcollConsumer.h>
00027 #include <tagcoll/TagcollFilter.h>
00028
00029 #include <map>
00030 #include <string>
00031
00032 namespace Tagcoll
00033 {
00034
00035
00036
00037 class ChangeList : public TagcollConsumer<std::string>
00038 {
00039 protected:
00040 typedef std::map<std::string, std::string> changes_t;
00041 changes_t changes;
00042
00043 public:
00044 virtual ~ChangeList() throw () {}
00045
00046 virtual void consume(const std::string& item) throw () {}
00047 virtual void consume(const std::string& item, const OpSet<std::string>& tags) throw ();
00048
00049
00050 std::string change(const std::string& tag) const throw ();
00051
00052
00053 OpSet<std::string> change(const OpSet<std::string>& tags) const throw ();
00054 };
00055
00056 class ApplyChanges : public TagcollFilter<std::string>
00057 {
00058 protected:
00059 ChangeList& changes;
00060
00061 public:
00062 ApplyChanges(ChangeList& changes) throw ()
00063 : changes(changes) {}
00064
00065 virtual void consume(const std::string& item) throw ()
00066 {
00067 consumer->consume(changes.change(item));
00068 }
00069
00070 virtual void consume(const std::string& item, const OpSet<std::string>& tags) throw ()
00071 {
00072 consumer->consume(item, changes.change(tags));
00073 }
00074 };
00075
00076 };
00077
00078
00079 #endif