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 .
19 #ifndef INCLUDED_SLIDESHOW_SOURCE_INC_WAKEUPEVENT_HXX
20 #define INCLUDED_SLIDESHOW_SOURCE_INC_WAKEUPEVENT_HXX
22 #include <canvas/elapsedtime.hxx>
25 #include "activitiesqueue.hxx"
27 namespace slideshow::internal
{
29 /** Little helper class, used to set Activities active again
30 after some sleep period.
32 Clients can use this class to schedule wakeup events at
33 the EventQueue, to avoid busy-waiting for the next
34 discrete time instant.
36 class WakeupEvent
: public Event
40 std::shared_ptr
< ::canvas::tools::ElapsedTime
> const& pTimeBase
,
41 ActivitiesQueue
& rActivityQueue
);
42 WakeupEvent(const WakeupEvent
&) = delete;
43 WakeupEvent
& operator=(const WakeupEvent
&) = delete;
45 virtual void dispose() override
;
46 virtual bool fire() override
;
47 virtual bool isCharged() const override
;
48 virtual double getActivationTime( double nCurrentTime
) const override
;
50 /// Start the internal timer
53 /** Set the next timeout this object should generate.
56 Absolute time, measured from the last start() call,
57 when this event should wakeup the Activity again. If
58 your time is relative, simply call start() just before
59 every setNextTimeout() call.
61 void setNextTimeout( double nextTime
);
63 /** Set activity to wakeup.
65 The activity given here will be reinserted into the
66 ActivitiesQueue, once the timeout is reached.
68 void setActivity( const ActivitySharedPtr
& rActivity
);
71 ::canvas::tools::ElapsedTime maTimer
;
73 ActivitySharedPtr mpActivity
;
74 ActivitiesQueue
& mrActivityQueue
;
77 typedef ::std::shared_ptr
< WakeupEvent
> WakeupEventSharedPtr
;
79 } // namespace presentation::internal
81 #endif // INCLUDED_SLIDESHOW_SOURCE_INC_WAKEUPEVENT_HXX
83 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */