Bump version to 6.0-36
[LibreOffice.git] / slideshow / source / inc / wakeupevent.hxx
blob6992be9e761ddbdccfb362cf9bd8b80d72556971
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 .
19 #ifndef INCLUDED_SLIDESHOW_SOURCE_INC_WAKEUPEVENT_HXX
20 #define INCLUDED_SLIDESHOW_SOURCE_INC_WAKEUPEVENT_HXX
22 #include <canvas/elapsedtime.hxx>
24 #include "event.hxx"
25 #include "activitiesqueue.hxx"
27 namespace slideshow {
28 namespace internal {
30 /** Little helper class, used to set Activities active again
31 after some sleep period.
33 Clients can use this class to schedule wakeup events at
34 the EventQueue, to avoid busy-waiting for the next
35 discrete time instant.
37 class WakeupEvent : public Event
39 public:
40 WakeupEvent(
41 std::shared_ptr< ::canvas::tools::ElapsedTime > const& pTimeBase,
42 ActivitiesQueue & rActivityQueue );
43 WakeupEvent(const WakeupEvent&) = delete;
44 WakeupEvent& operator=(const WakeupEvent&) = delete;
46 virtual void dispose() override;
47 virtual bool fire() override;
48 virtual bool isCharged() const override;
49 virtual double getActivationTime( double nCurrentTime ) const override;
51 /// Start the internal timer
52 void start();
54 /** Set the next timeout this object should generate.
56 @param nextTime
57 Absolute time, measured from the last start() call,
58 when this event should wakeup the Activity again. If
59 your time is relative, simply call start() just before
60 every setNextTimeout() call.
62 void setNextTimeout( double nextTime );
64 /** Set activity to wakeup.
66 The activity given here will be reinserted into the
67 ActivitiesQueue, once the timeout is reached.
69 void setActivity( const ActivitySharedPtr& rActivity );
71 private:
72 ::canvas::tools::ElapsedTime maTimer;
73 double mnNextTime;
74 ActivitySharedPtr mpActivity;
75 ActivitiesQueue& mrActivityQueue;
78 typedef ::std::shared_ptr< WakeupEvent > WakeupEventSharedPtr;
80 } // namespace internal
81 } // namespace presentation
83 #endif // INCLUDED_SLIDESHOW_SOURCE_INC_WAKEUPEVENT_HXX
85 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */