libfswatch  1.9.3
fsevents_monitor.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2016 Enrico M. Crisostomo
3  *
4  * This program is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU General Public License as published by the Free Software
6  * Foundation; either version 3, or (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11  * details.
12  *
13  * You should have received a copy of the GNU General Public License along with
14  * this program. If not, see <http://www.gnu.org/licenses/>.
15  */
26 #ifndef FSW_FSEVENT_MONITOR_H
27 # define FSW_FSEVENT_MONITOR_H
28 
29 # include "monitor.hpp"
30 # include <CoreServices/CoreServices.h>
31 
32 namespace fsw
33 {
39  class fsevents_monitor : public monitor
40  {
41  REGISTER_MONITOR(fsevents_monitor, fsevents_monitor_type);
42 
43  public:
47  fsevents_monitor(std::vector<std::string> paths,
49  void *context = nullptr);
53  virtual ~fsevents_monitor();
54 
55  protected:
63  void run() override;
64 
68  void on_stop() override;
69 
70  private:
71  fsevents_monitor(const fsevents_monitor& orig) = delete;
72  fsevents_monitor& operator=(const fsevents_monitor& that) = delete;
73 
74  static void fsevents_callback(ConstFSEventStreamRef streamRef,
75  void *clientCallBackInfo,
76  size_t numEvents,
77  void *eventPaths,
78  const FSEventStreamEventFlags eventFlags[],
79  const FSEventStreamEventId eventIds[]);
80 
81  FSEventStreamRef stream = nullptr;
82  CFRunLoopRef run_loop = nullptr;
83  };
84 }
85 
86 #endif /* FSW_FSEVENT_MONITOR_H */
OS X FSEvents monitor.
Definition: fsevents_monitor.hpp:39
void * context
Pointer to context data that will be passed to the monitor::callback.
Definition: monitor.hpp:553
Base class of all monitors.
Definition: monitor.hpp:146
Main namespace of libfswatch.
Definition: event.cpp:23
fsevents_monitor(std::vector< std::string > paths, FSW_EVENT_CALLBACK *callback, void *context=nullptr)
Constructs an instance of this class.
void on_stop() override
Execute an implementation-specific stop handler.
Definition: fsevents_monitor.cpp:147
Definition: cmonitor.h:46
Header of the fsw::monitor class.
virtual ~fsevents_monitor()
Destroys an instance of this class.
Definition: fsevents_monitor.cpp:76
void run() override
Executes the monitor loop.
Definition: fsevents_monitor.cpp:80
std::vector< std::string > paths
List of paths to watch.
Definition: monitor.hpp:533
FSW_EVENT_CALLBACK * callback
Callback to which change events should be notified.
Definition: monitor.hpp:548
void FSW_EVENT_CALLBACK(const std::vector< event > &, void *)
Function definition of an event callback.
Definition: monitor.hpp:60