Branch data 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 : :
20 : :
21 : : // must be first
22 : : #include <canvas/debug.hxx>
23 : : #include <canvas/verbosetrace.hxx>
24 : :
25 : : #include <wakeupevent.hxx>
26 : :
27 : :
28 : : namespace slideshow
29 : : {
30 : : namespace internal
31 : : {
32 : 0 : WakeupEvent::WakeupEvent(
33 : : boost::shared_ptr<canvas::tools::ElapsedTime> const & pTimeBase,
34 : : ActivitiesQueue& rActivityQueue ) :
35 : : #if OSL_DEBUG_LEVEL > 1
36 : : Event(::rtl::OUString("WakeupEvent")),
37 : : #endif
38 : : maTimer(pTimeBase),
39 : : mnNextTime(0.0),
40 : : mpActivity(),
41 : 0 : mrActivityQueue( rActivityQueue )
42 : : {
43 : 0 : }
44 : :
45 : 0 : void WakeupEvent::dispose()
46 : : {
47 : 0 : mpActivity.reset();
48 : 0 : }
49 : :
50 : 0 : bool WakeupEvent::fire()
51 : : {
52 : 0 : if( !mpActivity )
53 : 0 : return false;
54 : :
55 : 0 : return mrActivityQueue.addActivity( mpActivity );
56 : : }
57 : :
58 : 0 : bool WakeupEvent::isCharged() const
59 : : {
60 : : // this event won't expire, we fire everytime we're
61 : : // re-inserted into the event queue.
62 : 0 : return true;
63 : : }
64 : :
65 : 0 : double WakeupEvent::getActivationTime( double nCurrentTime ) const
66 : : {
67 : 0 : const double nElapsedTime( maTimer.getElapsedTime() );
68 : :
69 : : return ::std::max( nCurrentTime,
70 : 0 : nCurrentTime - nElapsedTime + mnNextTime );
71 : : }
72 : :
73 : 0 : void WakeupEvent::start()
74 : : {
75 : : // start timer
76 : 0 : maTimer.reset();
77 : 0 : }
78 : :
79 : 0 : void WakeupEvent::setNextTimeout( double rNextTime )
80 : : {
81 : 0 : mnNextTime = rNextTime;
82 : 0 : }
83 : :
84 : 0 : void WakeupEvent::setActivity( const ActivitySharedPtr& rActivity )
85 : : {
86 : 0 : mpActivity = rActivity;
87 : 0 : }
88 : : }
89 : 0 : }
90 : :
91 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|