Linux x86 build fix
[LibreOffice.git] / basebmp / inc / accessortraits.hxx
blob24a7af2408a601321f01199c0776c51dc841b381
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_BASEBMP_INC_ACCESSORTRAITS_HXX
21 #define INCLUDED_BASEBMP_INC_ACCESSORTRAITS_HXX
23 #include <accessorfunctors.hxx>
24 #include <accessoradapters.hxx>
25 #include <metafunctions.hxx>
27 #include <o3tl/compat_functional.hxx>
29 #include <functional>
31 namespace basebmp
34 struct FastMask;
35 struct NoFastMask;
37 /// Metafunction to select output mask functor from iterator and mask value type
38 template< typename T, typename M, bool polarity, typename DUMMY > struct outputMaskFunctorSelector : public
39 ifBothScalarIntegral< T, M,
40 IntegerOutputMaskFunctor< T, M, polarity >,
41 GenericOutputMaskFunctor< T, M, polarity > >
44 template< typename T, typename M, bool polarity > struct outputMaskFunctorSelector< T, M, polarity, FastMask > : public
45 ifBothScalarIntegral< T, M,
46 FastIntegerOutputMaskFunctor< T, M, polarity >,
47 GenericOutputMaskFunctor< T, M, polarity > >
51 /** Metafunction providing a point of configuration for iterators
52 capable of employing the fast output mask functor.
54 Specialize this metafunction for your case, and pass FastMask to
55 the outputMaskFunctorSelector.
57 template< class Accessor,
58 class MaskAccessor,
59 class Iterator,
60 class MaskIterator,
61 bool polarity > struct maskedAccessorSelector
63 typedef TernarySetterFunctionAccessorAdapter<
64 Accessor,
65 MaskAccessor,
66 typename outputMaskFunctorSelector<
67 typename Accessor::value_type,
68 typename MaskAccessor::value_type,
69 polarity,
70 NoFastMask > ::type >
71 type;
76 /** Traits template for Accessor
78 Provides wrapped types for color lookup, raw pixel access, xor and
79 mask accessors.
81 template< class Accessor > struct AccessorTraits
83 /// value type of described accessor
84 typedef typename Accessor::value_type value_type;
86 /// Retrieve stand-alone color lookup function for given Accessor type
87 typedef o3tl::project2nd< Accessor, value_type > color_lookup;
89 /// Retrieve raw pixel data accessor for given Accessor type
90 typedef Accessor raw_accessor;
92 /// Retrieve wrapped accessor for XOR setter access
93 typedef BinarySetterFunctionAccessorAdapter<
94 Accessor,
95 XorFunctor< value_type > > xor_accessor;
97 /** Retrieve masked accessor for given types
99 A masked accessor works like a filter, where the mask gates
100 the accessor's setter methods (if the mask contains a 0 at a
101 given iterator position, the original value is
102 preserved. Otherwise, the new value gets set).
104 @attention be careful when retrieving a masked accessor for a
105 set of types, and using it for a different one - there are
106 partial specializations that take an optimized functor for
107 certain mask accessors.
109 template< class MaskAccessor,
110 class Iterator,
111 class MaskIterator,
112 bool polarity > struct masked_accessor :
113 public maskedAccessorSelector< Accessor,
114 MaskAccessor,
115 Iterator,
116 MaskIterator,
117 polarity >
122 } // namespace basebmp
124 #endif /* INCLUDED_BASEBMP_INC_ACCESSORTRAITS_HXX */
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */