aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-07-10 12:13:32 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-07-10 12:13:32 +0100
commitf336351f553df7749595109821a1d2892e024e57 (patch)
tree98f57ed5008fc6154820246c29ee4fc61d698e04
parentd5533123d3ba98481049053a474348ff058a6e12 (diff)
downloadpaludis-f336351f553df7749595109821a1d2892e024e57.tar.gz
paludis-f336351f553df7749595109821a1d2892e024e57.tar.xz
Let TargetReason have extra information
-rw-r--r--paludis/resolver/reason.cc33
-rw-r--r--paludis/resolver/reason.hh7
-rw-r--r--paludis/resolver/resolver.cc8
-rw-r--r--paludis/resolver/resolver.hh4
-rw-r--r--paludis/resolver/resolver_test.cc2
-rw-r--r--src/clients/cave/resolve_common.cc6
6 files changed, 49 insertions, 11 deletions
diff --git a/paludis/resolver/reason.cc b/paludis/resolver/reason.cc
index 18353b7..5b6fdac 100644
--- a/paludis/resolver/reason.cc
+++ b/paludis/resolver/reason.cc
@@ -32,10 +32,40 @@ Reason::~Reason()
{
}
+namespace paludis
+{
+ template <>
+ struct Implementation<TargetReason>
+ {
+ const std::string extra_information;
+
+ Implementation(const std::string & x) :
+ extra_information(x)
+ {
+ }
+ };
+}
+
+TargetReason::TargetReason(const std::string & x) :
+ PrivateImplementationPattern<TargetReason>(new Implementation<TargetReason>(x))
+{
+}
+
+TargetReason::~TargetReason()
+{
+}
+
+const std::string
+TargetReason::extra_information() const
+{
+ return _imp->extra_information;
+};
+
void
TargetReason::serialise(Serialiser & s) const
{
s.object("TargetReason")
+ .member(SerialiserFlags<>(), "extra_information", extra_information())
;
}
@@ -362,7 +392,7 @@ Reason::deserialise(Deserialisation & d)
if (d.class_name() == "TargetReason")
{
Deserialisator v(d, "TargetReason");
- return make_shared_ptr(new TargetReason);
+ return make_shared_ptr(new TargetReason(v.member<std::string>("extra_information")));
}
else if (d.class_name() == "PresetReason")
{
@@ -426,6 +456,7 @@ Reason::deserialise(Deserialisation & d)
throw InternalError(PALUDIS_HERE, "unknown class '" + stringify(d.class_name()) + "'");
}
+template class PrivateImplementationPattern<TargetReason>;
template class PrivateImplementationPattern<DependencyReason>;
template class PrivateImplementationPattern<DependentReason>;
template class PrivateImplementationPattern<SetReason>;
diff --git a/paludis/resolver/reason.hh b/paludis/resolver/reason.hh
index 8ccd47e..2f136e4 100644
--- a/paludis/resolver/reason.hh
+++ b/paludis/resolver/reason.hh
@@ -51,10 +51,16 @@ namespace paludis
};
class TargetReason :
+ private PrivateImplementationPattern<TargetReason>,
public Reason,
public ImplementAcceptMethods<Reason, TargetReason>
{
public:
+ TargetReason(const std::string &);
+ ~TargetReason();
+
+ const std::string extra_information() const PALUDIS_ATTRIBUTE((warn_unused_result));
+
virtual void serialise(Serialiser &) const;
};
@@ -171,6 +177,7 @@ namespace paludis
};
}
+ extern template class PrivateImplementationPattern<resolver::TargetReason>;
extern template class PrivateImplementationPattern<resolver::DependencyReason>;
extern template class PrivateImplementationPattern<resolver::DependentReason>;
extern template class PrivateImplementationPattern<resolver::WasUsedByReason>;
diff --git a/paludis/resolver/resolver.cc b/paludis/resolver/resolver.cc
index 1bfc955..fded126 100644
--- a/paludis/resolver/resolver.cc
+++ b/paludis/resolver/resolver.cc
@@ -94,9 +94,9 @@ Resolver::~Resolver()
}
void
-Resolver::add_target(const PackageOrBlockDepSpec & spec)
+Resolver::add_target(const PackageOrBlockDepSpec & spec, const std::string & extra_information)
{
- _imp->decider->add_target_with_reason(spec, make_shared_ptr(new TargetReason));
+ _imp->decider->add_target_with_reason(spec, make_shared_ptr(new TargetReason(extra_information)));
}
namespace
@@ -149,7 +149,7 @@ namespace
}
void
-Resolver::add_target(const SetName & set_name)
+Resolver::add_target(const SetName & set_name, const std::string & extra_information)
{
Context context("When adding set target '" + stringify(set_name) + "':");
_imp->env->trigger_notifier_callback(NotifierCallbackResolverStepEvent());
@@ -159,7 +159,7 @@ Resolver::add_target(const SetName & set_name)
throw NoSuchSetError(stringify(set_name));
RecursingNames recurse;
- set->root()->accept(SetExpander(_imp->env, _imp->decider, make_shared_ptr(new TargetReason), recurse));
+ set->root()->accept(SetExpander(_imp->env, _imp->decider, make_shared_ptr(new TargetReason(extra_information)), recurse));
}
void
diff --git a/paludis/resolver/resolver.hh b/paludis/resolver/resolver.hh
index 443b88e..0515a17 100644
--- a/paludis/resolver/resolver.hh
+++ b/paludis/resolver/resolver.hh
@@ -51,8 +51,8 @@ namespace paludis
const ResolverFunctions &);
~Resolver();
- void add_target(const PackageOrBlockDepSpec &);
- void add_target(const SetName &);
+ void add_target(const PackageOrBlockDepSpec &, const std::string & extra_information);
+ void add_target(const SetName &, const std::string & extra_information);
void purge();
void resolve();
diff --git a/paludis/resolver/resolver_test.cc b/paludis/resolver/resolver_test.cc
index ef297f0..c6e15db 100644
--- a/paludis/resolver/resolver_test.cc
+++ b/paludis/resolver/resolver_test.cc
@@ -412,7 +412,7 @@ ResolverTestCase::get_resolved(const PackageOrBlockDepSpec & target)
try
{
Resolver resolver(&env, get_resolver_functions(initial_constraints));
- resolver.add_target(target);
+ resolver.add_target(target, "");
resolver.resolve();
return resolver.resolved();
}
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index 6b7b900..19ac6c5 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -274,14 +274,14 @@ namespace
PackageDepSpec s(parse_user_package_dep_spec(p->substr(1), env.get(), UserPackageDepSpecOptions()));
BlockDepSpec bs("!" + stringify(s), s, false);
result->push_back(stringify(bs));
- resolver->add_target(bs);
+ resolver->add_target(bs, "");
}
else
{
PackageDepSpec s(parse_user_package_dep_spec(*p, env.get(),
UserPackageDepSpecOptions() + updso_throw_if_set));
result->push_back(stringify(s));
- resolver->add_target(s);
+ resolver->add_target(s, "");
seen_packages = true;
}
}
@@ -290,7 +290,7 @@ namespace
if (seen_sets)
throw args::DoHelp("Cannot specify multiple set targets");
- resolver->add_target(SetName(*p));
+ resolver->add_target(SetName(*p), "");
result->push_back(*p);
seen_sets = true;
}