4 * Copyright 2002 the LyX Team
5 * Read the file COPYING
7 * \author Angus Leeming <leeming@lyx.org>
9 * FileMonitor monitors a file and informs a listener when that file has
22 #include <boost/utility.hpp>
23 #include <boost/scoped_ptr.hpp>
24 #include <boost/signals/signal0.hpp>
26 class FileMonitor : boost::noncopyable {
28 /** Once monitoring begins, the file will be monitored every
31 FileMonitor(string const & file_with_path, int interval);
33 /// Define an empty d-tor out-of-line to keep boost::scoped_ptr happy.
37 void reset(string const & file_with_path) const;
40 string const & filename() const;
42 /// Begin monitoring the file
47 bool monitoring() const;
49 /** The checksum is recomputed whenever the file is modified.
50 * If the file is not being monitored, then the checksum will be
51 * recomputed each time this function is called.
53 unsigned long checksum() const;
55 /// Connect and you'll be informed when the file has changed.
56 typedef boost::signal0<void>::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 #endif // FILEMONITOR_H