]> git.sesse.net Git - casparcg/blob - common/polling_filesystem_monitor.h
[general] Changed permissions of files that should be marked as executable but wasn't.
[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 #include <boost/asio.hpp>
27
28 namespace caspar {
29
30 /**
31  * A portable filesystem monitor implementation which periodically polls the
32  * filesystem for changes. Will not react instantly but never misses any
33  * changes.
34  * <p>
35  * Will create a dedicated thread for each monitor created.
36  */
37 class polling_filesystem_monitor_factory : public filesystem_monitor_factory
38 {
39 public:
40         /**
41          * Constructor.
42          *
43          * @param scheduler            The io_service that will be used for
44          *                             scheduling periodic scans.
45          * @param scan_interval_millis The number of milliseconds between each
46          *                             scheduled scan. Lower values lowers the reaction
47          *                             time but causes more I/O.
48          */
49         polling_filesystem_monitor_factory(
50                         std::shared_ptr<boost::asio::io_service> scheduler,
51                         int scan_interval_millis = 5000);
52         virtual ~polling_filesystem_monitor_factory();
53         virtual filesystem_monitor::ptr create(
54                         const boost::filesystem::path& folder_to_watch,
55                         filesystem_event events_of_interest_mask,
56                         bool report_already_existing,
57                         const filesystem_monitor_handler& handler,
58                         const initial_files_handler& initial_files_handler);
59 private:
60         struct impl;
61         spl::unique_ptr<impl> impl_;
62 };
63
64 }