LCOV - code coverage report
Current view: top level - slideshow/source/inc - delayevent.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 9 0.0 %
Date: 2014-11-03 Functions: 0 37 0.0 %
Legend: Lines: hit not hit

          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             : #ifndef INCLUDED_SLIDESHOW_SOURCE_INC_DELAYEVENT_HXX
      20             : #define INCLUDED_SLIDESHOW_SOURCE_INC_DELAYEVENT_HXX
      21             : 
      22             : #include <boost/function.hpp>
      23             : 
      24             : #include "event.hxx"
      25             : #include <boost/noncopyable.hpp>
      26             : 
      27             : namespace slideshow {
      28             : namespace internal {
      29             : 
      30             : /** Event, which delays the functor call the given amount of time
      31             :  */
      32           0 : class Delay : public Event, private ::boost::noncopyable
      33             : {
      34             : public:
      35             :     typedef ::boost::function0<void> FunctorT;
      36             : 
      37             :     template <typename FuncT>
      38           0 :         Delay( FuncT const& func,
      39             :                double nTimeout
      40             :             ,  const OUString& rsDescription
      41             :             ) : Event(rsDescription),
      42           0 :             mnTimeout(nTimeout), maFunc(func), mbWasFired(false) {}
      43             : 
      44           0 :     Delay( const boost::function0<void>& func,
      45             :            double nTimeout
      46             :         , const OUString& rsDescription
      47             :         ) : Event(rsDescription),
      48             :         mnTimeout(nTimeout),
      49             :         maFunc(func),
      50           0 :         mbWasFired(false) {}
      51             : 
      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;
      58             : 
      59             : private:
      60             :     double const mnTimeout;
      61             :     FunctorT maFunc;
      62             :     bool mbWasFired;
      63             : };
      64             : 
      65             : #if OSL_DEBUG_LEVEL <= 1
      66             : 
      67             : /** Generate delay event
      68             : 
      69             :     @param func
      70             :     Functor to call when the event fires.
      71             : 
      72             :     @param nTimeout
      73             :     Timeout in seconds, to wait until functor is called.
      74             : 
      75             :     @return generated delay event
      76             : */
      77             : template <typename FuncT>
      78           0 : inline EventSharedPtr makeDelay_( FuncT const& func, double nTimeout, OUString const& rsDescription )
      79             : {
      80           0 :     return EventSharedPtr( new Delay( func, nTimeout, rsDescription ) );
      81             : }
      82             : 
      83             : /** Generate immediate event
      84             : 
      85             :     @param func
      86             :     Functor to call when the event fires.
      87             : 
      88             :     @return generated immediate event.
      89             : */
      90             : template <typename FuncT>
      91           0 : inline EventSharedPtr makeEvent_( FuncT const& func, OUString const& rsDescription)
      92             : {
      93           0 :     return EventSharedPtr( new Delay( func, 0.0, rsDescription ) );
      94             : }
      95             : 
      96             : 
      97             : #define makeDelay(f, t, d) makeDelay_(f, t, d)
      98             : #define makeEvent(f, d) makeEvent_(f, d)
      99             : 
     100             : #else // OSL_DEBUG_LEVEL > 1
     101             : 
     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) {}
     111             : 
     112             :     char const* const FROM_FUNCTION;
     113             :     char const* const FROM_FILE;
     114             :     int const FROM_LINE;
     115             : };
     116             : 
     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)
     122             : {
     123             :     return EventSharedPtr( new Delay_( func, nTimeout,
     124             :             from_function, from_file, from_line, rsDescription) );
     125             : }
     126             : 
     127             : #define makeDelay(f, t, d) makeDelay_(f, t,                   \
     128             :         BOOST_CURRENT_FUNCTION, __FILE__, __LINE__,           \
     129             :         d)
     130             : #define makeEvent(f, d) makeDelay_(f, 0.0,                  \
     131             :         BOOST_CURRENT_FUNCTION, __FILE__, __LINE__,         \
     132             :         d)
     133             : 
     134             : #endif // OSL_DEBUG_LEVEL <= 1
     135             : 
     136             : } // namespace internal
     137             : } // namespace presentation
     138             : 
     139             : #endif // INCLUDED_SLIDESHOW_SOURCE_INC_DELAYEVENT_HXX
     140             : 
     141             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10