aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-05-27 21:57:40 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-05-27 21:57:40 +0000
commitf4ebe045f1145b284970baa1917433777945115f (patch)
treef712935fdac36c141bf5e26e613225f616019812
parent98891f1b7a9644f3ed8c60468434c7bb382243de (diff)
downloadpaludis-f4ebe045f1145b284970baa1917433777945115f.tar.gz
paludis-f4ebe045f1145b284970baa1917433777945115f.tar.xz
Split up DepList some more
-rw-r--r--paludis/dep_list/Makefile.am4
-rw-r--r--paludis/dep_list/dep_list.cc69
-rw-r--r--paludis/dep_list/dep_list.hh15
-rw-r--r--paludis/dep_list/show_suggest_visitor.cc99
-rw-r--r--paludis/dep_list/show_suggest_visitor.hh53
5 files changed, 163 insertions, 77 deletions
diff --git a/paludis/dep_list/Makefile.am b/paludis/dep_list/Makefile.am
index 39187b6..86704ea 100644
--- a/paludis/dep_list/Makefile.am
+++ b/paludis/dep_list/Makefile.am
@@ -17,6 +17,7 @@ paludis_dep_list_includedir = $(includedir)/paludis/dep_list
paludis_dep_list_include_HEADERS = \
dep_list.hh \
query_visitor.hh \
+ show_suggest_visitor.hh \
uninstall_list.hh \
exceptions.hh \
options.hh \
@@ -32,7 +33,8 @@ libpaludisdeplist_la_SOURCES = \
dep_list.cc dep_list.hh dep_list-fwd.hh \
uninstall_list.cc uninstall_list.hh \
range_rewriter.cc range_rewriter.hh \
- query_visitor.cc query_visitor.hh
+ query_visitor.cc query_visitor.hh \
+ show_suggest_visitor.cc show_suggest_visitor.hh
libpaludisdeplist_la_LDFLAGS = -version-info @VERSION_LIB_CURRENT@:@VERSION_LIB_REVISION@:0
diff --git a/paludis/dep_list/dep_list.cc b/paludis/dep_list/dep_list.cc
index 5043b94..8db1b9b 100644
--- a/paludis/dep_list/dep_list.cc
+++ b/paludis/dep_list/dep_list.cc
@@ -24,6 +24,7 @@
#include <paludis/dep_list/exceptions.hh>
#include <paludis/dep_list/range_rewriter.hh>
#include <paludis/dep_list/query_visitor.hh>
+#include <paludis/dep_list/show_suggest_visitor.hh>
#include <paludis/match_package.hh>
#include <paludis/query.hh>
#include <paludis/hashed_containers.hh>
@@ -897,72 +898,6 @@ DepList::AddVisitor::visit_leaf(const BlockDepSpec & a)
}
}
-struct DepList::ShowSuggestVisitor :
- ConstVisitor<DependencySpecTree>,
- ConstVisitor<DependencySpecTree>::VisitConstSequence<ShowSuggestVisitor, AnyDepSpec>,
- ConstVisitor<DependencySpecTree>::VisitConstSequence<ShowSuggestVisitor, AllDepSpec>
-{
- DepList * const d;
- tr1::shared_ptr<const DestinationsCollection> destinations;
-
- ShowSuggestVisitor(DepList * const dd, tr1::shared_ptr<const DestinationsCollection> ddd) :
- d(dd),
- destinations(ddd)
- {
- }
-
- void visit_leaf(const BlockDepSpec &);
-
- void visit_leaf(const PackageDepSpec &);
-
- void visit_sequence(const UseDepSpec &,
- DependencySpecTree::ConstSequenceIterator,
- DependencySpecTree::ConstSequenceIterator);
-
- using ConstVisitor<DependencySpecTree>::VisitConstSequence<ShowSuggestVisitor, AllDepSpec>::visit_sequence;
- using ConstVisitor<DependencySpecTree>::VisitConstSequence<ShowSuggestVisitor, AnyDepSpec>::visit_sequence;
-};
-
-void
-DepList::ShowSuggestVisitor::visit_sequence(const UseDepSpec & a,
- DependencySpecTree::ConstSequenceIterator cur,
- DependencySpecTree::ConstSequenceIterator end)
-{
- if ((d->_imp->current_pde() ? d->_imp->env->query_use(a.flag(), *d->_imp->current_pde()) : false) ^ a.inverse())
- std::for_each(cur, end, accept_visitor(*this));
-}
-
-void
-DepList::ShowSuggestVisitor::visit_leaf(const BlockDepSpec &)
-{
-}
-
-void
-DepList::ShowSuggestVisitor::visit_leaf(const PackageDepSpec & a)
-{
- Context context("When adding suggested dep '" + stringify(a) + "':");
-
- tr1::shared_ptr<const PackageDatabaseEntryCollection> matches(d->_imp->env->package_database()->query(
- a, is_installable_only, qo_order_by_version));
- if (matches->empty())
- {
- Log::get_instance()->message(ll_warning, lc_context, "Nothing found for '" + stringify(a) + "'");
- return;
- }
-
- for (PackageDatabaseEntryCollection::Iterator m(matches->begin()), m_end(matches->end()) ;
- m != m_end ; ++m)
- {
- if (d->_imp->env->mask_reasons(*m).any())
- continue;
-
- d->add_suggested_package(*m, destinations);
- return;
- }
-
- Log::get_instance()->message(ll_warning, lc_context, "Nothing visible found for '" + stringify(a) + "'");
-}
-
DepList::DepList(const Environment * const e, const DepListOptions & o) :
PrivateImplementationPattern<DepList>(new Implementation<DepList>(e, o))
{
@@ -1142,7 +1077,7 @@ DepList::add_package(const PackageDatabaseEntry & p, tr1::shared_ptr<const DepTa
Context c("When showing suggestions:");
Save<MergeList::iterator> suggest_save_merge_list_insert_position(&_imp->merge_list_insert_position,
next(our_merge_entry_position));
- ShowSuggestVisitor visitor(this, destinations);
+ ShowSuggestVisitor visitor(this, destinations, _imp->env, _imp->current_pde());
metadata->deps_interface->suggested_depend()->accept(visitor);
}
diff --git a/paludis/dep_list/dep_list.hh b/paludis/dep_list/dep_list.hh
index d25c3bc..28a62a2 100644
--- a/paludis/dep_list/dep_list.hh
+++ b/paludis/dep_list/dep_list.hh
@@ -53,10 +53,7 @@ namespace paludis
{
protected:
class AddVisitor;
- class ShowSuggestVisitor;
-
friend class AddVisitor;
- friend class ShowSuggestVisitor;
/**
* Find an appropriate destination for a package.
@@ -95,12 +92,6 @@ namespace paludis
void add_error_package(const PackageDatabaseEntry &, const DepListEntryKind);
/**
- * Add a suggested package to the list.
- */
- void add_suggested_package(const PackageDatabaseEntry &,
- tr1::shared_ptr<const DestinationsCollection> destinations);
-
- /**
* Add predependencies.
*/
void add_predeps(DependencySpecTree::ConstItem &, const DepListDepsOption, const std::string &,
@@ -181,6 +172,12 @@ namespace paludis
*/
bool has_errors() const;
+ /**
+ * Add a suggested package to the list.
+ */
+ void add_suggested_package(const PackageDatabaseEntry &,
+ tr1::shared_ptr<const DestinationsCollection> destinations);
+
///\name Iterate over our dependency list entries.
///\{
diff --git a/paludis/dep_list/show_suggest_visitor.cc b/paludis/dep_list/show_suggest_visitor.cc
new file mode 100644
index 0000000..792f1f2
--- /dev/null
+++ b/paludis/dep_list/show_suggest_visitor.cc
@@ -0,0 +1,99 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * 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
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/dep_list/show_suggest_visitor.hh>
+#include <paludis/dep_list/dep_list.hh>
+#include <paludis/dep_spec.hh>
+#include <paludis/package_database.hh>
+#include <paludis/util/log.hh>
+#include <paludis/util/visitor-impl.hh>
+
+using namespace paludis;
+
+namespace paludis
+{
+ template <>
+ struct Implementation<ShowSuggestVisitor>
+ {
+ DepList * const dep_list;
+ tr1::shared_ptr<const DestinationsCollection> destinations;
+ const Environment * const environment;
+ const PackageDatabaseEntry * const pde;
+
+ Implementation(DepList * const d, tr1::shared_ptr<const DestinationsCollection> dd,
+ const Environment * const e, const PackageDatabaseEntry * const p) :
+ dep_list(d),
+ destinations(dd),
+ environment(e),
+ pde(p)
+ {
+ }
+ };
+}
+
+ShowSuggestVisitor::ShowSuggestVisitor(DepList * const d, tr1::shared_ptr<const DestinationsCollection> dd,
+ const Environment * const e, const PackageDatabaseEntry * const p) :
+ PrivateImplementationPattern<ShowSuggestVisitor>(new Implementation<ShowSuggestVisitor>(d, dd, e, p))
+{
+}
+
+ShowSuggestVisitor::~ShowSuggestVisitor()
+{
+}
+
+void
+ShowSuggestVisitor::visit_sequence(const UseDepSpec & a,
+ DependencySpecTree::ConstSequenceIterator cur,
+ DependencySpecTree::ConstSequenceIterator end)
+{
+ if ((_imp->pde ? _imp->environment->query_use(a.flag(), *_imp->pde) : false) ^ a.inverse())
+ std::for_each(cur, end, accept_visitor(*this));
+}
+
+void
+ShowSuggestVisitor::visit_leaf(const BlockDepSpec &)
+{
+}
+
+void
+ShowSuggestVisitor::visit_leaf(const PackageDepSpec & a)
+{
+ Context context("When adding suggested dep '" + stringify(a) + "':");
+
+ tr1::shared_ptr<const PackageDatabaseEntryCollection> matches(_imp->environment->package_database()->query(
+ a, is_installable_only, qo_order_by_version));
+ if (matches->empty())
+ {
+ Log::get_instance()->message(ll_warning, lc_context, "Nothing found for '" + stringify(a) + "'");
+ return;
+ }
+
+ for (PackageDatabaseEntryCollection::Iterator m(matches->begin()), m_end(matches->end()) ;
+ m != m_end ; ++m)
+ {
+ if (_imp->environment->mask_reasons(*m).any())
+ continue;
+
+ _imp->dep_list->add_suggested_package(*m, _imp->destinations);
+ return;
+ }
+
+ Log::get_instance()->message(ll_warning, lc_context, "Nothing visible found for '" + stringify(a) + "'");
+}
+
diff --git a/paludis/dep_list/show_suggest_visitor.hh b/paludis/dep_list/show_suggest_visitor.hh
new file mode 100644
index 0000000..9356a8e
--- /dev/null
+++ b/paludis/dep_list/show_suggest_visitor.hh
@@ -0,0 +1,53 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * 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
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_DEP_LIST_SHOW_SUGGEST_VISITOR_HH
+#define PALUDIS_GUARD_PALUDIS_DEP_LIST_SHOW_SUGGEST_VISITOR_HH 1
+
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/dep_list/dep_list-fwd.hh>
+#include <paludis/dep_spec-fwd.hh>
+
+namespace paludis
+{
+ class ShowSuggestVisitor :
+ public ConstVisitor<DependencySpecTree>,
+ public ConstVisitor<DependencySpecTree>::VisitConstSequence<ShowSuggestVisitor, AnyDepSpec>,
+ public ConstVisitor<DependencySpecTree>::VisitConstSequence<ShowSuggestVisitor, AllDepSpec>,
+ private PrivateImplementationPattern<ShowSuggestVisitor>
+ {
+ public:
+ ShowSuggestVisitor(DepList * const dd, tr1::shared_ptr<const DestinationsCollection> ddd,
+ const Environment * const, const PackageDatabaseEntry * const);
+ ~ShowSuggestVisitor();
+
+ void visit_leaf(const BlockDepSpec &);
+
+ void visit_leaf(const PackageDepSpec &);
+
+ void visit_sequence(const UseDepSpec &,
+ DependencySpecTree::ConstSequenceIterator,
+ DependencySpecTree::ConstSequenceIterator);
+
+ using ConstVisitor<DependencySpecTree>::VisitConstSequence<ShowSuggestVisitor, AllDepSpec>::visit_sequence;
+ using ConstVisitor<DependencySpecTree>::VisitConstSequence<ShowSuggestVisitor, AnyDepSpec>::visit_sequence;
+ };
+}
+
+#endif