LCOV - code coverage report
Current view: top level - sdext/source/presenter - PresenterTimer.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 2 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 2 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             : 
      20             : #ifndef INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERTIMER_HXX
      21             : #define INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERTIMER_HXX
      22             : 
      23             : #include <com/sun/star/awt/XCallback.hpp>
      24             : #include <com/sun/star/awt/XRequestCallback.hpp>
      25             : #include <cppuhelper/basemutex.hxx>
      26             : #include <cppuhelper/compbase1.hxx>
      27             : #include <osl/mutex.hxx>
      28             : #include <osl/time.h>
      29             : #include <rtl/ref.hxx>
      30             : #include <sal/types.h>
      31             : #include <boost/function.hpp>
      32             : #include <vector>
      33             : 
      34             : namespace com { namespace sun { namespace star { namespace uno {
      35             :     class XComponentContext;
      36             : } } } }
      37             : 
      38             : namespace sdext { namespace presenter {
      39             : 
      40             : /** The timer allows tasks to be scheduled for execution at a specified time
      41             :     in the future.
      42             : */
      43             : class PresenterTimer
      44             : {
      45             : public:
      46             :     /** A task is called with the current time.
      47             :     */
      48             :     typedef ::boost::function<void(const TimeValue&)> Task;
      49             : 
      50             :     static const sal_Int32 NotAValidTaskId = 0;
      51             : 
      52             :     /** Schedule a task to be executed repeatedly.  The task is executed the
      53             :         first time after nFirst nano-seconds (1000000000 corresponds to one
      54             :         second).  After that task is executed in intervalls that are
      55             :         nIntervall ns long until CancelTask is called.
      56             :     */
      57             :     static sal_Int32 ScheduleRepeatedTask (
      58             :         const Task& rTask,
      59             :         const sal_Int64 nFirst,
      60             :         const sal_Int64 nIntervall);
      61             : 
      62             :     static void CancelTask (const sal_Int32 nTaskId);
      63             : };
      64             : 
      65             : typedef cppu::WeakComponentImplHelper1<
      66             :     css::awt::XCallback
      67             :     > PresenterClockTimerInterfaceBase;
      68             : 
      69             : /** A timer that calls its listeners, typically clocks, every second to
      70             :     update their current time value.
      71             : */
      72             : class PresenterClockTimer
      73             :     : protected ::cppu::BaseMutex,
      74             :       public PresenterClockTimerInterfaceBase
      75             : {
      76             : public:
      77           0 :     class Listener {
      78             :     public:
      79             :         virtual void TimeHasChanged (const oslDateTime& rCurrentTime) = 0;
      80             : 
      81             :     protected:
      82           0 :         ~Listener() {}
      83             :     };
      84             :     typedef ::boost::shared_ptr<Listener> SharedListener;
      85             : 
      86             :     static ::rtl::Reference<PresenterClockTimer> Instance (
      87             :         const css::uno::Reference<css::uno::XComponentContext>& rxContext);
      88             : 
      89             :     void AddListener (const SharedListener& rListener);
      90             :     void RemoveListener (const SharedListener& rListener);
      91             : 
      92             :     static oslDateTime GetCurrentTime();
      93             : 
      94             :     // XCallback
      95             : 
      96             :     virtual void SAL_CALL notify (const css::uno::Any& rUserData)
      97             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      98             : 
      99             : private:
     100             :     static ::rtl::Reference<PresenterClockTimer> mpInstance;
     101             : 
     102             :     ::osl::Mutex maMutex;
     103             :     typedef ::std::vector<SharedListener> ListenerContainer;
     104             :     ListenerContainer maListeners;
     105             :     oslDateTime maDateTime;
     106             :     sal_Int32 mnTimerTaskId;
     107             :     bool mbIsCallbackPending;
     108             :     css::uno::Reference<css::awt::XRequestCallback> mxRequestCallback;
     109             : 
     110             :     PresenterClockTimer (
     111             :         const css::uno::Reference<css::uno::XComponentContext>& rxContext);
     112             :     virtual ~PresenterClockTimer();
     113             : 
     114             :     void CheckCurrentTime (const TimeValue& rCurrentTime);
     115             : };
     116             : 
     117             : } } // end of namespace ::sdext::presenter
     118             : 
     119             : #endif
     120             : 
     121             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11