aboutsummaryrefslogtreecommitdiff
path: root/paludis/resolver/get_destination_types_for_blocker_helper.cc
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2013-05-23 21:00:24 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2013-05-23 21:00:24 +0100
commit8629539830b1521995e798a0404a701e99a6c110 (patch)
tree73f26e69ae00c1c51a6ad2e79c79371da9f2085c /paludis/resolver/get_destination_types_for_blocker_helper.cc
parentf91b6e03c2d84dd8de1b5095b3caae404a3bf510 (diff)
downloadpaludis-8629539830b1521995e798a0404a701e99a6c110.tar.gz
paludis-8629539830b1521995e798a0404a701e99a6c110.tar.xz
Convert to fancy new visitors
Diffstat (limited to 'paludis/resolver/get_destination_types_for_blocker_helper.cc')
-rw-r--r--paludis/resolver/get_destination_types_for_blocker_helper.cc86
1 files changed, 35 insertions, 51 deletions
diff --git a/paludis/resolver/get_destination_types_for_blocker_helper.cc b/paludis/resolver/get_destination_types_for_blocker_helper.cc
index efa9c89d1..3374f6059 100644
--- a/paludis/resolver/get_destination_types_for_blocker_helper.cc
+++ b/paludis/resolver/get_destination_types_for_blocker_helper.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2010, 2011 Ciaran McCreesh
+ * Copyright (c) 2010, 2011, 2013 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
@@ -24,7 +24,6 @@
#include <paludis/resolver/resolution.hh>
#include <paludis/resolver/decision.hh>
#include <paludis/util/pimp-impl.hh>
-#include <paludis/util/visitor_cast.hh>
#include <paludis/util/make_shared_copy.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/stringify.hh>
@@ -67,63 +66,48 @@ GetDestinationTypesForBlockerHelper::set_target_destination_type(const Destinati
_imp->target_destination_type = d;
}
-namespace
-{
- struct DestinationTypesFinder
- {
- const DestinationType target_destination_type;
-
- DestinationTypes visit(const TargetReason &) const
- {
- return { target_destination_type };
- }
-
- DestinationTypes visit(const DependentReason &) const
- {
- return { dt_install_to_slash };
- }
-
- DestinationTypes visit(const ViaBinaryReason &) const
- {
- return { };
- }
-
- DestinationTypes visit(const WasUsedByReason &) const
- {
- return { dt_install_to_slash };
- }
-
- DestinationTypes visit(const DependencyReason &) const
- {
- return { dt_install_to_slash };
- }
-
- DestinationTypes visit(const PresetReason &) const
- {
- return { };
- }
-
- DestinationTypes visit(const LikeOtherDestinationTypeReason & r) const
- {
- return r.reason_for_other()->accept_returning<DestinationTypes>(*this);
- }
-
- DestinationTypes visit(const SetReason & r) const
- {
- return r.reason_for_set()->accept_returning<DestinationTypes>(*this);
- }
- };
-}
-
DestinationTypes
GetDestinationTypesForBlockerHelper::operator() (
const BlockDepSpec &,
const std::shared_ptr<const Reason> & reason) const
{
- return reason->accept_returning<DestinationTypes>(DestinationTypesFinder{_imp->target_destination_type});
+ return reason->make_accept_returning(
+ [&] (const TargetReason &) {
+ return DestinationTypes{ _imp->target_destination_type };
+ },
+
+ [&] (const DependentReason &) {
+ return DestinationTypes{ dt_install_to_slash };
+ },
+
+ [&] (const ViaBinaryReason &) {
+ return DestinationTypes{ };
+ },
+
+ [&] (const WasUsedByReason &) {
+ return DestinationTypes{ dt_install_to_slash };
+ },
+
+ [&] (const DependencyReason &) {
+ return DestinationTypes{ dt_install_to_slash };
+ },
+
+ [&] (const PresetReason &) {
+ return DestinationTypes{ };
+ },
+
+ [&] (const LikeOtherDestinationTypeReason & r, const Revisit<DestinationTypes, Reason> & revisit) {
+ return revisit(*r.reason_for_other());
+ },
+
+ [&] (const SetReason & r, const Revisit<DestinationTypes, Reason> & revisit) {
+ return revisit(*r.reason_for_set());
+ }
+ );
}
namespace paludis
{
template class Pimp<GetDestinationTypesForBlockerHelper>;
}
+