aboutsummaryrefslogtreecommitdiff
path: root/paludis/resolver/reason_utils.cc
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-08 15:35:02 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-08 15:35:02 +0100
commitb4ab443375d5f8848e4084cd408dbb753fcaf771 (patch)
tree08400dc71612a36ebd6ffb5e0862bd5514d073cf /paludis/resolver/reason_utils.cc
parent391a11571d99f0b9ccb030381c32dd9a36721f37 (diff)
downloadpaludis-b4ab443375d5f8848e4084cd408dbb753fcaf771.tar.gz
paludis-b4ab443375d5f8848e4084cd408dbb753fcaf771.tar.xz
GetResolventsForHelper
Diffstat (limited to 'paludis/resolver/reason_utils.cc')
-rw-r--r--paludis/resolver/reason_utils.cc78
1 files changed, 78 insertions, 0 deletions
diff --git a/paludis/resolver/reason_utils.cc b/paludis/resolver/reason_utils.cc
new file mode 100644
index 000000000..063bd7703
--- /dev/null
+++ b/paludis/resolver/reason_utils.cc
@@ -0,0 +1,78 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2010 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/reason_utils.hh>
+#include <paludis/resolver/reason.hh>
+
+using namespace paludis;
+using namespace paludis::resolver;
+
+namespace
+{
+ struct IsTargetVisitor
+ {
+ bool visit(const DependencyReason &) const
+ {
+ return false;
+ }
+
+ bool visit(const DependentReason &) const
+ {
+ return false;
+ }
+
+ bool visit(const WasUsedByReason &) const
+ {
+ return false;
+ }
+
+ bool visit(const PresetReason &) const
+ {
+ return false;
+ }
+
+ bool visit(const ViaBinaryReason &) const
+ {
+ return false;
+ }
+
+ bool visit(const TargetReason &) const
+ {
+ return true;
+ }
+
+ bool visit(const LikeOtherDestinationTypeReason & r) const
+ {
+ return r.reason_for_other()->accept_returning<bool>(*this);
+ }
+
+ bool visit(const SetReason & r) const
+ {
+ return r.reason_for_set()->accept_returning<bool>(*this);
+ }
+ };
+}
+
+bool
+paludis::resolver::is_target(const std::shared_ptr<const Reason> & reason)
+{
+ IsTargetVisitor v;
+ return reason->accept_returning<bool>(v);
+}
+