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 .
22 #include <com/sun/star/lang/EventObject.hpp>
23 #include <osl/mutex.hxx>
26 /* Definition of the DisambiguationHelper class */
30 /** Base class, initializing its own baseclass with m_aMutex.
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
37 On top of that, disambiguates XEventListener::disposing and
38 WeakComponentImplHelper::disposing.
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.
45 template< class Base
> class DisambiguationHelper
: public Base
48 /** Construct DisambiguationHelper
50 This method is the whole purpose of this template:
51 initializing a base class with the provided m_aMutex
52 member (the WeakComponentImplHelper templates need that,
53 as they require the lifetime of the mutex to extend
56 DisambiguationHelper() :
61 virtual void disposeThis()
63 /// @throws css::uno::RuntimeException
64 virtual void disposeEventSource( const css::lang::EventObject
& )
67 mutable ::osl::Mutex m_aMutex
;
70 virtual void SAL_CALL
disposing() override
73 virtual void SAL_CALL
disposing( const css::lang::EventObject
& Source
) override
74 { disposeEventSource(Source
); }
79 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */