]> git.tdb.fi Git - libs/core.git/blob - source/fs/filemonitor.h
Add move semantics to Variant
[libs/core.git] / source / fs / filemonitor.h
1 #ifndef FILEMONITOR_H_
2 #define FILEMONITOR_H_
3
4 #include <msp/core/noncopyable.h>
5 #include <msp/fs/path.h>
6 #include <msp/io/eventdispatcher.h>
7
8 namespace Msp {
9 namespace FS {
10
11 class FileMonitor: NonCopyable
12 {
13 private:
14         struct Private;
15
16         struct MonitoredFile
17         {
18                 FS::Path path;
19                 bool modified = false;
20                 int tag = -1;
21         };
22
23 public:
24         sigc::signal<void, const FS::Path &> signal_file_modified;
25
26 private:
27         Private *priv = nullptr;
28         IO::EventDispatcher *event_disp = nullptr;
29         std::vector<MonitoredFile> files;
30
31 public:
32         FileMonitor();
33         ~FileMonitor();
34
35         void add_file(const FS::Path &);
36         void remove_file(const FS::Path &);
37 private:
38         void prepare_file(MonitoredFile &);
39         void cleanup_file(MonitoredFile &);
40
41 public:
42         void use_event_dispatcher(IO::EventDispatcher &);
43 private:
44         void platform_use_event_dispatcher();
45
46 public:
47         void tick();
48         void tick(const Msp::Time::TimeDelta &);
49 };
50
51 } // namespace FS
52 } // namespace Msp
53
54 #endif