LCOV - code coverage report
Current view: top level - libreoffice/canvas/inc/canvas/base - disambiguationhelper.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 12 0.0 %
Date: 2012-12-27 Functions: 0 42 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 INCLUDED_CANVAS_DISAMBIGUATIONHELPER_HXX
      21             : #define INCLUDED_CANVAS_DISAMBIGUATIONHELPER_HXX
      22             : 
      23             : #include <osl/mutex.hxx>
      24             : 
      25             : 
      26             : /* Definition of the DisambiguationHelper class */
      27             : 
      28             : namespace canvas
      29             : {
      30             :     /** Base class, initializing its own baseclass with m_aMutex.
      31             : 
      32             :         This is necessary to make the CanvasBase, GraphicDeviceBase,
      33             :         etc. classes freely combinable - letting them perform this
      34             :         initialization would prohibit deriving e.g. CanvasBase from
      35             :         GraphicDeviceBase.
      36             : 
      37             :         On top of that, disambiguates XEventListener::disposing and
      38             :         WeakComponentImplHelper::disposing.
      39             : 
      40             :         Having two virtual methods with the same name, and not
      41             :         overriding them in every derived class, will hide one of
      42             :         them. Later trying to override the same method, will generate
      43             :         a new vtable slot, and lead to very hard to spot errors.
      44             :      */
      45           0 :     template< class Base > class DisambiguationHelper : public Base
      46             :     {
      47             :     public:
      48             :         typedef Base BaseType;
      49             : 
      50             :         /** Construct DisambiguationHelper
      51             : 
      52             :             This method is the whole purpose of this template:
      53             :             initializing a base class with the provided m_aMutex
      54             :             member (the WeakComponentImplHelper templates need that,
      55             :             as they require the lifetime of the mutex to extend
      56             :             theirs).
      57             :          */
      58           0 :         DisambiguationHelper() :
      59           0 :             BaseType( m_aMutex )
      60             :         {
      61           0 :         }
      62             : 
      63           0 :         virtual void SAL_CALL disposing()
      64           0 :         { disposeThis(); }
      65             : 
      66           0 :         virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException)
      67           0 :         { disposeEventSource(Source); }
      68             : 
      69           0 :         virtual void disposeThis()
      70           0 :         {}
      71           0 :         virtual void disposeEventSource( const ::com::sun::star::lang::EventObject& ) throw (::com::sun::star::uno::RuntimeException)
      72           0 :         {}
      73             : 
      74             : protected:
      75             :         mutable ::osl::Mutex m_aMutex;
      76             :     };
      77             : }
      78             : 
      79             : #endif /* INCLUDED_CANVAS_DISAMBIGUATIONHELPER_HXX */
      80             : 
      81             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10