LibreOffice Module slideshow (master) 1
eventqueue.hxx
Go to the documentation of this file.
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_SLIDESHOW_SOURCE_INC_EVENTQUEUE_HXX
21#define INCLUDED_SLIDESHOW_SOURCE_INC_EVENTQUEUE_HXX
22
24
25#include "event.hxx"
26
27#include <mutex>
28#include <queue>
29#include <utility>
30#include <vector>
31
32
33/* Definition of ActivitiesQueue class */
34
35namespace slideshow::internal
36 {
41 {
42 public:
44 std::shared_ptr< ::canvas::tools::ElapsedTime > pPresTimer );
45
47
48 EventQueue(const EventQueue&) = delete;
49 EventQueue& operator=(const EventQueue&) = delete;
50
54 bool addEvent( const EventSharedPtr& event );
55
61 bool addEventForNextRound( const EventSharedPtr& event );
62
68 bool addEventWhenQueueIsEmpty (const EventSharedPtr& rpEvent);
69
81 void process();
82
87 bool isEmpty() const;
88
101 double nextTimeout() const;
102
105 void clear();
106
111 void forceEmpty();
112
115 std::shared_ptr< ::canvas::tools::ElapsedTime > const &
116 getTimer() const { return mpTimer; }
117
118 private:
119 mutable std::mutex maMutex;
120
122 {
124 double nTime;
125
126 bool operator<( const EventEntry& ) const; // to leverage priority_queue's default compare
127
129 : pEvent(std::move(p)), nTime(t) {}
130 };
131
132 typedef ::std::priority_queue< EventEntry > ImplQueueType;
134 typedef ::std::vector<EventEntry> EventEntryVector;
137 void process_( bool bFireAllEvents );
138
139 // perform timing of events via relative time
140 // measurements. The world time starts, when the
141 // EventQueue object is created
142 std::shared_ptr< ::canvas::tools::ElapsedTime > mpTimer;
143 };
144
145}
146#endif // INCLUDED_SLIDESHOW_SOURCE_INC_EVENTQUEUE_HXX
147
148/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
XPropertyListType t
This class handles events in a presentation.
Definition: eventqueue.hxx:41
EventQueue(std::shared_ptr< ::canvas::tools::ElapsedTime > pPresTimer)
std::shared_ptr< ::canvas::tools::ElapsedTime > const & getTimer() const
Gets the queue's timer object.
Definition: eventqueue.hxx:116
std::shared_ptr< ::canvas::tools::ElapsedTime > mpTimer
Definition: eventqueue.hxx:142
bool addEventForNextRound(const EventSharedPtr &event)
Add the given event to the queue.
Definition: eventqueue.cxx:105
EventQueue & operator=(const EventQueue &)=delete
void forceEmpty()
Forces an empty queue, firing all events immediately without minding any times.
Definition: eventqueue.cxx:142
::std::priority_queue< EventEntry > ImplQueueType
Definition: eventqueue.hxx:132
EventQueue(const EventQueue &)=delete
bool addEvent(const EventSharedPtr &event)
Add the given event to the queue.
Definition: eventqueue.cxx:79
double nextTimeout() const
Query timeout for the topmost event in the queue.
Definition: eventqueue.cxx:266
::std::vector< EventEntry > EventEntryVector
Definition: eventqueue.hxx:134
void process()
Process the event queue.
Definition: eventqueue.cxx:147
void process_(bool bFireAllEvents)
Definition: eventqueue.cxx:152
bool addEventWhenQueueIsEmpty(const EventSharedPtr &rpEvent)
Another way to control the order of asynchronous event execution.
Definition: eventqueue.cxx:122
void clear()
Remove all pending events from the queue.
Definition: eventqueue.cxx:283
bool isEmpty() const
Query state of the queue.
Definition: eventqueue.cxx:259
void * p
::std::shared_ptr< Event > EventSharedPtr
Definition: event.hxx:76
bool operator<(const EventEntry &) const
Definition: eventqueue.cxx:37
EventEntry(EventSharedPtr p, double t)
Definition: eventqueue.hxx:128