office-gobmx/include/svtools/filechangedchecker.hxx
Jan-Marek Glogowski bf110d40ef Change all Idle* LINKs to be Timer*
Seem UBSAN doesn't like my forced reinterpret_cast to set the Idles
Link in the Timer class. Now there are two possible solution:

  1. convert all (DECL|IMPL).*_LINK call sites to use a Timer* or
  2. split the inheritance of Idle from Timer again to maintain
     different Link<>s and move all common code into a TimerBase.

While the 1st is more correct, the 2nd has a better indicator for
Idles. This implements the first solution.

And while at it, this also converts all call sites of SetTimeoutHdl
and SetIdleHdl to SetInvokeHandler and gets rid of some local Link
objects, which are just passed to the SetInvokeHandler call.

It also introduces ClearInvokeHandler() and replaces the respective
call sites of SetInvokeHandler( Link<Timer *, void>() ).

Change-Id: I40c4167b1493997b7f136add4dad2f4ff5504b69
2017-01-23 20:49:05 +01:00

44 lines
1.2 KiB
C++

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* 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/.
*/
#ifndef INCLUDED_SVTOOLS_FILECHANGEDCHECKER_HXX
#define INCLUDED_SVTOOLS_FILECHANGEDCHECKER_HXX
#include <svtools/svtdllapi.h>
#include <osl/file.hxx>
#include <vcl/timer.hxx>
#include <vcl/idle.hxx>
#include <functional>
/** Periodically checks if a file has been modified
Instances of this class setup a vcl timer to occasionally wake up
check whether file modification time has changed.
*/
class SVT_DLLPUBLIC FileChangedChecker
{
private:
Idle mIdle;
OUString mFileName;
TimeValue mLastModTime;
::std::function<void ()> mpCallback;
bool SVT_DLLPRIVATE getCurrentModTime(TimeValue& o_rValue) const;
DECL_LINK(TimerHandler, Timer *, void);
public:
void resetTimer();
bool hasFileChanged();
FileChangedChecker(const OUString& rFilename,
const ::std::function<void ()>& rCallback);
};
#endif