[Debtags-commits] [svn] r892 - libdebtags1/trunk/debtags

Enrico Zini debtags-commits@lists.alioth.debian.org
Fri, 17 Jun 2005 23:00:53 +0000


Author: enrico
Date: Fri Jun 17 23:00:51 2005
New Revision: 892

Modified:
   libdebtags1/trunk/debtags/BasicPackageMatcher.cc
   libdebtags1/trunk/debtags/BasicPackageMatcher.h
Log:
BasicPackageMatcher can now act as a TagcollFilter

Modified: libdebtags1/trunk/debtags/BasicPackageMatcher.cc
==============================================================================
--- libdebtags1/trunk/debtags/BasicPackageMatcher.cc	(original)
+++ libdebtags1/trunk/debtags/BasicPackageMatcher.cc	Fri Jun 17 23:00:51 2005
@@ -81,7 +81,7 @@
 	return ptags.contains(tags);
 }
 
-bool BasicPackageMatcher::match(const Package& pkg) const throw ()
+bool BasicPackageMatcher::match(const Package& pkg, const OpSet<Tag>& tags) const throw ()
 {
 	bool got = true;
 	if (hasMaintainer() && pkg.maint() && !matchMaintainer(pkg.maint().fullname()))
@@ -96,9 +96,23 @@
 	} catch (PackageDBException& e) {
 		fprintf(stderr, "%s: %.*s. Skipping check for package status\n", e.type(), PFSTR(e.desc()));
 	}
-	if (hasDebtags() && !matchDebtags(pkg.tags()))
+	if (hasDebtags() && !matchDebtags(tags))
 		got = false;
+
 	return got;
 }
 
+
+void BasicPackageMatcher::consume(const Package& item) throw ()
+{
+	consume(item, OpSet<Tag>());
+}
+
+void BasicPackageMatcher::consume(const Package& item, const OpSet<Tag>& tags) throw ()
+{
+	if (match(item, tags))
+		consumer->consume(item, tags);
+}
+
+
 // vim:set ts=4 sw=4:

Modified: libdebtags1/trunk/debtags/BasicPackageMatcher.h
==============================================================================
--- libdebtags1/trunk/debtags/BasicPackageMatcher.h	(original)
+++ libdebtags1/trunk/debtags/BasicPackageMatcher.h	Fri Jun 17 23:00:51 2005
@@ -8,6 +8,8 @@
 #include <debtags/TagSet.h>
 #include <debtags/Consumer.h>
 
+#include <tagcoll/TagcollFilter.h>
+
 namespace Debtags
 {
 
@@ -16,7 +18,7 @@
 class Package;
 class Regexp;
 
-class BasicPackageMatcher : public PackageMatcher
+class BasicPackageMatcher : public PackageMatcher, public Tagcoll::TagcollFilter<Package, Tag>
 {
 public:
 	typedef enum { YES, NO, ANY } InstalledStatus;
@@ -64,7 +66,10 @@
 	bool matchDebtags(const TagSet& ptags) const throw ();
 	const TagSet& debtagsTagset() const throw () { return tags; }
 
-	bool match(const Package& pkg) const throw ();
+	bool match(const Package& pkg, const OpSet<Tag>& tags) const throw ();
+
+	void consume(const Package& item) throw ();
+	void consume(const Package& item, const OpSet<Tag>& tags) throw ();
 };
 
 };