aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-07-14 03:20:21 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-07-14 03:28:55 +0100
commit6e9dcfc722b454aa93eaf26c7cd31821f334e8c1 (patch)
treed03cbd772761adc9f541265fa057e0676f49a3a6
parentd36edaf6d906c3a011adf8e304f84677abcd81e3 (diff)
downloadpaludis-6e9dcfc722b454aa93eaf26c7cd31821f334e8c1.tar.gz
paludis-6e9dcfc722b454aa93eaf26c7cd31821f334e8c1.tar.xz
generator::FromRepository and generator::InRepository (continued)
Replace generator::Repository with generator::FromRepository and generator::InRepository, in line with previous.
-rw-r--r--paludis/generator-fwd.hh3
-rw-r--r--paludis/generator.cc62
-rw-r--r--paludis/generator.hh11
-rw-r--r--paludis/generator_TEST.cc4
4 files changed, 68 insertions, 12 deletions
diff --git a/paludis/generator-fwd.hh b/paludis/generator-fwd.hh
index 3a11c27..821c0dd 100644
--- a/paludis/generator-fwd.hh
+++ b/paludis/generator-fwd.hh
@@ -32,7 +32,8 @@ namespace paludis
class All;
class Matches;
class Package;
- class Repository;
+ class FromRepository;
+ class InRepository;
class Category;
class Intersection;
template <typename> class SomeIDsMightSupportAction;
diff --git a/paludis/generator.cc b/paludis/generator.cc
index a199318..ed6210f 100644
--- a/paludis/generator.cc
+++ b/paludis/generator.cc
@@ -34,6 +34,7 @@
#include <paludis/environment.hh>
#include <paludis/package_database.hh>
#include <paludis/package_id.hh>
+#include <paludis/metadata_key.hh>
#include <algorithm>
#include <tr1/functional>
@@ -121,12 +122,12 @@ Generator::as_string() const
namespace
{
- struct RepositoryGeneratorHandler :
+ struct InRepositoryGeneratorHandler :
AllGeneratorHandlerBase
{
const RepositoryName name;
- RepositoryGeneratorHandler(const RepositoryName & n) :
+ InRepositoryGeneratorHandler(const RepositoryName & n) :
name(n)
{
}
@@ -147,6 +148,48 @@ namespace
}
};
+ struct FromRepositoryGeneratorHandler :
+ AllGeneratorHandlerBase
+ {
+ const RepositoryName name;
+
+ FromRepositoryGeneratorHandler(const RepositoryName & n) :
+ name(n)
+ {
+ }
+
+ virtual std::tr1::shared_ptr<const PackageIDSet> ids(
+ const Environment * const env,
+ const std::tr1::shared_ptr<const RepositoryNameSet> & repos,
+ const std::tr1::shared_ptr<const QualifiedPackageNameSet> & qpns) const
+ {
+ std::tr1::shared_ptr<PackageIDSet> result(new PackageIDSet);
+
+ for (RepositoryNameSet::ConstIterator r(repos->begin()), r_end(repos->end()) ;
+ r != r_end ; ++r)
+ {
+ for (QualifiedPackageNameSet::ConstIterator q(qpns->begin()), q_end(qpns->end()) ;
+ q != q_end ; ++q)
+ {
+ std::tr1::shared_ptr<const PackageIDSequence> id(
+ env->package_database()->fetch_repository(*r)->package_ids(*q));
+ for (PackageIDSequence::ConstIterator i(id->begin()), i_end(id->end()) ;
+ i != i_end ; ++i)
+ if ((*i)->from_repositories_key() && ((*i)->from_repositories_key()->value()->end() !=
+ (*i)->from_repositories_key()->value()->find(stringify(name))))
+ result->insert(*i);
+ }
+ }
+
+ return result;
+ }
+
+ virtual std::string as_string() const
+ {
+ return "packages originally from repository " + stringify(name);
+ }
+ };
+
struct CategoryGeneratorHandler :
AllGeneratorHandlerBase
{
@@ -244,12 +287,12 @@ namespace
virtual std::tr1::shared_ptr<const RepositoryNameSet> repositories(
const Environment * const env) const
{
- if (! spec.repository_ptr())
+ if (! spec.in_repository_ptr())
return AllGeneratorHandlerBase::repositories(env);
std::tr1::shared_ptr<RepositoryNameSet> result(new RepositoryNameSet);
- if (env->package_database()->has_repository_named(*spec.repository_ptr()))
- result->insert(*spec.repository_ptr());
+ if (env->package_database()->has_repository_named(*spec.in_repository_ptr()))
+ result->insert(*spec.in_repository_ptr());
return result;
}
@@ -505,8 +548,13 @@ generator::All::All() :
{
}
-generator::Repository::Repository(const RepositoryName & n) :
- Generator(make_shared_ptr(new RepositoryGeneratorHandler(n)))
+generator::InRepository::InRepository(const RepositoryName & n) :
+ Generator(make_shared_ptr(new InRepositoryGeneratorHandler(n)))
+{
+}
+
+generator::FromRepository::FromRepository(const RepositoryName & n) :
+ Generator(make_shared_ptr(new FromRepositoryGeneratorHandler(n)))
{
}
diff --git a/paludis/generator.hh b/paludis/generator.hh
index c60e47f..4f93f02 100644
--- a/paludis/generator.hh
+++ b/paludis/generator.hh
@@ -92,11 +92,18 @@ namespace paludis
Package(const QualifiedPackageName &);
};
- class PALUDIS_VISIBLE Repository :
+ class PALUDIS_VISIBLE FromRepository :
public Generator
{
public:
- Repository(const RepositoryName &);
+ FromRepository(const RepositoryName &);
+ };
+
+ class PALUDIS_VISIBLE InRepository :
+ public Generator
+ {
+ public:
+ InRepository(const RepositoryName &);
};
class PALUDIS_VISIBLE Category :
diff --git a/paludis/generator_TEST.cc b/paludis/generator_TEST.cc
index 4fc5de1..0c096f2 100644
--- a/paludis/generator_TEST.cc
+++ b/paludis/generator_TEST.cc
@@ -214,7 +214,7 @@ namespace test_cases
struct RepositoryGeneratorTestCase : GeneratorTestCaseBase
{
RepositoryGeneratorTestCase() :
- GeneratorTestCaseBase("repository", generator::Repository(RepositoryName("repo1")))
+ GeneratorTestCaseBase("repository", generator::InRepository(RepositoryName("repo1")))
{
}
@@ -229,7 +229,7 @@ namespace test_cases
struct NoRepositoryGeneratorTestCase : GeneratorTestCaseBase
{
NoRepositoryGeneratorTestCase() :
- GeneratorTestCaseBase("no repository", generator::Repository(RepositoryName("repo3")))
+ GeneratorTestCaseBase("no repository", generator::InRepository(RepositoryName("repo3")))
{
}