aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-05-06 11:17:18 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-05-06 11:29:11 +0100
commit8e7d38867fb807fe13bab057d0af5d68116e4508 (patch)
tree4f31b7f34c243b8b6352e83381b903e7a08d7a27
parent01337e0a95b3f39d09efe52d184600f37f0e121f (diff)
downloadpaludis-8e7d38867fb807fe13bab057d0af5d68116e4508.tar.gz
paludis-8e7d38867fb807fe13bab057d0af5d68116e4508.tar.xz
generator::Nothing()
-rw-r--r--paludis/generator-fwd.hh1
-rw-r--r--paludis/generator.cc45
-rw-r--r--paludis/generator.hh12
3 files changed, 57 insertions, 1 deletions
diff --git a/paludis/generator-fwd.hh b/paludis/generator-fwd.hh
index 4629ac8..5aae111 100644
--- a/paludis/generator-fwd.hh
+++ b/paludis/generator-fwd.hh
@@ -43,6 +43,7 @@ namespace paludis
class Category;
class Intersection;
class Union;
+ class Nothing;
template <typename> class SomeIDsMightSupportAction;
}
diff --git a/paludis/generator.cc b/paludis/generator.cc
index 1abe6f8..7912972 100644
--- a/paludis/generator.cc
+++ b/paludis/generator.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2008, 2009, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -672,6 +672,44 @@ namespace
return "packages that might support action " + stringify(ActionNames<A_>::value);
}
};
+
+ struct NothingGeneratorHandler :
+ GeneratorHandler
+ {
+ virtual std::tr1::shared_ptr<const RepositoryNameSet> repositories(
+ const Environment * const) const
+ {
+ return make_shared_ptr(new RepositoryNameSet);
+ }
+
+ virtual std::tr1::shared_ptr<const CategoryNamePartSet> categories(
+ const Environment * const,
+ const std::tr1::shared_ptr<const RepositoryNameSet> &) const
+ {
+ return make_shared_ptr(new CategoryNamePartSet);
+ }
+
+ virtual std::tr1::shared_ptr<const QualifiedPackageNameSet> packages(
+ const Environment * const,
+ const std::tr1::shared_ptr<const RepositoryNameSet> &,
+ const std::tr1::shared_ptr<const CategoryNamePartSet> &) const
+ {
+ return make_shared_ptr(new QualifiedPackageNameSet);
+ }
+
+ virtual std::tr1::shared_ptr<const PackageIDSet> ids(
+ const Environment * const,
+ const std::tr1::shared_ptr<const RepositoryNameSet> &,
+ const std::tr1::shared_ptr<const QualifiedPackageNameSet> &) const
+ {
+ return make_shared_ptr(new PackageIDSet);
+ }
+
+ virtual std::string as_string() const
+ {
+ return "no packages";
+ }
+ };
}
generator::All::All() :
@@ -714,6 +752,11 @@ generator::Union::Union(const Generator & g1, const Generator & g2) :
{
}
+generator::Nothing::Nothing() :
+ Generator(make_shared_ptr(new NothingGeneratorHandler))
+{
+}
+
template <typename A_>
generator::SomeIDsMightSupportAction<A_>::SomeIDsMightSupportAction() :
Generator(make_shared_ptr(new SomeIDsMightSupportActionGeneratorHandler<A_>))
diff --git a/paludis/generator.hh b/paludis/generator.hh
index fe793f0..2b5dda0 100644
--- a/paludis/generator.hh
+++ b/paludis/generator.hh
@@ -255,6 +255,18 @@ namespace paludis
public:
SomeIDsMightSupportAction();
};
+
+ /**
+ * A Generator which returns no PackageIDs.
+ *
+ * \ingroup g_selections
+ */
+ class PALUDIS_VISIBLE Nothing :
+ public Generator
+ {
+ public:
+ Nothing();
+ };
}
#ifdef PALUDIS_HAVE_EXTERN_TEMPLATE