LCOV - code coverage report
Current view: top level - sd/source/ui/slidesorter/cache - SlsRequestQueue.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 1 100.0 %
Date: 2015-06-13 12:38:46 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_SD_SOURCE_UI_SLIDESORTER_CACHE_SLSREQUESTQUEUE_HXX
      21             : #define INCLUDED_SD_SOURCE_UI_SLIDESORTER_CACHE_SLSREQUESTQUEUE_HXX
      22             : 
      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>
      29             : 
      30             : namespace sd { namespace slidesorter { namespace cache {
      31             : 
      32             : class RequestData;
      33             : 
      34             : /** The request queue stores requests that are described by the RequestData
      35             :     sorted according to priority class and then priority.
      36             : */
      37             : class RequestQueue : public sdr::PageUser
      38             : {
      39             : public:
      40             :     RequestQueue (const SharedCacheContext& rpCacheContext);
      41             :     virtual ~RequestQueue();
      42             : 
      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.
      55             :     */
      56             :     void AddRequest (
      57             :         CacheKey aKey,
      58             :         RequestPriorityClass eRequestClass,
      59             :         bool bInsertWithHighestPriority = false);
      60             : 
      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.
      69             :     */
      70             :     bool RemoveRequest (CacheKey aKey);
      71             : 
      72             :     /** Change the priority class of the specified request.
      73             :     */
      74             :     void ChangeClass (
      75             :         CacheKey aKey,
      76             :         RequestPriorityClass eNewRequestClass);
      77             : 
      78             :     /** Get the request with the highest priority int the highest priority class.
      79             :     */
      80             :     CacheKey GetFront();
      81             : 
      82             :     // For debugging.
      83             :     RequestPriorityClass GetFrontPriorityClass();
      84             : 
      85             :     /** Really a synonym for RemoveRequest(GetFront());
      86             :     */
      87             :     void PopFront();
      88             : 
      89             :     /** Returns <TRUE/> when there is no element in the queue.
      90             :     */
      91             :     bool IsEmpty();
      92             : 
      93             :     /** Remove all requests from the queue.  This resets the minimum and
      94             :         maximum priorities to their default values.
      95             :     */
      96             :     void Clear();
      97             : 
      98             :     /** Return the mutex that guards the access to the priority queue.
      99             :     */
     100         290 :     ::osl::Mutex& GetMutex() { return maMutex;}
     101             : 
     102             :     /** Ensure we don't hand out a page deleted before anyone got a
     103             :         chance to process it
     104             :     */
     105             :     virtual void PageInDestruction(const SdrPage& rPage) SAL_OVERRIDE;
     106             : 
     107             : private:
     108             :     ::osl::Mutex maMutex;
     109             :     class Container;
     110             :     ::boost::scoped_ptr<Container> mpRequestQueue;
     111             :     SharedCacheContext mpCacheContext;
     112             : 
     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.
     117             :     */
     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.
     123             :     */
     124             :     int mnMaximumPriority;
     125             : };
     126             : 
     127             : } } } // end of namespace ::sd::slidesorter::cache
     128             : 
     129             : #endif
     130             : 
     131             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11