1 | #ifndef RTAGCOLL_BUILDER_H |
---|
2 | #define RTAGCOLL_BUILDER_H |
---|
3 | |
---|
4 | /* |
---|
5 | * TagcollConsumer that builds a tagged collection |
---|
6 | * |
---|
7 | * Copyright (C) 2003 Enrico Zini <enrico@debian.org> |
---|
8 | * |
---|
9 | * This library is free software; you can redistribute it and/or |
---|
10 | * modify it under the terms of the GNU Lesser General Public |
---|
11 | * License as published by the Free Software Foundation; either |
---|
12 | * version 2.1 of the License, or (at your option) any later version. |
---|
13 | * |
---|
14 | * This library is distributed in the hope that it will be useful, |
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
17 | * Lesser General Public License for more details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU Lesser General Public |
---|
20 | * License along with this library; if not, write to the Free Software |
---|
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
22 | */ |
---|
23 | |
---|
24 | #if 0 // PORTME |
---|
25 | #ifdef HAVE_DEBTAGS |
---|
26 | //#pragma interface |
---|
27 | |
---|
28 | #include <HandleMaker.h> |
---|
29 | #include <TagcollConsumer.h> |
---|
30 | #include <TagCollection.h> |
---|
31 | #include "rpackage.h" |
---|
32 | #include "rpackagelister.h" |
---|
33 | |
---|
34 | // TagcollConsumer that builds a tagged collection for synaptic |
---|
35 | class RTagcollBuilder:public TagcollConsumer<std::string> { |
---|
36 | protected: |
---|
37 | HandleMaker<RPackage *> &handleMaker; |
---|
38 | TagCollection<int> coll; |
---|
39 | RPackageLister *_lister; |
---|
40 | |
---|
41 | int getHandle(const std::string &str) throw() { |
---|
42 | RPackage *pkg = _lister->getElement(str); |
---|
43 | return handleMaker.getHandle(pkg); |
---|
44 | } |
---|
45 | |
---|
46 | OpSet<int> itemsToHandles(const OpSet<std::string> &ts) throw() { |
---|
47 | OpSet<int> res; |
---|
48 | for (OpSet<std::string>::const_iterator i = ts.begin(); |
---|
49 | i != ts.end(); i++) |
---|
50 | res += getHandle(*i); |
---|
51 | return res; |
---|
52 | } |
---|
53 | |
---|
54 | public: |
---|
55 | RTagcollBuilder(HandleMaker<RPackage *> &handleMaker, |
---|
56 | RPackageLister *l) throw() |
---|
57 | : handleMaker(handleMaker), _lister(l) { |
---|
58 | } |
---|
59 | virtual ~ RTagcollBuilder()throw() { |
---|
60 | } |
---|
61 | |
---|
62 | virtual void consume(const std::string &item) throw() { |
---|
63 | coll.add(getHandle(item)); |
---|
64 | } |
---|
65 | |
---|
66 | virtual void consume(const std::string &item, |
---|
67 | const OpSet<std::string> &tags) throw() { |
---|
68 | coll.add(tags, getHandle(item)); |
---|
69 | } |
---|
70 | |
---|
71 | virtual void consume(const OpSet<std::string> &items) throw() { |
---|
72 | coll.add(itemsToHandles(items)); |
---|
73 | } |
---|
74 | |
---|
75 | virtual void consume(const OpSet<std::string> &items, |
---|
76 | const OpSet<std::string> &tags) throw() { |
---|
77 | coll.add(tags, itemsToHandles(items)); |
---|
78 | } |
---|
79 | |
---|
80 | // Retrieve the resulting collection |
---|
81 | TagCollection<int> collection() throw() { |
---|
82 | return coll; |
---|
83 | } |
---|
84 | const TagCollection<int> collection() const throw() { |
---|
85 | return coll; |
---|
86 | } |
---|
87 | }; |
---|
88 | |
---|
89 | #endif //HAVE_DEBTAGS |
---|
90 | |
---|
91 | // vim:set ts=4 sw=4: |
---|
92 | #endif |
---|
93 | #endif |
---|