vcl: no raw pointers
[LibreOffice.git] / include / svtools / filechangedchecker.hxx
blob3edd07dbf8c84a8836f381f435fd0f0152355416
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/.
8 */
10 #pragma once
12 #include <svtools/svtdllapi.h>
14 #include <osl/time.h>
15 #include <rtl/ustring.hxx>
16 #include <vcl/timer.hxx>
18 #include <functional>
20 /** Periodically checks if a file has been modified
22 Instances of this class setup a vcl timer to occasionally wake up
23 check whether file modification time has changed.
25 class SVT_DLLPUBLIC FileChangedChecker
27 private:
28 Timer mTimer;
29 OUString mFileName;
30 TimeValue mLastModTime;
31 ::std::function<void ()> mpCallback;
33 bool SVT_DLLPRIVATE getCurrentModTime(TimeValue& o_rValue) const;
34 DECL_DLLPRIVATE_LINK(TimerHandler, Timer *, void);
36 public:
37 void resetTimer();
38 // bUpdate = true when file has changed, get the return and the object get the new time
39 // = false when file has changed, only get the return, not change the object
40 bool hasFileChanged(bool bUpdate = true);
41 FileChangedChecker(OUString aFilename,
42 ::std::function<void ()> aCallback);
43 // without Timer function
44 FileChangedChecker(OUString aFilename);