[gimp/gimp-2-10] app: in gimppaintcore-loops, add {Mandatory, Suppressed}AlgorithmDispatch
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] app: in gimppaintcore-loops, add {Mandatory, Suppressed}AlgorithmDispatch
- Date: Sat, 16 Feb 2019 15:04:30 +0000 (UTC)
commit 8b86296979c7c9ea73211e57ae1b276157a8fc27
Author: Ell <ell_se yahoo com>
Date: Sat Feb 16 08:31:09 2019 -0500
app: in gimppaintcore-loops, add {Mandatory,Suppressed}AlgorithmDispatch
In gimppaintcore-loops, add MandatoryAlgorithmDispatch and
SuppressedAlgorithmDispatch class templates, which implement
dispatch functions suitable for algorithms which are always part of
the hierarchy, or never part of the hierarchy, respectively. Using
one of these classes as the dispatch function for a given algorithm
verifies that the algorithm is/isn't included in the requested-
algorithm set, but doesn't otherwise increase the number of
instanciated hierarchies, since only one of these cases has to be
handled.
(cherry picked from commit fc7ffc71a3673222d41e6613ffc7512277c97f24)
app/paint/gimppaintcore-loops.cc | 79 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 79 insertions(+)
---
diff --git a/app/paint/gimppaintcore-loops.cc b/app/paint/gimppaintcore-loops.cc
index 92e5928920..fdf8d08c15 100644
--- a/app/paint/gimppaintcore-loops.cc
+++ b/app/paint/gimppaintcore-loops.cc
@@ -476,6 +476,85 @@ struct AlgorithmDispatch
};
+/* MandatoryAlgorithmDispatch:
+ *
+ * A class template implementing a dispatch function suitable for dispatching
+ * algorithms that must be included in all hierarchies. '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, used as explained below.
+ *
+ * 'MandatoryAlgorithmDispatch' verifies that the algorithm is included in the
+ * set of requested algorithms (specifically, that the bitwise-AND of the
+ * requested-algorithms bitset and of 'Mask' is equal to 'Mask'), and adds the
+ * it to the hierarchy unconditionally.
+ *
+ * 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,
+ class... Dependencies>
+struct MandatoryAlgorithmDispatch
+{
+ static constexpr guint mask = Mask;
+
+ template <class Visitor,
+ class Algorithm>
+ void
+ operator () (Visitor visitor,
+ const GimpPaintCoreLoopsParams *params,
+ GimpPaintCoreLoopsAlgorithm algorithms,
+ identity<Algorithm> algorithm) const
+ {
+ g_return_if_fail ((algorithms & Mask) == Mask);
+
+ BasicDispatch<AlgorithmTemplate, Mask, Dependencies...> () (visitor,
+ params,
+ algorithms,
+ algorithm);
+ }
+};
+
+/* SuppressedAlgorithmDispatch:
+ *
+ * A class template implementing a placeholder dispatch function suitable for
+ * dispatching algorithms that are never included in any hierarchy.
+ * '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. Note that
+ * 'AlgorithmTemplate' and 'Dependencies' are not actually used, and are merely
+ * included for exposition.
+ *
+ * 'SuppressedAlgorithmDispatch' verifies that the algorithm is not included in
+ * the set of requested algorithms (specifically, that the bitwise-AND of the
+ * requested-algorithms bitset and of 'Mask' is not equal to 'Mask'), and
+ * doesn't modify the hierarchy.
+ */
+
+template <template <class Base> class AlgorithmTemplate,
+ guint Mask,
+ class... Dependencies>
+struct SuppressedAlgorithmDispatch
+{
+ static constexpr guint mask = Mask;
+
+ template <class Visitor,
+ class Algorithm>
+ void
+ operator () (Visitor visitor,
+ const GimpPaintCoreLoopsParams *params,
+ GimpPaintCoreLoopsAlgorithm algorithms,
+ identity<Algorithm> algorithm) const
+ {
+ g_return_if_fail ((algorithms & Mask) != Mask);
+
+ visitor (algorithm);
+ }
+};
+
+
/* PaintBuf, dispatch_paint_buf():
*
* An algorithm helper class, providing access to the paint buffer. Algorithms
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]