update dev300-m58
[ooovba.git] / slideshow / source / inc / wakeupevent.hxx
blob766e253367c8529d9af74e6135366eb6c39ad54f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: wakeupevent.hxx,v $
10 * $Revision: 1.9 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef INCLUDED_SLIDESHOW_WAKEUPEVENT_HXX
31 #define INCLUDED_SLIDESHOW_WAKEUPEVENT_HXX
33 #include <canvas/elapsedtime.hxx>
35 #include "event.hxx"
36 #include "activitiesqueue.hxx"
38 #include <boost/bind.hpp>
39 #include <boost/noncopyable.hpp>
41 namespace slideshow {
42 namespace internal {
44 /** Little helper class, used to set Activities active again
45 after some sleep period.
47 Clients can use this class to schedule wakeup events at
48 the EventQueue, to avoid busy-waiting for the next
49 discrete time instant.
51 class WakeupEvent : public Event,
52 private ::boost::noncopyable
54 public:
55 WakeupEvent(
56 ::boost::shared_ptr< ::canvas::tools::ElapsedTime > const& pTimeBase,
57 ActivitiesQueue & rActivityQueue );
59 virtual void dispose();
60 virtual bool fire();
61 virtual bool isCharged() const;
62 virtual double getActivationTime( double nCurrentTime ) const;
64 /// Start the internal timer
65 void start();
67 /** Set the next timeout this object should generate.
69 @param nextTime
70 Absolute time, measured from the last start() call,
71 when this event should wakeup the Activity again. If
72 your time is relative, simply call start() just before
73 every setNextTimeout() call.
75 void setNextTimeout( double nextTime );
77 /** Set activity to wakeup.
79 The activity given here will be reinserted into the
80 ActivitiesQueue, once the timeout is reached.
82 void setActivity( const ActivitySharedPtr& rActivity );
84 private:
85 ::canvas::tools::ElapsedTime maTimer;
86 double mnNextTime;
87 ActivitySharedPtr mpActivity;
88 ActivitiesQueue& mrActivityQueue;
91 typedef ::boost::shared_ptr< WakeupEvent > WakeupEventSharedPtr;
93 } // namespace internal
94 } // namespace presentation
96 #endif /* INCLUDED_SLIDESHOW_WAKEUPEVENT_HXX */