LCOV - code coverage report
Current view: top level - libreoffice/basebmp/inc/basebmp - accessor.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 10 10 100.0 %
Date: 2012-12-17 Functions: 27 48 56.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   496104951 :     value_type operator()(Iterator const& i) const
      42             :     {
      43   496104951 :         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  1331136855 :     void set(V const& value, Iterator const& i) const
      56             :     {
      57  1331136855 :         *i = vigra::detail::RequiresExplicitCast<value_type>::cast(value);
      58  1331136855 :     }
      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     4377611 :     value_type operator()(Iterator const& i) const
      83             :     {
      84     4377611 :         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    60674900 :     void set(V const& value, Iterator const& i) const
      97             :     {
      98    60674900 :         i.set( vigra::detail::RequiresExplicitCast<value_type>::cast(value) );
      99    60674900 :     }
     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.10