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 SD_SLIDESORTER_CACHE_CONFIGURATION_HXX 25 #define SD_SLIDESORTER_CACHE_CONFIGURATION_HXX 26 27 #include <com/sun/star/uno/Any.hxx> 28 #include <vcl/timer.hxx> 29 #include <com/sun/star/container/XNameAccess.hpp> 30 #include <boost/shared_ptr.hpp> 31 #include <boost/weak_ptr.hpp> 32 33 namespace sd { namespace slidesorter { namespace cache { 34 35 /** A very simple and easy-to-use access to configuration entries regarding 36 the slide sorter cache. 37 */ 38 class CacheConfiguration 39 { 40 public: 41 /** Return an instance to this class. The reference is released after 5 42 seconds. Subsequent calls to this function will create a new 43 instance. 44 */ 45 static ::boost::shared_ptr<CacheConfiguration> Instance (void); 46 47 /** Look up the specified value in 48 MultiPaneGUI/SlideSorter/PreviewCache. When the specified value 49 does not exist then an empty Any is returned. 50 */ 51 ::com::sun::star::uno::Any GetValue (const ::rtl::OUString& rName); 52 53 private: 54 static ::boost::shared_ptr<CacheConfiguration> mpInstance; 55 /** When a caller holds a reference after we have released ours we use 56 this weak pointer to avoid creating a new instance. 57 */ 58 static ::boost::weak_ptr<CacheConfiguration> mpWeakInstance; 59 static Timer maReleaseTimer; 60 ::com::sun::star::uno::Reference< 61 ::com::sun::star::container::XNameAccess> mxCacheNode; 62 63 CacheConfiguration (void); 64 65 DECL_LINK(TimerCallback, Timer*); 66 }; 67 68 } } } // end of namespace ::sd::slidesorter::cache 69 70 #endif 71