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 .
20 #ifndef INCLUDED_CANVAS_DISAMBIGUATIONHELPER_HXX
21 #define INCLUDED_CANVAS_DISAMBIGUATIONHELPER_HXX
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 typedef Base BaseType
;
50 /** Construct DisambiguationHelper
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
58 DisambiguationHelper() :
63 virtual void SAL_CALL
disposing()
66 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& Source
) throw (::com::sun::star::uno::RuntimeException
)
67 { disposeEventSource(Source
); }
69 virtual void disposeThis()
71 virtual void disposeEventSource( const ::com::sun::star::lang::EventObject
& ) throw (::com::sun::star::uno::RuntimeException
)
75 mutable ::osl::Mutex m_aMutex
;
79 #endif /* INCLUDED_CANVAS_DISAMBIGUATIONHELPER_HXX */
81 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */