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