aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-01-24 17:29:23 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-01-24 17:29:23 +0000
commit393899ffc024d98549cc0009fffa22ac5b23ffa4 (patch)
treeab955485c21154b8ce408e8361e37cc79c772dea
parent929360c8b10c2214fcc1cab95f24ecfceb62edbb (diff)
downloadpaludis-393899ffc024d98549cc0009fffa22ac5b23ffa4.tar.gz
paludis-393899ffc024d98549cc0009fffa22ac5b23ffa4.tar.xz
UnableToMakeDecision::deserialise better
-rw-r--r--paludis/resolver/decision.cc38
-rw-r--r--paludis/resolver/decision.hh8
2 files changed, 25 insertions, 21 deletions
diff --git a/paludis/resolver/decision.cc b/paludis/resolver/decision.cc
index d019247..c27a7cf 100644
--- a/paludis/resolver/decision.cc
+++ b/paludis/resolver/decision.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009 Ciaran McCreesh
+ * Copyright (c) 2009, 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
@@ -62,27 +62,11 @@ Decision::deserialise(Deserialisation & d)
}
else if (d.class_name() == "ChangesToMakeDecision")
{
- Deserialisator v(d, "ChangesToMakeDecision");
- return make_shared_ptr(new ChangesToMakeDecision(
- v.member<std::tr1::shared_ptr<const PackageID> >("origin_id"),
- v.member<bool>("best"),
- v.member<bool>("taken"),
- v.member<std::tr1::shared_ptr<const Destination> >("destination")
- ));
+ return ChangesToMakeDecision::deserialise(d);
}
else if (d.class_name() == "UnableToMakeDecision")
{
- Deserialisator v(d, "UnableToMakeDecision");
-
- std::tr1::shared_ptr<UnsuitableCandidates> unsuitable_candidates(new UnsuitableCandidates);
- Deserialisator vv(*v.find_remove_member("unsuitable_candidates"), "c");
- for (int n(1), n_end(vv.member<int>("count") + 1) ; n != n_end ; ++n)
- unsuitable_candidates->push_back(vv.member<UnsuitableCandidate>(stringify(n)));
-
- return make_shared_ptr(new UnableToMakeDecision(
- unsuitable_candidates,
- v.member<bool>("taken")
- ));
+ return UnableToMakeDecision::deserialise(d);
}
else
throw InternalError(PALUDIS_HERE, "unknown class '" + stringify(d.class_name()) + "'");
@@ -100,6 +84,22 @@ ChangesToMakeDecision::deserialise(Deserialisation & d)
));
}
+const std::tr1::shared_ptr<UnableToMakeDecision>
+UnableToMakeDecision::deserialise(Deserialisation & d)
+{
+ Deserialisator v(d, "UnableToMakeDecision");
+
+ std::tr1::shared_ptr<UnsuitableCandidates> unsuitable_candidates(new UnsuitableCandidates);
+ Deserialisator vv(*v.find_remove_member("unsuitable_candidates"), "c");
+ for (int n(1), n_end(vv.member<int>("count") + 1) ; n != n_end ; ++n)
+ unsuitable_candidates->push_back(vv.member<UnsuitableCandidate>(stringify(n)));
+
+ return make_shared_ptr(new UnableToMakeDecision(
+ unsuitable_candidates,
+ v.member<bool>("taken")
+ ));
+}
+
namespace paludis
{
template <>
diff --git a/paludis/resolver/decision.hh b/paludis/resolver/decision.hh
index 95c5da5..026aace 100644
--- a/paludis/resolver/decision.hh
+++ b/paludis/resolver/decision.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009 Ciaran McCreesh
+ * Copyright (c) 2009, 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
@@ -126,7 +126,8 @@ namespace paludis
class PALUDIS_VISIBLE UnableToMakeDecision :
public Decision,
public ImplementAcceptMethods<Decision, UnableToMakeDecision>,
- private PrivateImplementationPattern<UnableToMakeDecision>
+ private PrivateImplementationPattern<UnableToMakeDecision>,
+ public std::tr1::enable_shared_from_this<UnableToMakeDecision>
{
public:
UnableToMakeDecision(
@@ -139,6 +140,9 @@ namespace paludis
virtual void serialise(Serialiser &) const;
const std::tr1::shared_ptr<const UnsuitableCandidates> unsuitable_candidates() const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ static const std::tr1::shared_ptr<UnableToMakeDecision> deserialise(
+ Deserialisation & d) PALUDIS_ATTRIBUTE((warn_unused_result));
};
}