+///
+/// Watch a file:
+/// FileMonitorPtr monitor = FileSystemWatcher::monitor(file_with_path);
+/// monitor.connect(...); //(using boost::signals2), or:
+/// connect(monitor, SIGNAL(fileChanged()),...); // (using Qt)
+///
+/// Remember that a unique_ptr is automatically deleted at the end of a scope if
+/// it has not been moved, or when assigned. When that happens, the signal
+/// object is deleted and therefore all the connections are closed. The file
+/// ceases being tracked when all the monitors for a file have been deleted.
+///
+/// Stop watching:
+/// * as determined statically by the scope, or
+/// * dynamically, using:
+/// monitor = nullptr;
+///
+/// Watch a different file:
+/// monitor = FileSystemWatcher::monitor(file_with_path2);
+/// monitor.connect(...);
+/// (stops watching the first)
+///
+class FileSystemWatcher
+{
+public:
+ /// as described above
+ static FileMonitorPtr monitor(FileName const & filename);
+ /// same but with an ActiveFileMonitor
+ static ActiveFileMonitorPtr activeMonitor(FileName const & filename,
+ int interval = 10000);
+ /// Output whether the paths tracked by qwatcher_ and the active
+ /// FileMonitorGuards are in correspondence.
+ static void debug();
+private:
+ FileSystemWatcher();
+ /// A global instance is created automatically on first call
+ static FileSystemWatcher & instance();