LCOV - code coverage report
Current view: top level - include/basebmp - accessor.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 10 10 100.0 %
Date: 2015-06-13 12:38:46 Functions: 26 48 54.2 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_BASEBMP_ACCESSOR_HXX
      21             : #define INCLUDED_BASEBMP_ACCESSOR_HXX
      22             : 
      23             : #include <vigra/numerictraits.hxx>
      24             : 
      25             : namespace basebmp
      26             : {
      27             : 
      28             : /** Standard accessor type
      29             : 
      30             :     Accesses the iterator values the standard way (i.e. via
      31             :     *operator()/operator[])
      32             :  */
      33             : template<typename ValueType> class StandardAccessor
      34             : {
      35             : public:
      36             :     typedef ValueType value_type;
      37             : 
      38             : 
      39             : 
      40             :     template< class Iterator >
      41  3273939226 :     value_type operator()(Iterator const& i) const
      42             :     {
      43  3273939226 :         return *i;
      44             :     }
      45             : 
      46             :     template< class Iterator, class Difference >
      47             :     value_type operator()(Iterator const& i, Difference const& diff) const
      48             :     {
      49             :         return i[diff];
      50             :     }
      51             : 
      52             : 
      53             : 
      54             :     template< typename V, class Iterator >
      55 11568345705 :     void set(V const& value, Iterator const& i) const
      56             :     {
      57 11568345705 :         *i = vigra::detail::RequiresExplicitCast<value_type>::cast(value);
      58 11568345705 :     }
      59             : 
      60             :     template< typename V, class Iterator, class Difference >
      61             :     void set(V const& value, Iterator const& i, Difference const& diff) const
      62             :     {
      63             :         i[diff] = vigra::detail::RequiresExplicitCast<value_type>::cast(value);
      64             :     }
      65             : };
      66             : 
      67             : 
      68             : 
      69             : /** Non-standard accessor type
      70             : 
      71             :     Uses getter/setter methods at the given iterator type, to access
      72             :     the underlying values.
      73             :  */
      74             : template<typename ValueType> class NonStandardAccessor
      75             : {
      76             : public:
      77             :     typedef ValueType value_type;
      78             : 
      79             : 
      80             : 
      81             :     template< class Iterator >
      82  1329694803 :     value_type operator()(Iterator const& i) const
      83             :     {
      84  1329694803 :         return i.get();
      85             :     }
      86             : 
      87             :     template< class Iterator, class Difference >
      88             :     value_type operator()(Iterator const& i, Difference const& diff) const
      89             :     {
      90             :         return i.get(diff);
      91             :     }
      92             : 
      93             : 
      94             : 
      95             :     template< typename V, class Iterator >
      96   302191006 :     void set(V const& value, Iterator const& i) const
      97             :     {
      98   302191006 :         i.set( vigra::detail::RequiresExplicitCast<value_type>::cast(value) );
      99   302191006 :     }
     100             : 
     101             :     template< typename V, class Iterator, class Difference >
     102             :     void set(V const& value, Iterator const& i, Difference const& diff) const
     103             :     {
     104             :         i.set( vigra::detail::RequiresExplicitCast<value_type>::cast(value),
     105             :                diff );
     106             :     }
     107             : };
     108             : 
     109             : } // namespace basebmp
     110             : 
     111             : #endif /* INCLUDED_BASEBMP_ACCESSOR_HXX */
     112             : 
     113             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11