xref: /trunk/main/unotools/inc/unotools/options.hxx (revision 67e470da)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef INCLUDED_unotools_OPTIONS_HXX
25 #define INCLUDED_unotools_OPTIONS_HXX
26 
27 #include "sal/config.h"
28 #include "unotools/unotoolsdllapi.h"
29 
30 /*
31 	The class utl::detail::Options provides a kind of multiplexer. It implements a ConfigurationListener
32 	that is usually registered at a ConfigItem class. At the same time it implements a ConfigurationBroadcaster
33 	that allows further ("external") listeners to register.
34 	Once the class deriving from Options is notified about
35 	configuration changes by the ConfigItem if its content has been changed by calling some of its methods,
36 	a call of the Options::NotifyListeners() method will send out notifications to all external listeners.
37 */
38 
39 namespace utl {
40 
41     class ConfigurationBroadcaster;
42     class IMPL_ConfigurationListenerList;
43 
44 	// interface for configuration listener
45     class UNOTOOLS_DLLPUBLIC ConfigurationListener
46     {
47     public:
48         virtual void ConfigurationChanged( ConfigurationBroadcaster* p, sal_uInt32 nHint=0 ) = 0;
49     };
50 
51 	// complete broadcasting implementation
52     class UNOTOOLS_DLLPUBLIC ConfigurationBroadcaster
53     {
54         IMPL_ConfigurationListenerList* mpList;
55 		sal_Int32               m_nBroadcastBlocked;     // broadcast only if this is 0
56 		sal_uInt32				m_nBlockedHint;
57 
58     public:
59         void AddListener( utl::ConfigurationListener* pListener );
60         void RemoveListener( utl::ConfigurationListener* pListener );
61 
62 		// notify listeners; nHint is an implementation detail of the particular class deriving from ConfigurationBroadcaster
63         void NotifyListeners( sal_uInt32 nHint );
64         ConfigurationBroadcaster();
65         virtual ~ConfigurationBroadcaster();
66         virtual void BlockBroadcasts( bool bBlock );
67     };
68 
69 namespace detail {
70 
71 // A base class for the various option classes supported by
72 // unotools/source/config/itemholderbase.hxx (which must be public, as it is
73 // shared between unotools, svl and svt)
74 // It also provides an implementation for a Configuration Listener and inherits a broadcaster implementation
75 
76 class UNOTOOLS_DLLPUBLIC Options : public utl::ConfigurationBroadcaster, public utl::ConfigurationListener
77 {
78 public:
79     Options();
80 
81     virtual ~Options() = 0;
82 
83 private:
84     UNOTOOLS_DLLPRIVATE Options(Options &); // not defined
85     UNOTOOLS_DLLPRIVATE void operator =(Options &); // not defined
86 
87 protected:
88     virtual void ConfigurationChanged( ::utl::ConfigurationBroadcaster* p, sal_uInt32 nHint=0 );
89 };
90 
91 } }
92 
93 #endif
94