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_ACCESSOR_HXX
21 #define INCLUDED_BASEBMP_ACCESSOR_HXX
23 #include <vigra/numerictraits.hxx>
28 /** Standard accessor type
30 Accesses the iterator values the standard way (i.e. via
31 *operator()/operator[])
33 template<typename ValueType
> class StandardAccessor
36 typedef ValueType value_type
;
38 // -------------------------------------------------------
40 template< class Iterator
>
41 value_type
operator()(Iterator
const& i
) const
46 template< class Iterator
, class Difference
>
47 value_type
operator()(Iterator
const& i
, Difference
const& diff
) const
52 // -------------------------------------------------------
54 template< typename V
, class Iterator
>
55 void set(V
const& value
, Iterator
const& i
) const
57 *i
= vigra::detail::RequiresExplicitCast
<value_type
>::cast(value
);
60 template< typename V
, class Iterator
, class Difference
>
61 void set(V
const& value
, Iterator
const& i
, Difference
const& diff
) const
63 i
[diff
] = vigra::detail::RequiresExplicitCast
<value_type
>::cast(value
);
67 //-----------------------------------------------------------------------------
69 /** Non-standard accessor type
71 Uses getter/setter methods at the given iterator type, to access
72 the underlying values.
74 template<typename ValueType
> class NonStandardAccessor
77 typedef ValueType value_type
;
79 // -------------------------------------------------------
81 template< class Iterator
>
82 value_type
operator()(Iterator
const& i
) const
87 template< class Iterator
, class Difference
>
88 value_type
operator()(Iterator
const& i
, Difference
const& diff
) const
93 // -------------------------------------------------------
95 template< typename V
, class Iterator
>
96 void set(V
const& value
, Iterator
const& i
) const
98 i
.set( vigra::detail::RequiresExplicitCast
<value_type
>::cast(value
) );
101 template< typename V
, class Iterator
, class Difference
>
102 void set(V
const& value
, Iterator
const& i
, Difference
const& diff
) const
104 i
.set( vigra::detail::RequiresExplicitCast
<value_type
>::cast(value
),
109 } // namespace basebmp
111 #endif /* INCLUDED_BASEBMP_ACCESSOR_HXX */
113 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */