diff options
Diffstat (limited to 'src/3rdParty/efsw/FileWatcherGeneric.hpp')
-rwxr-xr-x | src/3rdParty/efsw/FileWatcherGeneric.hpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/3rdParty/efsw/FileWatcherGeneric.hpp b/src/3rdParty/efsw/FileWatcherGeneric.hpp new file mode 100755 index 0000000..4cb0b67 --- /dev/null +++ b/src/3rdParty/efsw/FileWatcherGeneric.hpp | |||
@@ -0,0 +1,60 @@ | |||
1 | #ifndef EFSW_FILEWATCHERGENERIC_HPP | ||
2 | #define EFSW_FILEWATCHERGENERIC_HPP | ||
3 | |||
4 | #include <efsw/DirWatcherGeneric.hpp> | ||
5 | #include <efsw/FileWatcherImpl.hpp> | ||
6 | #include <efsw/WatcherGeneric.hpp> | ||
7 | #include <list> | ||
8 | |||
9 | namespace efsw { | ||
10 | |||
11 | /// Implementation for Generic File Watcher. | ||
12 | /// @class FileWatcherGeneric | ||
13 | class FileWatcherGeneric : public FileWatcherImpl { | ||
14 | public: | ||
15 | typedef std::list<WatcherGeneric*> WatchList; | ||
16 | |||
17 | FileWatcherGeneric( FileWatcher* parent ); | ||
18 | |||
19 | virtual ~FileWatcherGeneric(); | ||
20 | |||
21 | /// Add a directory watch | ||
22 | /// On error returns WatchID with Error type. | ||
23 | WatchID addWatch( const std::string& directory, FileWatchListener* watcher, bool recursive ); | ||
24 | |||
25 | /// Remove a directory watch. This is a brute force lazy search O(nlogn). | ||
26 | void removeWatch( const std::string& directory ); | ||
27 | |||
28 | /// Remove a directory watch. This is a map lookup O(logn). | ||
29 | void removeWatch( WatchID watchid ); | ||
30 | |||
31 | /// Updates the watcher. Must be called often. | ||
32 | void watch(); | ||
33 | |||
34 | /// Handles the action | ||
35 | void handleAction( Watcher* watch, const std::string& filename, unsigned long action, | ||
36 | std::string oldFilename = "" ); | ||
37 | |||
38 | /// @return Returns a list of the directories that are being watched | ||
39 | std::list<std::string> directories(); | ||
40 | |||
41 | protected: | ||
42 | Thread* mThread; | ||
43 | |||
44 | /// The last watchid | ||
45 | WatchID mLastWatchID; | ||
46 | |||
47 | /// Map of WatchID to WatchStruct pointers | ||
48 | WatchList mWatches; | ||
49 | |||
50 | Mutex mWatchesLock; | ||
51 | |||
52 | bool pathInWatches( const std::string& path ); | ||
53 | |||
54 | private: | ||
55 | void run(); | ||
56 | }; | ||
57 | |||
58 | } // namespace efsw | ||
59 | |||
60 | #endif | ||