4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Angus Leeming
9 * Full author contact details are available in file CREDITS.
11 * FileMonitor monitors a file and informs a listener when that file has
18 #include <boost/utility.hpp>
19 #include <boost/scoped_ptr.hpp>
20 #include <boost/signal.hpp>
25 class FileMonitor : boost::noncopyable {
27 /** Once monitoring begins, the file will be monitored every
30 FileMonitor(std::string const & file_with_path, int interval);
32 /// Define an empty d-tor out-of-line to keep boost::scoped_ptr happy.
36 void reset(std::string const & file_with_path) const;
39 std::string const & filename() const;
41 /// Begin monitoring the file
46 bool monitoring() const;
48 /** The checksum is recomputed whenever the file is modified.
49 * If the file is not being monitored, then the checksum will be
50 * recomputed each time this function is called.
52 unsigned long checksum() const;
54 /// Connect and you'll be informed when the file has changed.
55 typedef boost::signal<void()> FileChangedSig;
56 typedef FileChangedSig::slot_type slot_type;
58 boost::signals::connection connect(slot_type const &) const;
61 /// Use the Pimpl idiom to hide the internals.
64 /// The pointer never changes although *pimpl_'s contents may.
65 boost::scoped_ptr<Impl> const pimpl_;
68 } // namespace support
71 #endif // FILEMONITOR_H