aboutsummaryrefslogtreecommitdiff
path: root/paludis/repositories/virtuals
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-01-09 13:46:00 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-01-09 13:46:00 +0000
commit4231af5178d647d8ad932decfcf6a437bec63365 (patch)
treebb0d7168d1aff08b6c087bd1aca0f42f8a33e1ed /paludis/repositories/virtuals
parent6cf45c1cfa4bf675095a244693b9dbfd5e08daca (diff)
downloadpaludis-4231af5178d647d8ad932decfcf6a437bec63365.tar.gz
paludis-4231af5178d647d8ad932decfcf6a437bec63365.tar.xz
New easier tree visitors
Diffstat (limited to 'paludis/repositories/virtuals')
-rw-r--r--paludis/repositories/virtuals/installed_virtuals_repository.cc3
-rw-r--r--paludis/repositories/virtuals/package_id.cc52
-rw-r--r--paludis/repositories/virtuals/package_id.hh2
-rw-r--r--paludis/repositories/virtuals/virtuals_repository.cc4
4 files changed, 33 insertions, 28 deletions
diff --git a/paludis/repositories/virtuals/installed_virtuals_repository.cc b/paludis/repositories/virtuals/installed_virtuals_repository.cc
index 5f32f546c..bfd3ae8dc 100644
--- a/paludis/repositories/virtuals/installed_virtuals_repository.cc
+++ b/paludis/repositories/virtuals/installed_virtuals_repository.cc
@@ -30,11 +30,12 @@
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/sequence.hh>
#include <paludis/util/set.hh>
-#include <paludis/util/visitor-impl.hh>
#include <paludis/util/map.hh>
#include <paludis/util/mutex.hh>
#include <paludis/util/hashes.hh>
#include <paludis/util/make_named_values.hh>
+#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/util/wrapped_output_iterator.hh>
#include <tr1/functional>
#include <tr1/unordered_map>
diff --git a/paludis/repositories/virtuals/package_id.cc b/paludis/repositories/virtuals/package_id.cc
index 0e7be0456..b6504023c 100644
--- a/paludis/repositories/virtuals/package_id.cc
+++ b/paludis/repositories/virtuals/package_id.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009 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
@@ -23,7 +23,6 @@
#include <paludis/util/stringify.hh>
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
-#include <paludis/util/visitor-impl.hh>
#include <paludis/util/mutex.hh>
#include <paludis/util/hashes.hh>
#include <paludis/util/make_named_values.hh>
@@ -53,30 +52,33 @@ namespace paludis
struct Implementation<VirtualsDepKey>
{
const Environment * const env;
- const std::tr1::shared_ptr<const TreeLeaf<DependencySpecTree, PackageDepSpec> > value;
+ const std::tr1::shared_ptr<DependencySpecTree> value;
const std::tr1::shared_ptr<const DependencyLabelSequence> labels;
+ const std::tr1::shared_ptr<const PackageDepSpec> spec;
Implementation(const Environment * const e, const std::tr1::shared_ptr<const PackageID> & v,
const std::tr1::shared_ptr<const DependencyLabelSequence> & l,
bool exact) :
env(e),
- value(exact ?
- new TreeLeaf<DependencySpecTree, PackageDepSpec>(make_shared_ptr(new PackageDepSpec(
- make_package_dep_spec()
- .package(v->name())
- .version_requirement(make_named_values<VersionRequirement>(
- value_for<n::version_operator>(vo_equal),
- value_for<n::version_spec>(v->version())))
- .slot_requirement(make_shared_ptr(new UserSlotExactRequirement(v->slot())))
- .in_repository(v->repository()->name()))))
+ value(new DependencySpecTree(make_shared_ptr(new AllDepSpec))),
+ labels(l),
+ spec(exact ?
+ make_shared_ptr(new PackageDepSpec(
+ make_package_dep_spec()
+ .package(v->name())
+ .version_requirement(make_named_values<VersionRequirement>(
+ value_for<n::version_operator>(vo_equal),
+ value_for<n::version_spec>(v->version())))
+ .slot_requirement(make_shared_ptr(new UserSlotExactRequirement(v->slot())))
+ .in_repository(v->repository()->name())))
:
- new TreeLeaf<DependencySpecTree, PackageDepSpec>(make_shared_ptr(new PackageDepSpec(
- make_package_dep_spec()
- .package(v->name())
- )))
- ),
- labels(l)
+ make_shared_ptr(new PackageDepSpec(
+ make_package_dep_spec()
+ .package(v->name())
+ ))
+ )
{
+ value->root()->append(spec);
}
};
}
@@ -95,7 +97,7 @@ VirtualsDepKey::~VirtualsDepKey()
{
}
-const std::tr1::shared_ptr<const DependencySpecTree::ConstItem>
+const std::tr1::shared_ptr<const DependencySpecTree>
VirtualsDepKey::value() const
{
return _imp->value;
@@ -106,17 +108,17 @@ VirtualsDepKey::pretty_print(const DependencySpecTree::ItemFormatter & f) const
{
if (_imp->env)
{
- if (! (*_imp->env)[selection::SomeArbitraryVersion(generator::Matches(*_imp->value->item(), MatchPackageOptions()) |
+ if (! (*_imp->env)[selection::SomeArbitraryVersion(generator::Matches(*_imp->spec, MatchPackageOptions()) |
filter::InstalledAtRoot(_imp->env->root()))]->empty())
- return f.format(*_imp->value->item(), format::Installed());
- else if (! (*_imp->env)[selection::SomeArbitraryVersion(generator::Matches(*_imp->value->item(), MatchPackageOptions()) |
+ return f.format(*_imp->spec, format::Installed());
+ else if (! (*_imp->env)[selection::SomeArbitraryVersion(generator::Matches(*_imp->spec, MatchPackageOptions()) |
filter::SupportsAction<InstallAction>() | filter::NotMasked())]->empty())
- return f.format(*_imp->value->item(), format::Installable());
+ return f.format(*_imp->spec, format::Installable());
else
- return f.format(*_imp->value->item(), format::Plain());
+ return f.format(*_imp->spec, format::Plain());
}
else
- return f.format(*_imp->value->item(), format::Plain());
+ return f.format(*_imp->spec, format::Plain());
}
std::string
diff --git a/paludis/repositories/virtuals/package_id.hh b/paludis/repositories/virtuals/package_id.hh
index 094e9d42b..91786a9b0 100644
--- a/paludis/repositories/virtuals/package_id.hh
+++ b/paludis/repositories/virtuals/package_id.hh
@@ -42,7 +42,7 @@ namespace paludis
const bool);
~VirtualsDepKey();
- virtual const std::tr1::shared_ptr<const DependencySpecTree::ConstItem> value() const
+ virtual const std::tr1::shared_ptr<const DependencySpecTree> value() const
PALUDIS_ATTRIBUTE((warn_unused_result));
virtual std::string pretty_print(const DependencySpecTree::ItemFormatter &) const
diff --git a/paludis/repositories/virtuals/virtuals_repository.cc b/paludis/repositories/virtuals/virtuals_repository.cc
index cd9629581..9dd6fca90 100644
--- a/paludis/repositories/virtuals/virtuals_repository.cc
+++ b/paludis/repositories/virtuals/virtuals_repository.cc
@@ -37,15 +37,17 @@
#include <paludis/util/map.hh>
#include <paludis/util/set.hh>
#include <paludis/util/sequence.hh>
-#include <paludis/util/visitor-impl.hh>
#include <paludis/util/mutex.hh>
#include <paludis/util/hashes.hh>
#include <paludis/util/make_named_values.hh>
+#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/util/wrapped_output_iterator.hh>
#include <tr1/functional>
#include <tr1/unordered_map>
#include <vector>
#include <utility>
+#include <algorithm>
using namespace paludis;