aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-08-25 03:10:33 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-08-25 21:56:23 +0100
commit750706b13dc94fce3153093fea502141ff86be92 (patch)
tree27be963ef0971bd0a13abe91d90d18498683894d
parentefe1d56f129dea213603e2f2b58c14e529f2695f (diff)
downloadpaludis-750706b13dc94fce3153093fea502141ff86be92.tar.gz
paludis-750706b13dc94fce3153093fea502141ff86be92.tar.xz
split out resolutions
-rw-r--r--paludis/resolver/Makefile.am2
-rw-r--r--paludis/resolver/resolutions-fwd.hh31
-rw-r--r--paludis/resolver/resolutions.cc66
-rw-r--r--paludis/resolver/resolutions.hh57
-rw-r--r--paludis/resolver/resolver.cc28
-rw-r--r--paludis/resolver/resolver.hh7
-rw-r--r--src/clients/cave/cmd_resolve_display_resolution.cc3
7 files changed, 171 insertions, 23 deletions
diff --git a/paludis/resolver/Makefile.am b/paludis/resolver/Makefile.am
index 33b18e7..01296c4 100644
--- a/paludis/resolver/Makefile.am
+++ b/paludis/resolver/Makefile.am
@@ -18,6 +18,7 @@ noinst_HEADERS = \
qpn_s.hh qpn_s-fwd.hh \
reason.hh reason-fwd.hh \
resolution.hh resolution-fwd.hh \
+ resolutions.hh resolutions-fwd.hh \
resolver.hh resolver-fwd.hh \
resolver_functions.hh resolver_functions-fwd.hh \
sanitised_dependencies.hh sanitised_dependencies-fwd.hh \
@@ -32,6 +33,7 @@ libpaludisresolver_a_SOURCES = \
qpn_s.cc \
reason.cc \
resolution.cc \
+ resolutions.cc \
resolver.cc \
sanitised_dependencies.cc \
suggest_restart.cc \
diff --git a/paludis/resolver/resolutions-fwd.hh b/paludis/resolver/resolutions-fwd.hh
new file mode 100644
index 0000000..4ecdefd
--- /dev/null
+++ b/paludis/resolver/resolutions-fwd.hh
@@ -0,0 +1,31 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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_RESOLVER_RESOLUTIONS_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_RESOLUTIONS_FWD_HH 1
+
+namespace paludis
+{
+ namespace resolver
+ {
+ struct Resolutions;
+ }
+}
+
+#endif
diff --git a/paludis/resolver/resolutions.cc b/paludis/resolver/resolutions.cc
new file mode 100644
index 0000000..37dcca4
--- /dev/null
+++ b/paludis/resolver/resolutions.cc
@@ -0,0 +1,66 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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/resolver/resolutions.hh>
+#include <paludis/util/wrapped_forward_iterator-impl.hh>
+#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <list>
+
+using namespace paludis;
+using namespace paludis::resolver;
+
+namespace paludis
+{
+ template <>
+ struct Implementation<Resolutions>
+ {
+ std::list<std::tr1::shared_ptr<const Resolution> > resolutions;
+ };
+}
+
+Resolutions::Resolutions() :
+ PrivateImplementationPattern<Resolutions>(new Implementation<Resolutions>)
+{
+}
+
+Resolutions::~Resolutions()
+{
+}
+
+void
+Resolutions::append(const std::tr1::shared_ptr<const Resolution> & r)
+{
+ _imp->resolutions.push_back(r);
+}
+
+Resolutions::ConstIterator
+Resolutions::begin() const
+{
+ return ConstIterator(_imp->resolutions.begin());
+}
+
+Resolutions::ConstIterator
+Resolutions::end() const
+{
+ return ConstIterator(_imp->resolutions.end());
+}
+
+template class PrivateImplementationPattern<Resolutions>;
+template class WrappedForwardIterator<Resolutions::ConstIteratorTag, const std::tr1::shared_ptr<const Resolution> >;
+
diff --git a/paludis/resolver/resolutions.hh b/paludis/resolver/resolutions.hh
new file mode 100644
index 0000000..a2af9f4
--- /dev/null
+++ b/paludis/resolver/resolutions.hh
@@ -0,0 +1,57 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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_RESOLVER_RESOLUTIONS_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_RESOLUTIONS_HH 1
+
+#include <paludis/resolver/resolutions-fwd.hh>
+#include <paludis/resolver/resolution-fwd.hh>
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/attributes.hh>
+#include <paludis/util/wrapped_forward_iterator-fwd.hh>
+#include <tr1/memory>
+
+namespace paludis
+{
+ namespace resolver
+ {
+ class PALUDIS_VISIBLE Resolutions :
+ private PrivateImplementationPattern<Resolutions>
+ {
+ public:
+ Resolutions();
+ ~Resolutions();
+
+ void append(const std::tr1::shared_ptr<const Resolution> &);
+
+ struct ConstIteratorTag;
+ typedef WrappedForwardIterator<ConstIteratorTag,
+ const std::tr1::shared_ptr<const Resolution> > ConstIterator;
+ ConstIterator begin() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ ConstIterator end() const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ };
+ }
+
+#ifdef PALUDIS_HAVE_EXTERN_TEMPLATE
+ extern template class PrivateImplementationPattern<resolver::Resolutions>;
+#endif
+}
+
+#endif
diff --git a/paludis/resolver/resolver.cc b/paludis/resolver/resolver.cc
index 0b74dac..70e964e 100644
--- a/paludis/resolver/resolver.cc
+++ b/paludis/resolver/resolver.cc
@@ -28,6 +28,7 @@
#include <paludis/resolver/destinations.hh>
#include <paludis/resolver/resolver_functions.hh>
#include <paludis/resolver/suggest_restart.hh>
+#include <paludis/resolver/resolutions.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/log.hh>
@@ -60,7 +61,6 @@ using namespace paludis;
using namespace paludis::resolver;
typedef std::map<QPN_S, std::tr1::shared_ptr<Resolution> > ResolutionsByQPN_SMap;
-typedef std::list<std::tr1::shared_ptr<const Resolution> > OrderedResolutionsList;
namespace paludis
{
@@ -71,11 +71,12 @@ namespace paludis
const ResolverFunctions fns;
ResolutionsByQPN_SMap resolutions_by_qpn_s;
- OrderedResolutionsList ordered_resolutions;
+ std::tr1::shared_ptr<Resolutions> resolutions;
Implementation(const Environment * const e, const ResolverFunctions & f) :
env(e),
- fns(f)
+ fns(f),
+ resolutions(new Resolutions)
{
}
};
@@ -805,7 +806,7 @@ Resolver::_can_order_now(const QPN_S &, const std::tr1::shared_ptr<const Resolut
void
Resolver::_do_order(const QPN_S &, const std::tr1::shared_ptr<Resolution> & resolution)
{
- _imp->ordered_resolutions.push_back(resolution);
+ _imp->resolutions->append(resolution);
resolution->already_ordered() = true;
}
@@ -848,18 +849,6 @@ Resolver::_dependency_to_destination_slash(const QPN_S &, const SanitisedDepende
return true;
}
-Resolver::ConstIterator
-Resolver::begin() const
-{
- return ConstIterator(_imp->ordered_resolutions.begin());
-}
-
-Resolver::ConstIterator
-Resolver::end() const
-{
- return ConstIterator(_imp->ordered_resolutions.end());
-}
-
Resolver::ResolutionsByQPN_SConstIterator
Resolver::begin_resolutions_by_qpn_s() const
{
@@ -1307,7 +1296,12 @@ Resolver::_find_id_for_from(
return make_null_shared_ptr();
}
-template class WrappedForwardIterator<Resolver::ConstIteratorTag, const std::tr1::shared_ptr<const Resolution> >;
+const std::tr1::shared_ptr<const Resolutions>
+Resolver::resolutions() const
+{
+ return _imp->resolutions;
+}
+
template class WrappedForwardIterator<Resolver::ResolutionsByQPN_SConstIteratorTag,
const std::pair<const QPN_S, std::tr1::shared_ptr<Resolution> > >;
diff --git a/paludis/resolver/resolver.hh b/paludis/resolver/resolver.hh
index 028b3e6..12861e5 100644
--- a/paludis/resolver/resolver.hh
+++ b/paludis/resolver/resolver.hh
@@ -29,6 +29,7 @@
#include <paludis/resolver/reason-fwd.hh>
#include <paludis/resolver/use_installed-fwd.hh>
#include <paludis/resolver/destinations-fwd.hh>
+#include <paludis/resolver/resolutions-fwd.hh>
#include <paludis/resolver/resolver_functions-fwd.hh>
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/wrapped_forward_iterator-fwd.hh>
@@ -152,11 +153,7 @@ namespace paludis
void resolve();
- struct ConstIteratorTag;
- typedef WrappedForwardIterator<ConstIteratorTag,
- const std::tr1::shared_ptr<const Resolution> > ConstIterator;
- ConstIterator begin() const PALUDIS_ATTRIBUTE((warn_unused_result));
- ConstIterator end() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ const std::tr1::shared_ptr<const Resolutions> resolutions() const PALUDIS_ATTRIBUTE((warn_unused_result));
struct ResolutionsByQPN_SConstIteratorTag;
typedef WrappedForwardIterator<ResolutionsByQPN_SConstIteratorTag,
diff --git a/src/clients/cave/cmd_resolve_display_resolution.cc b/src/clients/cave/cmd_resolve_display_resolution.cc
index fee954b..5cc2a8b 100644
--- a/src/clients/cave/cmd_resolve_display_resolution.cc
+++ b/src/clients/cave/cmd_resolve_display_resolution.cc
@@ -26,6 +26,7 @@
#include <paludis/resolver/destinations.hh>
#include <paludis/resolver/constraint.hh>
#include <paludis/resolver/reason.hh>
+#include <paludis/resolver/resolutions.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/simple_visitor_cast.hh>
#include <paludis/util/join.hh>
@@ -78,7 +79,7 @@ paludis::cave::display_resolution(
std::cout << "These are the actions I will take, in order:" << std::endl << std::endl;
- for (Resolver::ConstIterator c(resolver->begin()), c_end(resolver->end()) ;
+ for (Resolutions::ConstIterator c(resolver->resolutions()->begin()), c_end(resolver->resolutions()->end()) ;
c != c_end ; ++c)
{
const std::tr1::shared_ptr<const PackageID> id((*c)->decision()->if_package_id());