bump product version to 5.0.4.1
[LibreOffice.git] / sd / source / ui / slidesorter / cache / SlsRequestQueue.hxx
blob476e21cd2d61c405851d0209ad1f9b409453824a
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_SLSREQUESTQUEUE_HXX
21 #define INCLUDED_SD_SOURCE_UI_SLIDESORTER_CACHE_SLSREQUESTQUEUE_HXX
23 #include "SlsRequestPriorityClass.hxx"
24 #include "cache/SlsCacheContext.hxx"
25 #include "taskpane/SlideSorterCacheDisplay.hxx"
26 #include <drawdoc.hxx>
27 #include <osl/mutex.hxx>
28 #include <svx/sdrpageuser.hxx>
30 namespace sd { namespace slidesorter { namespace cache {
32 class RequestData;
34 /** The request queue stores requests that are described by the RequestData
35 sorted according to priority class and then priority.
37 class RequestQueue : public sdr::PageUser
39 public:
40 RequestQueue (const SharedCacheContext& rpCacheContext);
41 virtual ~RequestQueue();
43 /** Insert a request with highest or lowest priority in its priority
44 class. When the request is already present then it is first
45 removed. This effect is then a re-prioritization.
46 @param aKey
47 The request.
48 @param eRequestClass
49 The priority class in which to insert the request with highest
50 or lowest priority.
51 @param bInsertWithHighestPriority
52 When this flag is <TRUE/> the request is inserted with highes
53 priority in its class. When <FALSE/> the request is inserted
54 with lowest priority.
56 void AddRequest (
57 CacheKey aKey,
58 RequestPriorityClass eRequestClass,
59 bool bInsertWithHighestPriority = false);
61 /** Remove the specified request from the queue.
62 @param aKey
63 It is OK when the specified request is not a member of the
64 queue.
65 @return
66 Returns <TRUE/> when the request has been successfully been
67 removed from the queue. Otherwise, e.g. because the request was
68 not a member of the queue, <FALSE/> is returned.
70 bool RemoveRequest (CacheKey aKey);
72 /** Change the priority class of the specified request.
74 void ChangeClass (
75 CacheKey aKey,
76 RequestPriorityClass eNewRequestClass);
78 /** Get the request with the highest priority int the highest priority class.
80 CacheKey GetFront();
82 // For debugging.
83 RequestPriorityClass GetFrontPriorityClass();
85 /** Really a synonym for RemoveRequest(GetFront());
87 void PopFront();
89 /** Returns <TRUE/> when there is no element in the queue.
91 bool IsEmpty();
93 /** Remove all requests from the queue. This resets the minimum and
94 maximum priorities to their default values.
96 void Clear();
98 /** Return the mutex that guards the access to the priority queue.
100 ::osl::Mutex& GetMutex() { return maMutex;}
102 /** Ensure we don't hand out a page deleted before anyone got a
103 chance to process it
105 virtual void PageInDestruction(const SdrPage& rPage) SAL_OVERRIDE;
107 private:
108 ::osl::Mutex maMutex;
109 class Container;
110 ::boost::scoped_ptr<Container> mpRequestQueue;
111 SharedCacheContext mpCacheContext;
113 /** A lower bound of the lowest priority of all elements in the queues.
114 The start value is 0. It is assigned and then decreased every time
115 when an element is inserted or marked as the request with lowest
116 priority.
118 int mnMinimumPriority;
119 /** An upper bound of the highest priority of all elements in the queues.
120 The start value is 1. It is assigned and then increased every time
121 when an element is inserted or marked as the request with highest
122 priority.
124 int mnMaximumPriority;
127 } } } // end of namespace ::sd::slidesorter::cache
129 #endif
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */