Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef INCLUDED_CANVAS_DISAMBIGUATIONHELPER_HXX
30 : : #define INCLUDED_CANVAS_DISAMBIGUATIONHELPER_HXX
31 : :
32 : : #include <osl/mutex.hxx>
33 : :
34 : :
35 : : /* Definition of the DisambiguationHelper class */
36 : :
37 : : namespace canvas
38 : : {
39 : : /** Base class, initializing its own baseclass with m_aMutex.
40 : :
41 : : This is necessary to make the CanvasBase, GraphicDeviceBase,
42 : : etc. classes freely combinable - letting them perform this
43 : : initialization would prohibit deriving e.g. CanvasBase from
44 : : GraphicDeviceBase.
45 : :
46 : : On top of that, disambiguates XEventListener::disposing and
47 : : WeakComponentImplHelper::disposing.
48 : :
49 : : Having two virtual methods with the same name, and not
50 : : overriding them in every derived class, will hide one of
51 : : them. Later trying to override the same method, will generate
52 : : a new vtable slot, and lead to very hard to spot errors.
53 : : */
54 : 0 : template< class Base > class DisambiguationHelper : public Base
55 : : {
56 : : public:
57 : : typedef Base BaseType;
58 : :
59 : : /** Construct DisambiguationHelper
60 : :
61 : : This method is the whole purpose of this template:
62 : : initializing a base class with the provided m_aMutex
63 : : member (the WeakComponentImplHelper templates need that,
64 : : as they require the lifetime of the mutex to extend
65 : : theirs).
66 : : */
67 : 0 : DisambiguationHelper() :
68 : 0 : BaseType( m_aMutex )
69 : : {
70 : 0 : }
71 : :
72 : 0 : virtual void SAL_CALL disposing()
73 : 0 : { disposeThis(); }
74 : :
75 : 0 : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException)
76 : 0 : { disposeEventSource(Source); }
77 : :
78 : 0 : virtual void disposeThis()
79 : 0 : {}
80 : 0 : virtual void disposeEventSource( const ::com::sun::star::lang::EventObject& ) throw (::com::sun::star::uno::RuntimeException)
81 : 0 : {}
82 : :
83 : : protected:
84 : : mutable ::osl::Mutex m_aMutex;
85 : : };
86 : : }
87 : :
88 : : #endif /* INCLUDED_CANVAS_DISAMBIGUATIONHELPER_HXX */
89 : :
90 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|