fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / slideshow / source / inc / delayevent.hxx
blobcbfd7599a3a86121f4befc980317e75355cff6d3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SLIDESHOW_SOURCE_INC_DELAYEVENT_HXX
20 #define INCLUDED_SLIDESHOW_SOURCE_INC_DELAYEVENT_HXX
22 #include <boost/function.hpp>
24 #include "event.hxx"
25 #include <boost/noncopyable.hpp>
27 namespace slideshow {
28 namespace internal {
30 /** Event, which delays the functor call the given amount of time
32 class Delay : public Event, private ::boost::noncopyable
34 public:
35 typedef ::boost::function0<void> FunctorT;
37 template <typename FuncT>
38 Delay( FuncT const& func,
39 double nTimeout
40 , const OUString& rsDescription
41 ) : Event(rsDescription),
42 mnTimeout(nTimeout), maFunc(func), mbWasFired(false) {}
44 Delay( const boost::function0<void>& func,
45 double nTimeout
46 , const OUString& rsDescription
47 ) : Event(rsDescription),
48 mnTimeout(nTimeout),
49 maFunc(func),
50 mbWasFired(false) {}
52 // Event:
53 virtual bool fire() SAL_OVERRIDE;
54 virtual bool isCharged() const SAL_OVERRIDE;
55 virtual double getActivationTime( double nCurrentTime ) const SAL_OVERRIDE;
56 // Disposable:
57 virtual void dispose() SAL_OVERRIDE;
59 private:
60 double const mnTimeout;
61 FunctorT maFunc;
62 bool mbWasFired;
65 #if OSL_DEBUG_LEVEL <= 1
67 /** Generate delay event
69 @param func
70 Functor to call when the event fires.
72 @param nTimeout
73 Timeout in seconds, to wait until functor is called.
75 @return generated delay event
77 template <typename FuncT>
78 inline EventSharedPtr makeDelay_( FuncT const& func, double nTimeout, OUString const& rsDescription )
80 return EventSharedPtr( new Delay( func, nTimeout, rsDescription ) );
83 /** Generate immediate event
85 @param func
86 Functor to call when the event fires.
88 @return generated immediate event.
90 template <typename FuncT>
91 inline EventSharedPtr makeEvent_( FuncT const& func, OUString const& rsDescription)
93 return EventSharedPtr( new Delay( func, 0.0, rsDescription ) );
97 #define makeDelay(f, t, d) makeDelay_(f, t, d)
98 #define makeEvent(f, d) makeEvent_(f, d)
100 #else // OSL_DEBUG_LEVEL > 1
102 class Delay_ : public Delay {
103 public:
104 template <typename FuncT>
105 Delay_( FuncT const& func, double nTimeout,
106 char const* from_function, char const* from_file, int from_line,
107 const OUString& rsDescription)
108 : Delay(func, nTimeout, rsDescription),
109 FROM_FUNCTION(from_function),
110 FROM_FILE(from_file), FROM_LINE(from_line) {}
112 char const* const FROM_FUNCTION;
113 char const* const FROM_FILE;
114 int const FROM_LINE;
117 template <typename FuncT>
118 inline EventSharedPtr makeDelay_(
119 FuncT const& func, double nTimeout,
120 char const* from_function, char const* from_file, int from_line,
121 const OUString& rsDescription)
123 return EventSharedPtr( new Delay_( func, nTimeout,
124 from_function, from_file, from_line, rsDescription) );
127 #define makeDelay(f, t, d) makeDelay_(f, t, \
128 BOOST_CURRENT_FUNCTION, __FILE__, __LINE__, \
130 #define makeEvent(f, d) makeDelay_(f, 0.0, \
131 BOOST_CURRENT_FUNCTION, __FILE__, __LINE__, \
134 #endif // OSL_DEBUG_LEVEL <= 1
136 } // namespace internal
137 } // namespace presentation
139 #endif // INCLUDED_SLIDESHOW_SOURCE_INC_DELAYEVENT_HXX
141 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */