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 : #ifndef INCLUDED_SLIDESHOW_WAKEUPEVENT_HXX
20 : #define INCLUDED_SLIDESHOW_WAKEUPEVENT_HXX
21 :
22 : #include <canvas/elapsedtime.hxx>
23 :
24 : #include "event.hxx"
25 : #include "activitiesqueue.hxx"
26 :
27 : #include <boost/bind.hpp>
28 : #include <boost/noncopyable.hpp>
29 :
30 : namespace slideshow {
31 : namespace internal {
32 :
33 : /** Little helper class, used to set Activities active again
34 : after some sleep period.
35 :
36 : Clients can use this class to schedule wakeup events at
37 : the EventQueue, to avoid busy-waiting for the next
38 : discrete time instant.
39 : */
40 0 : class WakeupEvent : public Event,
41 : private ::boost::noncopyable
42 : {
43 : public:
44 : WakeupEvent(
45 : ::boost::shared_ptr< ::canvas::tools::ElapsedTime > const& pTimeBase,
46 : ActivitiesQueue & rActivityQueue );
47 :
48 : virtual void dispose() SAL_OVERRIDE;
49 : virtual bool fire() SAL_OVERRIDE;
50 : virtual bool isCharged() const SAL_OVERRIDE;
51 : virtual double getActivationTime( double nCurrentTime ) const SAL_OVERRIDE;
52 :
53 : /// Start the internal timer
54 : void start();
55 :
56 : /** Set the next timeout this object should generate.
57 :
58 : @param nextTime
59 : Absolute time, measured from the last start() call,
60 : when this event should wakeup the Activity again. If
61 : your time is relative, simply call start() just before
62 : every setNextTimeout() call.
63 : */
64 : void setNextTimeout( double nextTime );
65 :
66 : /** Set activity to wakeup.
67 :
68 : The activity given here will be reinserted into the
69 : ActivitiesQueue, once the timeout is reached.
70 : */
71 : void setActivity( const ActivitySharedPtr& rActivity );
72 :
73 : private:
74 : ::canvas::tools::ElapsedTime maTimer;
75 : double mnNextTime;
76 : ActivitySharedPtr mpActivity;
77 : ActivitiesQueue& mrActivityQueue;
78 : };
79 :
80 : typedef ::boost::shared_ptr< WakeupEvent > WakeupEventSharedPtr;
81 :
82 : } // namespace internal
83 : } // namespace presentation
84 :
85 : #endif /* INCLUDED_SLIDESHOW_WAKEUPEVENT_HXX */
86 :
87 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|