aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-07-15 22:07:30 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-07-15 22:08:38 +0100
commite2af660dffefd965506130258f14feb14730ef80 (patch)
treef2d99ee8a703446ea4ce78b86fc9f8ea5eb31f47
parente0f6e7ec0687eb055549d1f816278614a216e290 (diff)
downloadpaludis-e2af660dffefd965506130258f14feb14730ef80.tar.gz
paludis-e2af660dffefd965506130258f14feb14730ef80.tar.xz
Add filter::Slot().
-rw-r--r--paludis/filter-fwd.hh1
-rw-r--r--paludis/filter.cc35
-rw-r--r--paludis/filter.hh7
3 files changed, 43 insertions, 0 deletions
diff --git a/paludis/filter-fwd.hh b/paludis/filter-fwd.hh
index 8e678e7..c10c7a9 100644
--- a/paludis/filter-fwd.hh
+++ b/paludis/filter-fwd.hh
@@ -34,6 +34,7 @@ namespace paludis
class NotMasked;
class InstalledAtRoot;
class And;
+ class Slot;
}
std::ostream & operator<< (std::ostream &, const Filter &)
diff --git a/paludis/filter.cc b/paludis/filter.cc
index 8d9c9cc..c365b4f 100644
--- a/paludis/filter.cc
+++ b/paludis/filter.cc
@@ -236,6 +236,36 @@ namespace
}
};
+ struct SlotFilterHandler :
+ AllFilterHandlerBase
+ {
+ const SlotName n;
+
+ SlotFilterHandler(const SlotName & nn) :
+ n(nn)
+ {
+ }
+
+ virtual std::tr1::shared_ptr<const PackageIDSet> ids(
+ const Environment * const,
+ const std::tr1::shared_ptr<const PackageIDSet> & id) const
+ {
+ std::tr1::shared_ptr<PackageIDSet> result(new PackageIDSet);
+
+ for (PackageIDSet::ConstIterator i(id->begin()), i_end(id->end()) ;
+ i != i_end ; ++i)
+ if ((*i)->slot() == n)
+ result->insert(*i);
+
+ return result;
+ }
+
+ virtual std::string as_string() const
+ {
+ return "slot is '" + stringify(n) + "'";
+ }
+ };
+
struct AndFilterHandler :
FilterHandler
{
@@ -306,6 +336,11 @@ filter::InstalledAtRoot::InstalledAtRoot(const FSEntry & r) :
{
}
+filter::Slot::Slot(const SlotName & n) :
+ Filter(make_shared_ptr(new SlotFilterHandler(n)))
+{
+}
+
filter::And::And(const Filter & f1, const Filter & f2) :
Filter(make_shared_ptr(new AndFilterHandler(f1, f2)))
{
diff --git a/paludis/filter.hh b/paludis/filter.hh
index 1f17913..361565e 100644
--- a/paludis/filter.hh
+++ b/paludis/filter.hh
@@ -107,6 +107,13 @@ namespace paludis
public:
And(const Filter &, const Filter &);
};
+
+ class PALUDIS_VISIBLE Slot :
+ public Filter
+ {
+ public:
+ Slot(const SlotName &);
+ };
}
#ifdef PALUDIS_HAVE_EXTERN_TEMPLATE