00001 #ifndef TAGCOLL_ITEM_GROUPER_H
00002 #define TAGCOLL_ITEM_GROUPER_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/OpSet.h>
00028
00029 #include <map>
00030 #include <string>
00031
00032 namespace Tagcoll
00033 {
00034
00035 template<class ITEM, class TAG>
00036 class ItemGrouper : public TagcollConsumer<ITEM, TAG>
00037 {
00038 protected:
00039
00040 std::map<OpSet<TAG>, OpSet<ITEM> > groups;
00041
00042 public:
00043 virtual ~ItemGrouper() throw () {}
00044
00045 virtual void consume(const ITEM& item) throw ()
00046 {
00047 groups[OpSet<TAG>()] += item;
00048 }
00049
00050 virtual void consume(const ITEM& item, const OpSet<TAG>& tags) throw ()
00051 {
00052 groups[tags] += item;
00053 }
00054
00055 virtual void consume(const OpSet<ITEM>& items) throw ()
00056 {
00057 groups[OpSet<TAG>()] += items;
00058 }
00059
00060 virtual void consume(const OpSet<ITEM>& items, const OpSet<TAG>& tags) throw ()
00061 {
00062 groups[tags] += items;
00063 }
00064
00065
00066 void output(TagcollConsumer<ITEM, TAG>& consumer) throw ();
00067 };
00068
00069 };
00070
00071
00072 #endif