Update ooo320-m1
[ooovba.git] / sd / source / ui / slidesorter / cache / SlsRequestQueue.hxx
blob0fd282c05beac8715a07f45920815746e8106fb9
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SlsRequestQueue.hxx,v $
11 * $Revision: 1.3 $
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 {
44 class RequestData;
46 /** The request queue stores requests that are described by the RequestData
47 sorted according to priority class and then priority.
49 class RequestQueue
51 public:
52 RequestQueue (const SharedCacheContext& rpCacheContext);
53 ~RequestQueue (void);
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.
58 @param rRequestData
59 The request.
60 @param eRequestClass
61 The priority class in which to insert the request with highest
62 or lowest priority.
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
66 with lowest priority.
68 void AddRequest (
69 CacheKey aKey,
70 RequestPriorityClass eRequestClass,
71 bool bInsertWithHighestPriority = false);
73 /** Remove the specified request from the queue.
74 @param rRequestData
75 It is OK when the specified request is not a member of the
76 queue.
77 @return
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.
86 void ChangeClass (
87 CacheKey aKey,
88 RequestPriorityClass eNewRequestClass);
90 /** Get the request with the highest priority int the highest priority class.
92 CacheKey GetFront (void);
94 // For debugging.
95 RequestPriorityClass GetFrontPriorityClass (void);
97 /** Really a synonym for RemoveRequest(GetFront());
99 void PopFront (void);
101 /** Returns <TRUE/> when there is no element in the queue.
103 bool IsEmpty (void);
105 /** Remove all requests from the queue. This resets the minimum and
106 maximum priorities to their default values.
108 void Clear (void);
110 /** Return the mutex that guards the access to the priority queue.
112 ::osl::Mutex& GetMutex (void);
114 private:
115 ::osl::Mutex maMutex;
116 class Container;
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
123 priority.
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
129 priority.
131 int mnMaximumPriority;
135 } } } // end of namespace ::sd::slidesorter::cache
137 #endif