bump product version to 6.3.0.0.beta1
[LibreOffice.git] / sd / source / ui / slidesorter / cache / SlsRequestQueue.hxx
blobb6c30586fd5a1dd5b2f422b8a32b2a74946addd5
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 <osl/mutex.hxx>
26 #include <svx/sdrpageuser.hxx>
28 #include <memory>
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
37 public:
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.
44 @param aKey
45 The request.
46 @param eRequestClass
47 The priority class in which to insert the request with highest
48 or lowest priority.
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
52 with lowest priority.
54 void AddRequest (
55 CacheKey aKey,
56 RequestPriorityClass eRequestClass);
58 /** Remove the specified request from the queue.
59 @param aKey
60 It is OK when the specified request is not a member of the
61 queue.
63 #if OSL_DEBUG_LEVEL >=2
64 bool
65 #else
66 void
67 #endif
68 RemoveRequest (CacheKey aKey);
70 /** Change the priority class of the specified request.
72 void ChangeClass (
73 CacheKey aKey,
74 RequestPriorityClass eNewRequestClass);
76 /** Get the request with the highest priority int the highest priority class.
78 CacheKey GetFront();
80 // For debugging.
81 RequestPriorityClass GetFrontPriorityClass();
83 /** Really a synonym for RemoveRequest(GetFront());
85 void PopFront();
87 /** Returns <TRUE/> when there is no element in the queue.
89 bool IsEmpty();
91 /** Remove all requests from the queue. This resets the minimum and
92 maximum priorities to their default values.
94 void Clear();
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
101 chance to process it
103 virtual void PageInDestruction(const SdrPage& rPage) override;
105 private:
106 ::osl::Mutex maMutex;
107 class Container;
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
114 priority.
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
120 priority.
122 int mnMaximumPriority;
125 } } } // end of namespace ::sd::slidesorter::cache
127 #endif
129 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */