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