1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SlsQueueProcessor.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SD_SLIDESORTER_QUEUE_PROCESSOR_HXX
32 #define SD_SLIDESORTER_QUEUE_PROCESSOR_HXX
34 #include "cache/SlsPageCache.hxx"
35 #include "SlsRequestPriorityClass.hxx"
36 #include "SlsBitmapFactory.hxx"
37 #include "view/SlsPageObject.hxx"
38 #include "view/SlideSorterView.hxx"
39 #include "view/SlsPageObjectViewObjectContact.hxx"
40 #include "tools/IdleDetection.hxx"
41 #include "SlsBitmapCache.hxx"
45 #include <svx/svdpagv.hxx>
46 #include <vcl/svapp.hxx>
47 #include <vcl/timer.hxx>
48 #include <boost/function.hpp>
51 namespace sd
{ namespace slidesorter
{ namespace view
{
52 class SlideSorterView
;
57 namespace sd
{ namespace slidesorter
{ namespace cache
{
64 /** This queue processor is timer based, i.e. when an entry is added to the
65 queue and the processor is started with Start() in the base class a
66 timer is started that eventually calls ProcessRequest(). This is
67 repeated until the queue is empty or Stop() is called.
72 typedef ::boost::function
<bool()> IdleDetectionCallback
;
75 const ::boost::shared_ptr
<BitmapCache
>& rpCache
,
76 const Size
& rPreviewSize
,
77 const SharedCacheContext
& rpCacheContext
);
78 virtual ~QueueProcessor();
80 /** Start the processor. This implementation is timer based and waits
81 an defined amount of time that depends on the given argument before
82 the next entry in the queue is processed.
84 A priority class of 0 tells the processor that a high priority
85 request is waiting in the queue. The time to wait is thus
86 shorter then that for a low priority request (denoted by a value
87 of 1.) When the timer is already running it is not modified.
89 void Start (int nPriorityClass
= 0);
94 void Terminate (void);
96 void SetPreviewSize (const Size
& rSize
);
98 /** As we can not really terminate the rendering of a preview bitmap for
99 a request in midair this method acts more like a semaphor. It
100 returns only when it is save for the caller to delete the request.
101 For this to work it is important to remove the request from the
102 queue before calling this method.
104 void RemoveRequest (CacheKey aKey
);
106 /** Use this method when the page cache is (maybe) using a different
107 BitmapCache. This is usually necessary after calling
108 PageCacheManager::ChangeSize().
110 void SetBitmapCache (const ::boost::shared_ptr
<BitmapCache
>& rpCache
);
113 /** This mutex is used to guard the queue processor. Be carefull not to
114 mix its use with that of the solar mutex.
116 ::osl::Mutex maMutex
;
119 DECL_LINK(ProcessRequestHdl
, Timer
*);
120 sal_uInt32 mnTimeBetweenHighPriorityRequests
;
121 sal_uInt32 mnTimeBetweenLowPriorityRequests
;
122 sal_uInt32 mnTimeBetweenRequestsWhenNotIdle
;
124 SharedCacheContext mpCacheContext
;
125 RequestQueue
& mrQueue
;
126 ::boost::shared_ptr
<BitmapCache
> mpCache
;
127 BitmapFactory maBitmapFactory
;
130 void ProcessRequests (void);
131 void ProcessOneRequest (
133 const RequestPriorityClass ePriorityClass
);
139 } } } // end of namespace ::sd::slidesorter::cache