aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--paludis/util/digest_registry.cc22
-rw-r--r--paludis/util/digest_registry.hh10
2 files changed, 30 insertions, 2 deletions
diff --git a/paludis/util/digest_registry.cc b/paludis/util/digest_registry.cc
index ec7ab1e61..6994b8fb1 100644
--- a/paludis/util/digest_registry.cc
+++ b/paludis/util/digest_registry.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2011 David Leverton
+ * Copyright (c) 2011, 2012 David Leverton
*
* 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
@@ -20,6 +20,7 @@
#include <paludis/util/digest_registry.hh>
#include <paludis/util/pimp-impl.hh>
#include <paludis/util/singleton-impl.hh>
+#include <paludis/util/wrapped_forward_iterator-impl.hh>
#include <map>
using namespace paludis;
@@ -32,6 +33,12 @@ namespace
namespace paludis
{
template <>
+ struct WrappedForwardIteratorTraits<DigestRegistry::AlgorithmsConstIteratorTag>
+ {
+ typedef FunctionMap::const_iterator UnderlyingIterator;
+ };
+
+ template <>
struct Imp<DigestRegistry>
{
FunctionMap functions;
@@ -55,6 +62,18 @@ DigestRegistry::get(const std::string & algo) const
return it->second;
}
+DigestRegistry::AlgorithmsConstIterator
+DigestRegistry::begin_algorithms() const
+{
+ return AlgorithmsConstIterator(_imp->functions.begin());
+}
+
+DigestRegistry::AlgorithmsConstIterator
+DigestRegistry::end_algorithms() const
+{
+ return AlgorithmsConstIterator(_imp->functions.end());
+}
+
void
DigestRegistry::register_function(const std::string & algo, const Function & func)
{
@@ -65,6 +84,7 @@ namespace paludis
{
template class Pimp<DigestRegistry>;
template class Singleton<DigestRegistry>;
+ template class WrappedForwardIterator<DigestRegistry::AlgorithmsConstIteratorTag, const std::pair<const std::string, DigestRegistry::Function> >;
}
diff --git a/paludis/util/digest_registry.hh b/paludis/util/digest_registry.hh
index cfa86ceea..cf14fcf8f 100644
--- a/paludis/util/digest_registry.hh
+++ b/paludis/util/digest_registry.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2011 David Leverton
+ * Copyright (c) 2011, 2012 David Leverton
*
* 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
@@ -25,7 +25,9 @@
#include <paludis/util/attributes.hh>
#include <paludis/util/pimp.hh>
#include <paludis/util/singleton.hh>
+#include <paludis/util/wrapped_forward_iterator-fwd.hh>
#include <functional>
+#include <utility>
namespace paludis
{
@@ -39,6 +41,12 @@ namespace paludis
Function get(const std::string & algo) const;
+ struct AlgorithmsConstIteratorTag;
+ typedef WrappedForwardIterator<AlgorithmsConstIteratorTag, const std::pair<const std::string, Function> > AlgorithmsConstIterator;
+
+ AlgorithmsConstIterator begin_algorithms() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ AlgorithmsConstIterator end_algorithms() const PALUDIS_ATTRIBUTE((warn_unused_result));
+
template <typename T_>
class Registration
{