Loading...
Searching...
No Matches
RecursiveWatch.hpp
1#pragma once
2#include <ossia/detail/string_map.hpp>
3
4#include <QDebug>
5#include <QDir>
6#include <QString>
7
8#include <score_lib_base_export.h>
9
10#include <functional>
11#include <vector>
12
13namespace score
14{
15class SCORE_LIB_BASE_EXPORT RecursiveWatch
16{
17public:
18 struct Callbacks
19 {
20 std::function<void(std::string_view)> added;
21 std::function<void(std::string_view)> removed;
22 };
23
24 struct Watched
25 {
26 std::string ext;
27 Callbacks callbacks;
28 };
29
30 void setWatchedFolder(std::string root) { m_root = root; }
31
32 void registerWatch(std::string extension, Callbacks callbacks)
33 {
34 m_watched[extension].push_back(callbacks);
35 }
36
37 void scan() const;
38
39 void reset()
40 {
41 m_root.clear();
42 m_watched.clear();
43 }
44
45private:
46 std::string m_root;
47 ossia::string_map<std::vector<Callbacks>> m_watched;
48};
49
50SCORE_LIB_BASE_EXPORT
51void for_all_files(std::string_view root, std::function<void(std::string_view)> f);
52}
Definition RecursiveWatch.hpp:16
Base toolkit upon which the software is built.
Definition Application.cpp:90
Definition RecursiveWatch.hpp:19
Definition RecursiveWatch.hpp:25