1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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_ACCESSORTRAITS_HXX
21 #define INCLUDED_BASEBMP_ACCESSORTRAITS_HXX
23 #include <basebmp/accessorfunctors.hxx>
24 #include <basebmp/accessoradapters.hxx>
25 #include <basebmp/metafunctions.hxx>
35 /// Metafunction to select output mask functor from iterator and mask value type
36 template< typename T
, typename M
, bool polarity
, typename DUMMY
> struct outputMaskFunctorSelector
: public
37 ifBothScalarIntegral
< T
, M
,
38 IntegerOutputMaskFunctor
< T
, M
, polarity
>,
39 GenericOutputMaskFunctor
< T
, M
, polarity
> >
42 template< typename T
, typename M
, bool polarity
> struct outputMaskFunctorSelector
< T
, M
, polarity
, FastMask
> : public
43 ifBothScalarIntegral
< T
, M
,
44 FastIntegerOutputMaskFunctor
< T
, M
, polarity
>,
45 GenericOutputMaskFunctor
< T
, M
, polarity
> >
49 /** Metafunction providing a point of configuration for iterators
50 capable of employing the fast output mask functor.
52 Specialize this metafunction for your case, and pass FastMask to
53 the outputMaskFunctorSelector.
55 template< class Accessor
,
59 bool polarity
> struct maskedAccessorSelector
61 typedef TernarySetterFunctionAccessorAdapter
<
64 typename outputMaskFunctorSelector
<
65 typename
Accessor::value_type
,
66 typename
MaskAccessor::value_type
,
72 //-----------------------------------------------------------------------------
74 /** Traits template for Accessor
76 Provides wrapped types for color lookup, raw pixel access, xor and
79 template< class Accessor
> struct AccessorTraits
81 /// value type of described accessor
82 typedef typename
Accessor::value_type value_type
;
84 /// Retrieve stand-alone color lookup function for given Accessor type
85 typedef project2nd
< Accessor
, value_type
> color_lookup
;
87 /// Retrieve raw pixel data accessor for given Accessor type
88 typedef Accessor raw_accessor
;
90 /// Retrieve wrapped accessor for XOR setter access
91 typedef BinarySetterFunctionAccessorAdapter
<
93 XorFunctor
< value_type
> > xor_accessor
;
95 /** Retrieve masked accessor for given types
97 A masked accessor works like a filter, where the mask gates
98 the accessor's setter methods (if the mask contains a 0 at a
99 given iterator position, the original value is
100 preserved. Otherwise, the new value gets set).
102 @attention be careful when retrieving a masked accessor for a
103 set of types, and using it for a different one - there are
104 partial specializations that take an optimized functor for
105 certain mask accessors.
107 template< class MaskAccessor
,
110 bool polarity
> struct masked_accessor
:
111 public maskedAccessorSelector
< Accessor
,
120 } // namespace basebmp
122 #endif /* INCLUDED_BASEBMP_ACCESSORTRAITS_HXX */
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */