aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-06-12 20:25:35 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-06-12 20:25:35 +0100
commitd0f0c51bc9f2e32436c17bb7ec1d27844d2b852e (patch)
tree09ce80a657356dab751cbeb79b243f9cc9aa240b
parent5dbb7636dd880314d5b03379ebfd960b469ee6e9 (diff)
downloadpaludis-d0f0c51bc9f2e32436c17bb7ec1d27844d2b852e.tar.gz
paludis-d0f0c51bc9f2e32436c17bb7ec1d27844d2b852e.tar.xz
Give SlotNameOrNull its own header
-rw-r--r--paludis/resolver/Makefile.am10
-rw-r--r--paludis/resolver/resolvent-fwd.hh5
-rw-r--r--paludis/resolver/resolvent.cc58
-rw-r--r--paludis/resolver/resolvent.hh19
-rw-r--r--paludis/resolver/slot_name_or_null-fwd.hh38
-rw-r--r--paludis/resolver/slot_name_or_null.cc86
-rw-r--r--paludis/resolver/slot_name_or_null.hh51
7 files changed, 186 insertions, 81 deletions
diff --git a/paludis/resolver/Makefile.am b/paludis/resolver/Makefile.am
index 17af9bb..99051ed 100644
--- a/paludis/resolver/Makefile.am
+++ b/paludis/resolver/Makefile.am
@@ -29,15 +29,15 @@ noinst_HEADERS = \
arrow.hh arrow-fwd.hh \
change_type.hh change_type-fwd.hh change_type-se.hh \
constraint.hh constraint-fwd.hh \
- job.hh job-fwd.hh \
- job_id.hh job_id-fwd.hh \
- job_state.hh job_state-fwd.hh \
- jobs.hh jobs-fwd.hh \
decider.hh decider-fwd.hh \
decision.hh decision-fwd.hh \
destination.hh destination-fwd.hh \
destination_types.hh destination_types-fwd.hh destination_types-se.hh \
failure_kinds.hh failure_kinds-fwd.hh failure_kinds-se.hh \
+ job.hh job-fwd.hh \
+ job_id.hh job_id-fwd.hh \
+ job_state.hh job_state-fwd.hh \
+ jobs.hh jobs-fwd.hh \
orderer.hh orderer-fwd.hh \
reason.hh reason-fwd.hh \
required_confirmations.hh required_confirmations-fwd.hh \
@@ -48,6 +48,7 @@ noinst_HEADERS = \
resolver_functions.hh resolver_functions-fwd.hh \
resolver_lists.hh resolver_lists-fwd.hh \
sanitised_dependencies.hh sanitised_dependencies-fwd.hh \
+ slot_name_or_null.hh slot_name_or_null-fwd.hh \
spec_rewriter.hh spec_rewriter-fwd.hh \
suggest_restart.hh suggest_restart-fwd.hh \
unsuitable_candidates.hh unsuitable_candidates-fwd.hh \
@@ -77,6 +78,7 @@ libpaludisresolver_a_SOURCES = \
resolver_functions.cc \
resolver_lists.cc \
sanitised_dependencies.cc \
+ slot_name_or_null.cc \
spec_rewriter.cc \
suggest_restart.cc \
unsuitable_candidates.cc \
diff --git a/paludis/resolver/resolvent-fwd.hh b/paludis/resolver/resolvent-fwd.hh
index bde7db0..494763a 100644
--- a/paludis/resolver/resolvent-fwd.hh
+++ b/paludis/resolver/resolvent-fwd.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
@@ -35,13 +35,10 @@ namespace paludis
typedef Sequence<Resolvent> Resolvents;
std::ostream & operator<< (std::ostream &, const Resolvent &) PALUDIS_VISIBLE;
- std::ostream & operator<< (std::ostream &, const SlotNameOrNull &) PALUDIS_VISIBLE;
bool operator< (const Resolvent &, const Resolvent &) PALUDIS_ATTRIBUTE((warn_unused_result)) PALUDIS_VISIBLE;
bool operator== (const Resolvent &, const Resolvent &) PALUDIS_ATTRIBUTE((warn_unused_result)) PALUDIS_VISIBLE;
- bool operator== (const SlotNameOrNull &, const SlotNameOrNull &) PALUDIS_ATTRIBUTE((warn_unused_result)) PALUDIS_VISIBLE;
-
Filter make_slot_filter(const Resolvent &) PALUDIS_ATTRIBUTE((warn_unused_result)) PALUDIS_VISIBLE;
}
}
diff --git a/paludis/resolver/resolvent.cc b/paludis/resolver/resolvent.cc
index 1190e0a..d28c855 100644
--- a/paludis/resolver/resolvent.cc
+++ b/paludis/resolver/resolvent.cc
@@ -75,21 +75,6 @@ paludis::resolver::operator== (const Resolvent & a, const Resolvent & b)
return true;
}
-bool
-paludis::resolver::operator== (const SlotNameOrNull & a, const SlotNameOrNull & b)
-{
- if ((!! a.name_or_null()) != (!! b.name_or_null()))
- return false;
-
- if ((a.name_or_null()) && (*a.name_or_null() != *b.name_or_null()))
- return false;
-
- if ((! a.name_or_null()) && (a.null_means_unknown() != b.null_means_unknown()))
- return false;
-
- return true;
-}
-
#ifdef PALUDIS_HAVE_DEFAULT_DELETED
Resolvent::Resolvent(const Resolvent &) = default;
@@ -212,55 +197,12 @@ paludis::resolver::make_slot_filter(const Resolvent & r)
}
std::ostream &
-paludis::resolver::operator<< (std::ostream & s, const SlotNameOrNull & n)
-{
- if (n.name_or_null())
- s << ":" << *n.name_or_null();
- else if (n.null_means_unknown())
- s << ":(unknown)";
- else
- s << ":(no slot)";
- return s;
-}
-
-std::ostream &
paludis::resolver::operator<< (std::ostream & s, const Resolvent & r)
{
s << r.package() << r.slot() << "::(" << r.destination_type() << ")";
return s;
}
-void
-SlotNameOrNull::serialise(Serialiser & s) const
-{
- s.object("SlotNameOrNull")
- .member(SerialiserFlags<>(), "name_or_null", name_or_null() ? stringify(*name_or_null()) : "")
- .member(SerialiserFlags<>(), "null_means_unknown", null_means_unknown())
- ;
-}
-
-const SlotNameOrNull
-SlotNameOrNull::deserialise(Deserialisation & d)
-{
- Deserialisator v(d, "SlotNameOrNull");
-
- std::string s(v.member<std::string>("name_or_null"));
-
- return make_named_values<SlotNameOrNull>(
- n::name_or_null() = s.empty() ? make_null_shared_ptr() : make_shared_ptr(new SlotName(s)),
- n::null_means_unknown() = v.member<bool>("null_means_unknown")
- );
-}
-
-std::size_t
-SlotNameOrNull::hash() const
-{
- if (name_or_null())
- return Hash<SlotName>()(*name_or_null());
- else
- return 0xdeadbeef;
-}
-
template class Sequence<Resolvent>;
template class WrappedForwardIterator<Resolvents::ConstIteratorTag, const Resolvent>;
diff --git a/paludis/resolver/resolvent.hh b/paludis/resolver/resolvent.hh
index fc9e9c4..e06e33a 100644
--- a/paludis/resolver/resolvent.hh
+++ b/paludis/resolver/resolvent.hh
@@ -22,11 +22,13 @@
#include <paludis/resolver/resolvent-fwd.hh>
#include <paludis/resolver/destination_types-fwd.hh>
-#include <paludis/serialise-fwd.hh>
+#include <paludis/resolver/destination_types-fwd.hh>
+#include <paludis/resolver/slot_name_or_null.hh>
#include <paludis/util/named_value.hh>
-#include <paludis/name.hh>
+#include <paludis/serialise-fwd.hh>
#include <paludis/dep_spec-fwd.hh>
#include <paludis/package_id-fwd.hh>
+#include <paludis/name.hh>
#include <tr1/memory>
namespace paludis
@@ -34,25 +36,12 @@ namespace paludis
namespace n
{
typedef Name<struct destination_type_name> destination_type;
- typedef Name<struct name_or_null_name> name_or_null;
- typedef Name<struct null_means_unknown_name> null_means_unknown;
typedef Name<struct package_name> package;
typedef Name<struct slot_name> slot;
}
namespace resolver
{
- struct SlotNameOrNull
- {
- NamedValue<n::name_or_null, std::tr1::shared_ptr<const SlotName> > name_or_null;
- NamedValue<n::null_means_unknown, bool> null_means_unknown;
-
- void serialise(Serialiser &) const;
- static const SlotNameOrNull deserialise(Deserialisation &) PALUDIS_ATTRIBUTE((warn_unused_result));
-
- std::size_t hash() const PALUDIS_ATTRIBUTE((warn_unused_result));
- };
-
struct Resolvent
{
NamedValue<n::destination_type, DestinationType> destination_type;
diff --git a/paludis/resolver/slot_name_or_null-fwd.hh b/paludis/resolver/slot_name_or_null-fwd.hh
new file mode 100644
index 0000000..e27f8db
--- /dev/null
+++ b/paludis/resolver/slot_name_or_null-fwd.hh
@@ -0,0 +1,38 @@
+/* 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
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_RESOLVER_SLOT_NAME_OR_NULL_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_SLOT_NAME_OR_NULL_FWD_HH 1
+
+#include <paludis/util/attributes.hh>
+#include <iosfwd>
+
+namespace paludis
+{
+ namespace resolver
+ {
+ struct SlotNameOrNull;
+
+ std::ostream & operator<< (std::ostream &, const SlotNameOrNull &) PALUDIS_VISIBLE;
+
+ bool operator== (const SlotNameOrNull &, const SlotNameOrNull &) PALUDIS_ATTRIBUTE((warn_unused_result)) PALUDIS_VISIBLE;
+ }
+}
+
+#endif
diff --git a/paludis/resolver/slot_name_or_null.cc b/paludis/resolver/slot_name_or_null.cc
new file mode 100644
index 0000000..bbf0076
--- /dev/null
+++ b/paludis/resolver/slot_name_or_null.cc
@@ -0,0 +1,86 @@
+/* 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/slot_name_or_null.hh>
+#include <paludis/util/make_named_values.hh>
+#include <paludis/util/hashes.hh>
+#include <paludis/serialise-impl.hh>
+#include <ostream>
+
+using namespace paludis;
+using namespace paludis::resolver;
+
+bool
+paludis::resolver::operator== (const SlotNameOrNull & a, const SlotNameOrNull & b)
+{
+ if ((!! a.name_or_null()) != (!! b.name_or_null()))
+ return false;
+
+ if ((a.name_or_null()) && (*a.name_or_null() != *b.name_or_null()))
+ return false;
+
+ if ((! a.name_or_null()) && (a.null_means_unknown() != b.null_means_unknown()))
+ return false;
+
+ return true;
+}
+
+std::ostream &
+paludis::resolver::operator<< (std::ostream & s, const SlotNameOrNull & n)
+{
+ if (n.name_or_null())
+ s << ":" << *n.name_or_null();
+ else if (n.null_means_unknown())
+ s << ":(unknown)";
+ else
+ s << ":(no slot)";
+ return s;
+}
+
+void
+SlotNameOrNull::serialise(Serialiser & s) const
+{
+ s.object("SlotNameOrNull")
+ .member(SerialiserFlags<>(), "name_or_null", name_or_null() ? stringify(*name_or_null()) : "")
+ .member(SerialiserFlags<>(), "null_means_unknown", null_means_unknown())
+ ;
+}
+
+const SlotNameOrNull
+SlotNameOrNull::deserialise(Deserialisation & d)
+{
+ Deserialisator v(d, "SlotNameOrNull");
+
+ std::string s(v.member<std::string>("name_or_null"));
+
+ return make_named_values<SlotNameOrNull>(
+ n::name_or_null() = s.empty() ? make_null_shared_ptr() : make_shared_ptr(new SlotName(s)),
+ n::null_means_unknown() = v.member<bool>("null_means_unknown")
+ );
+}
+
+std::size_t
+SlotNameOrNull::hash() const
+{
+ if (name_or_null())
+ return Hash<SlotName>()(*name_or_null());
+ else
+ return 0xdeadbeef;
+}
+
diff --git a/paludis/resolver/slot_name_or_null.hh b/paludis/resolver/slot_name_or_null.hh
new file mode 100644
index 0000000..669aa79
--- /dev/null
+++ b/paludis/resolver/slot_name_or_null.hh
@@ -0,0 +1,51 @@
+/* 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
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_RESOLVER_SLOT_NAME_OR_NULL_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_SLOT_NAME_OR_NULL_HH 1
+
+#include <paludis/resolver/slot_name_or_null-fwd.hh>
+#include <paludis/util/named_value.hh>
+#include <paludis/serialise-fwd.hh>
+#include <paludis/name.hh>
+
+namespace paludis
+{
+ namespace n
+ {
+ typedef Name<struct name_or_null_name> name_or_null;
+ typedef Name<struct null_means_unknown_name> null_means_unknown;
+ }
+
+ namespace resolver
+ {
+ struct SlotNameOrNull
+ {
+ NamedValue<n::name_or_null, std::tr1::shared_ptr<const SlotName> > name_or_null;
+ NamedValue<n::null_means_unknown, bool> null_means_unknown;
+
+ void serialise(Serialiser &) const;
+ static const SlotNameOrNull deserialise(Deserialisation &) PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ std::size_t hash() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+ }
+}
+
+#endif