]> git.sesse.net Git - casparcg/blob - common/polling_filesystem_monitor.h
* Replaced boost::timer with caspar::timer because of too low resolution on Linux...
[casparcg] / common / polling_filesystem_monitor.h
1 /*
2 * Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
3 *
4 * This file is part of CasparCG (www.casparcg.com).
5 *
6 * CasparCG is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * CasparCG is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * Author: Helge Norberg, helge.norberg@svt.se
20 */
21
22 #pragma once
23
24 #include "filesystem_monitor.h"
25
26 namespace caspar {
27
28 /**
29  * A portable filesystem monitor implementation which periodically polls the
30  * filesystem for changes. Will not react instantly but never misses any
31  * changes.
32  * <p>
33  * Will create a dedicated thread for each monitor created.
34  */
35 class polling_filesystem_monitor_factory : public filesystem_monitor_factory
36 {
37 public:
38         /**
39          * Constructor.
40          *
41          * @param scan_interval_millis The number of milliseconds between each
42          *                             scheduled scan. Lower values lowers the reaction
43          *                             time but causes more I/O.
44          */
45         polling_filesystem_monitor_factory(int scan_interval_millis = 5000);
46         virtual ~polling_filesystem_monitor_factory();
47         virtual filesystem_monitor::ptr create(
48                         const boost::filesystem::wpath& folder_to_watch,
49                         filesystem_event events_of_interest_mask,
50                         bool report_already_existing,
51                         const filesystem_monitor_handler& handler,
52                         const initial_files_handler& initial_files_handler);
53 private:
54         struct impl;
55         spl::unique_ptr<impl> impl_;
56 };
57
58 }