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_VCL_TIMER_HXX
21 : #define INCLUDED_VCL_TIMER_HXX
22 :
23 : #include <tools/link.hxx>
24 : #include <vcl/scheduler.hxx>
25 :
26 279052 : class VCL_DLLPUBLIC Timer : public Scheduler
27 : {
28 : protected:
29 : Link<Timer *, void> maTimeoutHdl; // Callback Link
30 : sal_uInt64 mnTimeout;
31 : bool mbAuto;
32 :
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;
36 :
37 : private:
38 : static void InitSystemTimer();
39 :
40 : public:
41 : Timer( const sal_Char *pDebugName = NULL );
42 : Timer( const Timer& rTimer );
43 :
44 : /// Make it possible to associate a callback with this timer handler
45 : /// of course, you can also sub-class and override 'Invoke'
46 257580 : void SetTimeoutHdl( const Link<Timer *, void>& rLink ) { maTimeoutHdl = rLink; }
47 8051 : const Link<Timer *, void>& GetTimeoutHdl() const { return maTimeoutHdl; }
48 : void SetTimeout( sal_uInt64 nTimeoutMs );
49 44750 : sal_uInt64 GetTimeout() const { return mnTimeout; }
50 : virtual void Invoke() SAL_OVERRIDE;
51 0 : void Timeout() { Invoke(); }
52 : Timer& operator=( const Timer& rTimer );
53 : virtual void Start() SAL_OVERRIDE;
54 : static void ImplStartTimer( ImplSVData* pSVData, sal_uInt64 nMS );
55 : };
56 :
57 : /// An auto-timer is a multi-shot timer re-emitting itself at
58 : /// interval until destroyed.
59 27943 : class VCL_DLLPUBLIC AutoTimer : public Timer
60 : {
61 : public:
62 : AutoTimer();
63 : AutoTimer( const AutoTimer& rTimer );
64 :
65 : AutoTimer& operator=( const AutoTimer& rTimer );
66 : };
67 :
68 : #endif // INCLUDED_VCL_TIMER_HXX
69 :
70 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|