2010-10-14 08:27:31 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-21 14:30:25 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2007-04-11 17:15:08 +00:00
|
|
|
|
2013-10-23 19:10:20 +02:00
|
|
|
#ifndef INCLUDED_VCL_TIMER_HXX
|
|
|
|
#define INCLUDED_VCL_TIMER_HXX
|
2007-04-11 17:15:08 +00:00
|
|
|
|
|
|
|
#include <tools/link.hxx>
|
2015-02-26 07:33:59 +00:00
|
|
|
#include <vcl/scheduler.hxx>
|
2007-04-11 17:15:08 +00:00
|
|
|
|
2015-02-26 07:33:59 +00:00
|
|
|
class VCL_DLLPUBLIC Timer : public Scheduler
|
2007-04-11 17:15:08 +00:00
|
|
|
{
|
|
|
|
protected:
|
2015-05-04 17:28:40 +02:00
|
|
|
Link<Timer *, void> maTimeoutHdl; // Callback Link
|
2015-03-09 08:44:26 +00:00
|
|
|
sal_uInt64 mnTimeout;
|
2013-11-17 00:35:56 -02:00
|
|
|
bool mbAuto;
|
2007-04-11 17:15:08 +00:00
|
|
|
|
2015-03-06 15:45:03 +01:00
|
|
|
virtual void SetDeletionFlags() SAL_OVERRIDE;
|
|
|
|
virtual bool ReadyForSchedule( bool bTimer ) SAL_OVERRIDE;
|
2015-03-09 08:44:26 +00:00
|
|
|
virtual sal_uInt64 UpdateMinPeriod( sal_uInt64 nMinPeriod, sal_uInt64 nTime ) SAL_OVERRIDE;
|
2014-11-05 17:57:15 +01:00
|
|
|
|
2015-03-11 12:58:42 +00:00
|
|
|
private:
|
2015-03-11 13:10:34 +00:00
|
|
|
static void InitSystemTimer();
|
2015-03-11 12:58:42 +00:00
|
|
|
|
2007-04-11 17:15:08 +00:00
|
|
|
public:
|
2015-06-10 12:08:00 +01:00
|
|
|
Timer( const sal_Char *pDebugName = NULL );
|
2015-02-26 07:33:59 +00:00
|
|
|
Timer( const Timer& rTimer );
|
2007-04-11 17:15:08 +00:00
|
|
|
|
2015-02-26 07:33:59 +00:00
|
|
|
/// Make it possible to associate a callback with this timer handler
|
|
|
|
/// of course, you can also sub-class and override 'Invoke'
|
2015-05-04 17:28:40 +02:00
|
|
|
void SetTimeoutHdl( const Link<Timer *, void>& rLink ) { maTimeoutHdl = rLink; }
|
|
|
|
const Link<Timer *, void>& GetTimeoutHdl() const { return maTimeoutHdl; }
|
2015-03-09 08:44:26 +00:00
|
|
|
void SetTimeout( sal_uInt64 nTimeoutMs );
|
|
|
|
sal_uInt64 GetTimeout() const { return mnTimeout; }
|
2015-02-26 07:33:59 +00:00
|
|
|
virtual void Invoke() SAL_OVERRIDE;
|
2015-03-05 14:05:15 +00:00
|
|
|
void Timeout() { Invoke(); }
|
2007-04-11 17:15:08 +00:00
|
|
|
Timer& operator=( const Timer& rTimer );
|
2015-03-09 08:44:26 +00:00
|
|
|
virtual void Start() SAL_OVERRIDE;
|
|
|
|
static void ImplStartTimer( ImplSVData* pSVData, sal_uInt64 nMS );
|
2007-04-11 17:15:08 +00:00
|
|
|
};
|
|
|
|
|
2014-09-25 16:20:36 +01:00
|
|
|
/// An auto-timer is a multi-shot timer re-emitting itself at
|
|
|
|
/// interval until destroyed.
|
2007-04-11 17:15:08 +00:00
|
|
|
class VCL_DLLPUBLIC AutoTimer : public Timer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
AutoTimer();
|
|
|
|
AutoTimer( const AutoTimer& rTimer );
|
|
|
|
|
|
|
|
AutoTimer& operator=( const AutoTimer& rTimer );
|
|
|
|
};
|
2015-02-26 07:33:59 +00:00
|
|
|
|
2013-10-23 19:10:20 +02:00
|
|
|
#endif // INCLUDED_VCL_TIMER_HXX
|
2010-10-14 08:27:31 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|