1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: wakeupevent.hxx,v $
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>
36 #include "activitiesqueue.hxx"
38 #include <boost/bind.hpp>
39 #include <boost/noncopyable.hpp>
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
56 ::boost::shared_ptr
< ::canvas::tools::ElapsedTime
> const& pTimeBase
,
57 ActivitiesQueue
& rActivityQueue
);
59 virtual void dispose();
61 virtual bool isCharged() const;
62 virtual double getActivationTime( double nCurrentTime
) const;
64 /// Start the internal timer
67 /** Set the next timeout this object should generate.
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
);
85 ::canvas::tools::ElapsedTime maTimer
;
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 */