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 #ifndef __FILTER_CONFIG_CACHEUPDATELISTENER_HXX_ 24 #define __FILTER_CONFIG_CACHEUPDATELISTENER_HXX_ 25 26 //_______________________________________________ 27 // includes 28 29 #include "filtercache.hxx" 30 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 31 #include <com/sun/star/lang/XEventListener.hpp> 32 #include <com/sun/star/util/XChangesListener.hpp> 33 #include <salhelper/singletonref.hxx> 34 #include <cppuhelper/implbase1.hxx> 35 36 //_______________________________________________ 37 // namespace 38 39 namespace filter{ 40 namespace config{ 41 42 //_______________________________________________ 43 // definitions 44 45 //_______________________________________________ 46 47 /** @short implements a listener, which will update the 48 global filter cache, if the underlying configuration 49 wa changed by other processes. 50 */ 51 class CacheUpdateListener : public BaseLock // must be the first one to guarantee right initialized mutex member! 52 , public ::cppu::WeakImplHelper1< css::util::XChangesListener > 53 { 54 //------------------------------------------- 55 // member 56 57 private: 58 59 /** @short reference to an uno service manager, which can be used 60 to create own needed services. */ 61 css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR; 62 63 /** @short reference to the singleton(!) filter cache implementation, 64 which should be updated by this thread. */ 65 ::salhelper::SingletonRef< FilterCache > m_rCache; 66 67 /** @short holds the configuration access, where we listen alive. */ 68 css::uno::Reference< css::uno::XInterface > m_xConfig; 69 70 /** @short every instance of this update listener listen on 71 a special sub set of the filter configuration. 72 So it should know, which type of configuration entry 73 it must put into the filter cache, if the configuration notifys changes ... */ 74 FilterCache::EItemType m_eConfigType; 75 76 //------------------------------------------- 77 // native interface 78 79 public: 80 81 //--------------------------------------- 82 // ctor/dtor 83 84 /** @short initialize new instance of this class. 85 86 @descr Listening won't be started here. It can be done 87 by calling startListening() on this instance. 88 89 @see startListening() 90 91 @param xSMGR 92 reference to a service manager, which can be used to create 93 own needed uno services. 94 95 @param xConfigAccess 96 the configuration access, where this instance should listen for changes. 97 98 @param eConfigType 99 specify the type of configuration. 100 */ 101 CacheUpdateListener(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR , 102 const css::uno::Reference< css::uno::XInterface >& xConfigAccess, 103 FilterCache::EItemType eConfigType ); 104 105 //--------------------------------------- 106 107 /** @short standard dtor. 108 */ 109 virtual ~CacheUpdateListener(); 110 111 //--------------------------------------- 112 113 /** @short starts listening. 114 */ 115 virtual void startListening(); 116 117 //--------------------------------------- 118 119 /** @short stop listening. 120 */ 121 virtual void stopListening(); 122 123 //------------------------------------------- 124 // uno interface 125 126 public: 127 128 //--------------------------------------- 129 // XChangesListener 130 131 virtual void SAL_CALL changesOccurred(const css::util::ChangesEvent& aEvent) 132 throw(css::uno::RuntimeException); 133 134 //--------------------------------------- 135 // lang.XEventListener 136 virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent) 137 throw(css::uno::RuntimeException); 138 }; 139 140 } // namespace config 141 } // namespace filter 142 143 #endif // __FILTER_CONFIG_CACHEUPDATELISTENER_HXX_ 144