LCOV - code coverage report
Current view: top level - libreoffice/solver/unxlngi6.pro/inc/vcl - scopedbitmapaccess.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 15 0.0 %
Date: 2012-12-27 Functions: 0 17 0.0 %
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 VCL_SCOPEDBITMAPACCESS_HXX_INCLUDED
      21             : #define VCL_SCOPEDBITMAPACCESS_HXX_INCLUDED
      22             : 
      23             : namespace vcl
      24             : {
      25             : 
      26             : /** This template handles BitmapAccess the RAII way.
      27             : 
      28             :     Please don't use directly, but through the ready-made typedefs
      29             :     ScopedReadAccess and ScopedWriteAccess in classes Bitmap and
      30             :     AlphaMask.
      31             : 
      32             :     Use as follows:
      33             :     Bitmap aBitmap;
      34             :     Bitmap::ScopedReadAccess pReadAccess( aBitmap );
      35             :     pReadAccess->SetPixel()...
      36             : 
      37             :     Bitmap aBitmap2;
      38             :     Bitmap::ScopedWriteAccess pWriteAccess( bCond ? aBitmap2.AcquireWriteAccess() : 0, aBitmap2 );
      39             :     if ( pWriteAccess )...
      40             : 
      41             :     @attention for practical reasons, ScopedBitmapAccess stores a
      42             :     reference to the provided bitmap, thus, make sure that the bitmap
      43             :     specified at construction time lives at least as long as the
      44             :     ScopedBitmapAccess.
      45             :  */
      46             : template < class Access, class Bitmap, Access* (Bitmap::* Acquire)() > class ScopedBitmapAccess
      47             : {
      48             :     typedef ScopedBitmapAccess< Access, Bitmap, Acquire > self_type;
      49             :     typedef bool (self_type::* unspecified_bool_type)() const;
      50             : 
      51             : public:
      52           0 :     explicit ScopedBitmapAccess( Bitmap& rBitmap ) :
      53             :         mpAccess( 0 ),
      54           0 :         mrBitmap( rBitmap )
      55             :     {
      56           0 :         mpAccess = (mrBitmap.*Acquire)();
      57           0 :     }
      58             : 
      59           0 :     ScopedBitmapAccess( Access* pAccess, Bitmap& rBitmap ) :
      60             :         mpAccess( pAccess ),
      61           0 :         mrBitmap( rBitmap )
      62             :     {
      63           0 :     }
      64             : 
      65           0 :     ~ScopedBitmapAccess()
      66             :     {
      67           0 :         mrBitmap.ReleaseAccess( mpAccess );
      68           0 :     }
      69             : 
      70           0 :     bool operator!() const { return !mpAccess; }
      71           0 :     operator unspecified_bool_type() const
      72             :     {
      73           0 :         return mpAccess ? &self_type::operator! : 0;
      74             :     }
      75             : 
      76           0 :     Access*         get() { return mpAccess; }
      77             :     const Access*   get() const { return mpAccess; }
      78             : 
      79           0 :     Access*         operator->() { return mpAccess; }
      80             :     const Access*   operator->() const { return mpAccess; }
      81             : 
      82             :     Access&         operator*() { return *mpAccess; }
      83             :     const Access&   operator*() const { return *mpAccess; }
      84             : 
      85             : private:
      86             :     Access*     mpAccess;
      87             :     Bitmap&     mrBitmap;
      88             : };
      89             : 
      90             : }
      91             : 
      92             : #endif // VCL_SCOPEDBITMAPACCESS_HXX_INCLUDED
      93             : 
      94             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10