2002-07-18 14:01:42 +00:00
|
|
|
// -*- C++ -*-
|
2002-09-25 10:03:41 +00:00
|
|
|
/**
|
2002-07-18 14:01:42 +00:00
|
|
|
* \file FileMonitor.h
|
2002-09-25 10:03:41 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-07-18 14:01:42 +00:00
|
|
|
*
|
2002-09-25 10:03:41 +00:00
|
|
|
* \author Angus Leeming
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-07-18 14:01:42 +00:00
|
|
|
*
|
|
|
|
* FileMonitor monitors a file and informs a listener when that file has
|
|
|
|
* changed.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef FILEMONITOR_H
|
|
|
|
#define FILEMONITOR_H
|
|
|
|
|
2017-02-27 22:46:10 +00:00
|
|
|
// TODO: Remove FileMonitor
|
|
|
|
#include "support/FileMonitor2.h"
|
|
|
|
|
2016-06-09 20:25:34 +00:00
|
|
|
#include <boost/signals2.hpp>
|
2002-07-18 14:01:42 +00:00
|
|
|
|
2003-06-30 23:56:22 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace support {
|
|
|
|
|
2006-11-26 21:30:39 +00:00
|
|
|
class FileName;
|
|
|
|
|
2007-11-29 07:11:08 +00:00
|
|
|
class FileMonitor
|
|
|
|
{
|
2002-07-18 14:01:42 +00:00
|
|
|
public:
|
|
|
|
/** Once monitoring begins, the file will be monitored every
|
|
|
|
* interval ms.
|
2007-11-30 09:49:35 +00:00
|
|
|
*
|
2017-02-27 22:46:10 +00:00
|
|
|
* This is now obsoleted by FileMonitor2 based on QFileSystemWatcher.
|
|
|
|
* FIXME: Remove FileMonitor
|
2002-07-18 14:01:42 +00:00
|
|
|
*/
|
2006-11-26 21:30:39 +00:00
|
|
|
FileMonitor(FileName const & file_with_path, int interval);
|
2002-07-18 14:01:42 +00:00
|
|
|
|
2007-11-29 07:11:08 +00:00
|
|
|
/// Destructor
|
2002-07-18 14:01:42 +00:00
|
|
|
~FileMonitor();
|
|
|
|
|
|
|
|
///
|
2006-11-26 21:30:39 +00:00
|
|
|
void reset(FileName const & file_with_path) const;
|
2002-07-18 14:01:42 +00:00
|
|
|
|
|
|
|
///
|
2006-11-26 21:30:39 +00:00
|
|
|
FileName const & filename() const;
|
2002-07-18 14:01:42 +00:00
|
|
|
|
|
|
|
/// Begin monitoring the file
|
|
|
|
void start() const;
|
|
|
|
///
|
|
|
|
void stop() const;
|
|
|
|
///
|
|
|
|
bool monitoring() const;
|
|
|
|
|
|
|
|
/** The checksum is recomputed whenever the file is modified.
|
|
|
|
* If the file is not being monitored, then the checksum will be
|
|
|
|
* recomputed each time this function is called.
|
|
|
|
*/
|
|
|
|
unsigned long checksum() const;
|
|
|
|
|
|
|
|
/// Connect and you'll be informed when the file has changed.
|
2016-06-09 20:25:34 +00:00
|
|
|
typedef boost::signals2::signal<void()> FileChangedSig;
|
2004-09-26 14:19:47 +00:00
|
|
|
typedef FileChangedSig::slot_type slot_type;
|
2002-07-18 14:01:42 +00:00
|
|
|
///
|
2016-06-09 20:25:34 +00:00
|
|
|
boost::signals2::connection connect(slot_type const &) const;
|
2002-07-18 14:01:42 +00:00
|
|
|
|
|
|
|
private:
|
2007-11-29 07:11:08 +00:00
|
|
|
/// noncopyable
|
|
|
|
FileMonitor(FileMonitor const &);
|
|
|
|
void operator=(FileMonitor const &);
|
|
|
|
|
2002-07-18 14:01:42 +00:00
|
|
|
/// Use the Pimpl idiom to hide the internals.
|
|
|
|
class Impl;
|
|
|
|
/// The pointer never changes although *pimpl_'s contents may.
|
2007-11-29 07:11:08 +00:00
|
|
|
Impl * const pimpl_;
|
2002-07-18 14:01:42 +00:00
|
|
|
};
|
|
|
|
|
2003-06-30 23:56:22 +00:00
|
|
|
} // namespace support
|
|
|
|
} // namespace lyx
|
|
|
|
|
2002-07-18 14:01:42 +00:00
|
|
|
#endif // FILEMONITOR_H
|