1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <osl/mutex.hxx>
26 #include <svx/sdrpageuser.hxx>
30 namespace sd
{ namespace slidesorter
{ namespace cache
{
32 /** The request queue stores requests that are described by the Request
33 sorted according to priority class and then priority.
35 class RequestQueue
: public sdr::PageUser
38 explicit RequestQueue (const SharedCacheContext
& rpCacheContext
);
39 virtual ~RequestQueue();
41 /** Insert a request with highest or lowest priority in its priority
42 class. When the request is already present then it is first
43 removed. This effect is then a re-prioritization.
47 The priority class in which to insert the request with highest
49 @param bInsertWithHighestPriority
50 When this flag is <TRUE/> the request is inserted with highest
51 priority in its class. When <FALSE/> the request is inserted
56 RequestPriorityClass eRequestClass
);
58 /** Remove the specified request from the queue.
60 It is OK when the specified request is not a member of the
63 #if OSL_DEBUG_LEVEL >=2
68 RemoveRequest (CacheKey aKey
);
70 /** Change the priority class of the specified request.
74 RequestPriorityClass eNewRequestClass
);
76 /** Get the request with the highest priority int the highest priority class.
81 RequestPriorityClass
GetFrontPriorityClass();
83 /** Really a synonym for RemoveRequest(GetFront());
87 /** Returns <TRUE/> when there is no element in the queue.
91 /** Remove all requests from the queue. This resets the minimum and
92 maximum priorities to their default values.
96 /** Return the mutex that guards the access to the priority queue.
98 ::osl::Mutex
& GetMutex() { return maMutex
;}
100 /** Ensure we don't hand out a page deleted before anyone got a
103 virtual void PageInDestruction(const SdrPage
& rPage
) override
;
106 ::osl::Mutex maMutex
;
108 std::unique_ptr
<Container
> mpRequestQueue
;
109 SharedCacheContext mpCacheContext
;
111 /** A lower bound of the lowest priority of all elements in the queues.
112 The start value is 0. It is assigned and then decreased every time
113 when an element is inserted or marked as the request with lowest
116 int mnMinimumPriority
;
117 /** An upper bound of the highest priority of all elements in the queues.
118 The start value is 1. It is assigned and then increased every time
119 when an element is inserted or marked as the request with highest
122 int mnMaximumPriority
;
125 } } } // end of namespace ::sd::slidesorter::cache
129 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */