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: SlsRequestQueue.hxx,v $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 #ifndef SD_SLIDESORTER_REQUEST_QUEUE_HXX
33 #define SD_SLIDESORTER_REQUEST_QUEUE_HXX
35 #include "SlsRequestPriorityClass.hxx"
36 #include "cache/SlsCacheContext.hxx"
37 #include "taskpane/SlideSorterCacheDisplay.hxx"
38 #include <drawdoc.hxx>
39 #include "osl/mutex.hxx"
42 namespace sd
{ namespace slidesorter
{ namespace cache
{
46 /** The request queue stores requests that are described by the RequestData
47 sorted according to priority class and then priority.
52 RequestQueue (const SharedCacheContext
& rpCacheContext
);
55 /** Insert a request with highest or lowest priority in its priority
56 class. When the request is already present then it is first
57 removed. This effect is then a re-prioritization.
61 The priority class in which to insert the request with highest
63 @param bInsertWithHighestPriority
64 When this flag is <TRUE/> the request is inserted with highes
65 priority in its class. When <FALSE/> the request is inserted
70 RequestPriorityClass eRequestClass
,
71 bool bInsertWithHighestPriority
= false);
73 /** Remove the specified request from the queue.
75 It is OK when the specified request is not a member of the
78 Returns <TRUE/> when the request has been successfully been
79 removed from the queue. Otherwise, e.g. because the request was
80 not a member of the queue, <FALSE/> is returned.
82 bool RemoveRequest (CacheKey aKey
);
84 /** Change the priority class of the specified request.
88 RequestPriorityClass eNewRequestClass
);
90 /** Get the request with the highest priority int the highest priority class.
92 CacheKey
GetFront (void);
95 RequestPriorityClass
GetFrontPriorityClass (void);
97 /** Really a synonym for RemoveRequest(GetFront());
101 /** Returns <TRUE/> when there is no element in the queue.
105 /** Remove all requests from the queue. This resets the minimum and
106 maximum priorities to their default values.
110 /** Return the mutex that guards the access to the priority queue.
112 ::osl::Mutex
& GetMutex (void);
115 ::osl::Mutex maMutex
;
117 ::boost::scoped_ptr
<Container
> mpRequestQueue
;
118 SharedCacheContext mpCacheContext
;
120 /** A lower bound of the lowest priority of all elements in the queues.
121 The start value is 0. It is assigned and then decreased every time
122 when an element is inserted or marked as the request with lowest
125 int mnMinimumPriority
;
126 /** An upper bound of the highest priority of all elements in the queues.
127 The start value is 1. It is assigned and then increased every time
128 when an element is inserted or marked as the request with highest
131 int mnMaximumPriority
;
135 } } } // end of namespace ::sd::slidesorter::cache