[gimp/gimp-2-10] app: in gimppaintcore-loops, allow specifying dependencies to BasicDispatch
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] app: in gimppaintcore-loops, allow specifying dependencies to BasicDispatch
- Date: Tue, 12 Feb 2019 14:29:24 +0000 (UTC)
commit 470f760eee9d18e2256820651f369bd75cb38d12
Author: Ell <ell_se yahoo com>
Date: Mon Feb 11 15:40:56 2019 -0500
app: in gimppaintcore-loops, allow specifying dependencies to BasicDispatch
... which are dispatched before the algorithm, as in
AlgorithmDispatch.
(cherry picked from commit 2788444df4d1849cbb7041e144e37253da834def)
app/paint/gimppaintcore-loops.cc | 38 ++++++++++++++++++++++++++++++++++----
1 file changed, 34 insertions(+), 4 deletions(-)
---
diff --git a/app/paint/gimppaintcore-loops.cc b/app/paint/gimppaintcore-loops.cc
index 604943daee..eadd102c75 100644
--- a/app/paint/gimppaintcore-loops.cc
+++ b/app/paint/gimppaintcore-loops.cc
@@ -370,16 +370,46 @@ struct AlgorithmBase
* A class template implementing a simple dispatch function object, which adds
* an algorithm to the hierarchy unconditionally. 'AlgorithmTemplate' is the
* alogithm class template (usually a helper class, rather than an actual
- * algorithm), and 'Mask' is the dispatch function mask, as described in
- * 'dispatch()'.
+ * algorithm), 'Mask' is the dispatch function mask, as described in
+ * 'dispatch()', and 'Dependencies' is a list of (types of) dispatch functions
+ * the algorithm depends on.
+ *
+ * Before adding the algorithm to the hierarchy, the hierarchy is augmented by
+ * dispatching through the list of dependencies, in order.
*/
template <template <class Base> class AlgorithmTemplate,
- guint Mask>
+ guint Mask,
+ class... Dependencies>
struct BasicDispatch
{
static constexpr guint mask = Mask;
+ template <class Visitor,
+ class Algorithm>
+ void
+ operator () (Visitor visitor,
+ const GimpPaintCoreLoopsParams *params,
+ GimpPaintCoreLoopsAlgorithm algorithms,
+ identity<Algorithm> algorithm) const
+ {
+ dispatch (
+ [&] (auto algorithm)
+ {
+ using NewAlgorithm = typename decltype (algorithm)::type;
+
+ visitor (identity<AlgorithmTemplate<NewAlgorithm>> ());
+ },
+ params, algorithms, algorithm, Dependencies ()...);
+ }
+};
+
+template <template <class Base> class AlgorithmTemplate,
+ guint Mask>
+struct BasicDispatch<AlgorithmTemplate, Mask>
+{
+ static constexpr guint mask = Mask;
+
template <class Visitor,
class Algorithm>
void
@@ -398,7 +428,7 @@ struct BasicDispatch
* A class template implementing a dispatch function suitable for dispatching
* algorithms. 'AlgorithmTemplate' is the algorithm class template, 'Mask' is
* the dispatch function mask, as described in 'dispatch()', and 'Dependencies'
- * is a list of (types of) dispatch functions the algorithm depends on, usd as
+ * is a list of (types of) dispatch functions the algorithm depends on, used as
* explained below.
*
* 'AlgorithmDispatch' adds the algorithm to the hierarchy if it's included in
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]