bump product version to 5.0.4.1
[LibreOffice.git] / sd / source / ui / slidesorter / cache / SlsQueueProcessor.hxx
blob253bc11b200564da89a0f4e5e13915b2696a9983
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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_SD_SOURCE_UI_SLIDESORTER_CACHE_SLSQUEUEPROCESSOR_HXX
21 #define INCLUDED_SD_SOURCE_UI_SLIDESORTER_CACHE_SLSQUEUEPROCESSOR_HXX
23 #include "cache/SlsPageCache.hxx"
24 #include "SlsRequestPriorityClass.hxx"
25 #include "SlsBitmapFactory.hxx"
26 #include "view/SlideSorterView.hxx"
27 #include "tools/IdleDetection.hxx"
28 #include "SlsBitmapCache.hxx"
29 #include "sdpage.hxx"
30 #include "Window.hxx"
32 #include <svx/svdpagv.hxx>
33 #include <vcl/svapp.hxx>
34 #include <vcl/timer.hxx>
35 #include <boost/function.hpp>
37 namespace sd { namespace slidesorter { namespace view {
38 class SlideSorterView;
39 } } }
41 namespace sd { namespace slidesorter { namespace cache {
43 class BitmapCache;
44 class RequestQueue;
46 /** This queue processor is timer based, i.e. when an entry is added to the
47 queue and the processor is started with Start() in the base class a
48 timer is started that eventually calls ProcessRequest(). This is
49 repeated until the queue is empty or Stop() is called.
51 class QueueProcessor
53 public:
54 typedef ::boost::function<bool()> IdleDetectionCallback;
55 QueueProcessor (
56 RequestQueue& rQueue,
57 const ::boost::shared_ptr<BitmapCache>& rpCache,
58 const Size& rPreviewSize,
59 const bool bDoSuperSampling,
60 const SharedCacheContext& rpCacheContext);
61 virtual ~QueueProcessor();
63 /** Start the processor. This implementation is timer based and waits
64 an defined amount of time that depends on the given argument before
65 the next entry in the queue is processed.
66 @param nPriorityClass
67 A priority class of 0 tells the processor that a high priority
68 request is waiting in the queue. The time to wait is thus
69 shorter then that for a low priority request (denoted by a value
70 of 1.) When the timer is already running it is not modified.
72 void Start (int nPriorityClass = 0);
73 void Stop();
74 void Pause();
75 void Resume();
77 void SetPreviewSize (
78 const Size& rSize,
79 const bool bDoSuperSampling);
81 /** Use this method when the page cache is (maybe) using a different
82 BitmapCache. This is usually necessary after calling
83 PageCacheManager::ChangeSize().
85 void SetBitmapCache (const ::boost::shared_ptr<BitmapCache>& rpCache);
87 private:
88 /** This mutex is used to guard the queue processor. Be careful not to
89 mix its use with that of the solar mutex.
91 ::osl::Mutex maMutex;
93 Timer maTimer;
94 DECL_LINK_TYPED(ProcessRequestHdl, Timer *, void);
95 sal_uInt32 mnTimeBetweenHighPriorityRequests;
96 sal_uInt32 mnTimeBetweenLowPriorityRequests;
97 sal_uInt32 mnTimeBetweenRequestsWhenNotIdle;
98 Size maPreviewSize;
99 bool mbDoSuperSampling;
100 SharedCacheContext mpCacheContext;
101 RequestQueue& mrQueue;
102 ::boost::shared_ptr<BitmapCache> mpCache;
103 BitmapFactory maBitmapFactory;
104 bool mbIsPaused;
106 void ProcessRequests();
107 void ProcessOneRequest (
108 CacheKey aKey,
109 const RequestPriorityClass ePriorityClass);
112 } } } // end of namespace ::sd::slidesorter::cache
114 #endif
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */