Unravel Engine C++ Reference
Loading...
Searching...
No Matches
watcher_wtr.h
Go to the documentation of this file.
1#ifndef FS_WATCHER_WTR_H
2#define FS_WATCHER_WTR_H
3
4#include <atomic>
5#include <chrono>
6#include <condition_variable>
7#include <functional>
8#include <map>
9#include <memory>
10#include <mutex>
11#include <string>
12
13#include "../filesystem.h"
14#include "../pattern_filter.h"
15#include "../watcher.h"
16
17#include <hpp/event.hpp>
18
19namespace fs
20{
21
23{
24public:
25 //-----------------------------------------------------------------------------
26 // Name : ~watcher_wtr ()
32 //-----------------------------------------------------------------------------
34 watcher_wtr() = default;
35
36 //-----------------------------------------------------------------------------
37 // Name : watch_impl ()
43 //-----------------------------------------------------------------------------
44 auto watch_impl(const fs::path& path,
45 const pattern_filter& filter,
46 bool recursive,
47 bool initial_list,
48 watcher::clock_t::duration poll_interval,
50 const std::string& watcher_name) -> std::uint64_t;
51
52 void unwatch_impl(std::uint64_t key);
53
54 void unwatch_all_impl();
55
56 void pause();
57 void resume();
58
59 //-----------------------------------------------------------------------------
60 // Name : close ()
66 //-----------------------------------------------------------------------------
67 void close();
68
69 //-----------------------------------------------------------------------------
70 // Name : start ()
76 //-----------------------------------------------------------------------------
77 void start();
78
80 std::mutex mutex_;
82 std::atomic<bool> watching_ = {false};
83
84 std::condition_variable cv_;
85
87 class impl;
88 std::map<std::uint64_t, std::shared_ptr<impl>> watchers_;
89
92 std::map<fs::path, std::shared_ptr<directory_listener>> directory_listeners_;
93
94};
95
96} // namespace fs
97
98#endif
A filter that combines include and exclude patterns for file/directory filtering.
std::map< std::uint64_t, std::shared_ptr< impl > > watchers_
Definition watcher_wtr.h:88
auto watch_impl(const fs::path &path, const pattern_filter &filter, bool recursive, bool initial_list, watcher::clock_t::duration poll_interval, watcher::notify_callback callback, const std::string &watcher_name) -> std::uint64_t
std::atomic< bool > watching_
Atomic bool sync.
Definition watcher_wtr.h:82
watcher_wtr()=default
std::mutex mutex_
Mutex for the file watchers.
Definition watcher_wtr.h:80
std::condition_variable cv_
Definition watcher_wtr.h:84
void unwatch_impl(std::uint64_t key)
std::map< fs::path, std::shared_ptr< directory_listener > > directory_listeners_
Definition watcher_wtr.h:92
std::function< void(const std::vector< entry > &, bool)> notify_callback
Definition watcher.h:41
Definition cache.hpp:11