Branch libreoffice-5-0-4
[LibreOffice.git] / include / vcl / timer.hxx
blob8835291cac7e4a06eb26e7f2cc5c5852a08c2b06
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 .
20 #ifndef INCLUDED_VCL_TIMER_HXX
21 #define INCLUDED_VCL_TIMER_HXX
23 #include <tools/link.hxx>
24 #include <vcl/scheduler.hxx>
26 class VCL_DLLPUBLIC Timer : public Scheduler
28 protected:
29 Link<Timer *, void> maTimeoutHdl; // Callback Link
30 sal_uInt64 mnTimeout;
31 bool mbAuto;
33 virtual void SetDeletionFlags() SAL_OVERRIDE;
34 virtual bool ReadyForSchedule( bool bTimer ) SAL_OVERRIDE;
35 virtual sal_uInt64 UpdateMinPeriod( sal_uInt64 nMinPeriod, sal_uInt64 nTime ) SAL_OVERRIDE;
37 private:
38 static void InitSystemTimer();
40 public:
41 Timer( const sal_Char *pDebugName = NULL );
42 Timer( const Timer& rTimer );
44 /// Make it possible to associate a callback with this timer handler
45 /// of course, you can also sub-class and override 'Invoke'
46 void SetTimeoutHdl( const Link<Timer *, void>& rLink ) { maTimeoutHdl = rLink; }
47 const Link<Timer *, void>& GetTimeoutHdl() const { return maTimeoutHdl; }
48 void SetTimeout( sal_uInt64 nTimeoutMs );
49 sal_uInt64 GetTimeout() const { return mnTimeout; }
50 virtual void Invoke() SAL_OVERRIDE;
51 void Timeout() { Invoke(); }
52 Timer& operator=( const Timer& rTimer );
53 virtual void Start() SAL_OVERRIDE;
54 static void ImplStartTimer( ImplSVData* pSVData, sal_uInt64 nMS );
57 /// An auto-timer is a multi-shot timer re-emitting itself at
58 /// interval until destroyed.
59 class VCL_DLLPUBLIC AutoTimer : public Timer
61 public:
62 AutoTimer();
63 AutoTimer( const AutoTimer& rTimer );
65 AutoTimer& operator=( const AutoTimer& rTimer );
68 #endif // INCLUDED_VCL_TIMER_HXX
70 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */