LCOV - code coverage report
Current view: top level - sdext/source/presenter - PresenterTimer.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 2 0.0 %
Date: 2012-08-25 Functions: 0 2 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef SDEXT_PRESENTER_TIMER_HXX
      30                 :            : #define SDEXT_PRESENTER_TIMER_HXX
      31                 :            : 
      32                 :            : #include <com/sun/star/awt/XCallback.hpp>
      33                 :            : #include <com/sun/star/awt/XRequestCallback.hpp>
      34                 :            : #include <cppuhelper/basemutex.hxx>
      35                 :            : #include <cppuhelper/compbase1.hxx>
      36                 :            : #include <osl/mutex.hxx>
      37                 :            : #include <osl/time.h>
      38                 :            : #include <rtl/ref.hxx>
      39                 :            : #include <sal/types.h>
      40                 :            : #include <boost/enable_shared_from_this.hpp>
      41                 :            : #include <boost/function.hpp>
      42                 :            : #include <vector>
      43                 :            : 
      44                 :            : namespace css = ::com::sun::star;
      45                 :            : 
      46                 :            : namespace sdext { namespace presenter {
      47                 :            : 
      48                 :            : /** The timer allows tasks to be scheduled for execution at a specified time
      49                 :            :     in the future.
      50                 :            : */
      51                 :            : class PresenterTimer
      52                 :            : {
      53                 :            : public:
      54                 :            :     /** A task is called with the current time.
      55                 :            :     */
      56                 :            :     typedef ::boost::function<void(const TimeValue&)> Task;
      57                 :            : 
      58                 :            :     static const sal_Int32 NotAValidTaskId = 0;
      59                 :            : 
      60                 :            :     /** Schedule a task to be executed repeatedly.  The task is executed the
      61                 :            :         first time after nFirst nano-seconds (1000000000 corresponds to one
      62                 :            :         second).  After that task is executed in intervalls that are
      63                 :            :         nIntervall ns long until CancelTask is called.
      64                 :            :     */
      65                 :            :     static sal_Int32 ScheduleRepeatedTask (
      66                 :            :         const Task& rTask,
      67                 :            :         const sal_Int64 nFirst,
      68                 :            :         const sal_Int64 nIntervall);
      69                 :            : 
      70                 :            :     static void CancelTask (const sal_Int32 nTaskId);
      71                 :            : };
      72                 :            : 
      73                 :            : typedef cppu::WeakComponentImplHelper1<
      74                 :            :     css::awt::XCallback
      75                 :            :     > PresenterClockTimerInterfaceBase;
      76                 :            : 
      77                 :            : /** A timer that calls its listeners, typically clocks, every second to
      78                 :            :     update their current time value.
      79                 :            : */
      80                 :            : class PresenterClockTimer
      81                 :            :     : protected ::cppu::BaseMutex,
      82                 :            :       public PresenterClockTimerInterfaceBase
      83                 :            : {
      84                 :            : public:
      85                 :          0 :     class Listener {
      86                 :            :     public:
      87                 :            :         virtual void TimeHasChanged (const oslDateTime& rCurrentTime) = 0;
      88                 :            : 
      89                 :            :     protected:
      90                 :          0 :         ~Listener() {}
      91                 :            :     };
      92                 :            :     typedef ::boost::shared_ptr<Listener> SharedListener;
      93                 :            : 
      94                 :            :     static ::rtl::Reference<PresenterClockTimer> Instance (
      95                 :            :         const css::uno::Reference<css::uno::XComponentContext>& rxContext);
      96                 :            : 
      97                 :            :     void AddListener (const SharedListener& rListener);
      98                 :            :     void RemoveListener (const SharedListener& rListener);
      99                 :            : 
     100                 :            :     static oslDateTime GetCurrentTime (void);
     101                 :            : 
     102                 :            :     // XCallback
     103                 :            : 
     104                 :            :     virtual void SAL_CALL notify (const css::uno::Any& rUserData)
     105                 :            :         throw (css::uno::RuntimeException);
     106                 :            : 
     107                 :            : private:
     108                 :            :     static ::rtl::Reference<PresenterClockTimer> mpInstance;
     109                 :            : 
     110                 :            :     ::osl::Mutex maMutex;
     111                 :            :     typedef ::std::vector<SharedListener> ListenerContainer;
     112                 :            :     ListenerContainer maListeners;
     113                 :            :     oslDateTime maDateTime;
     114                 :            :     sal_Int32 mnTimerTaskId;
     115                 :            :     bool mbIsCallbackPending;
     116                 :            :     css::uno::Reference<css::awt::XRequestCallback> mxRequestCallback;
     117                 :            : 
     118                 :            :     PresenterClockTimer (
     119                 :            :         const css::uno::Reference<css::uno::XComponentContext>& rxContext);
     120                 :            :     ~PresenterClockTimer (void);
     121                 :            : 
     122                 :            :     void CheckCurrentTime (const TimeValue& rCurrentTime);
     123                 :            : };
     124                 :            : 
     125                 :            : } } // end of namespace ::sdext::presenter
     126                 :            : 
     127                 :            : #endif
     128                 :            : 
     129                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10