Vuo  2.3.2
VuoFileWatcher.hh
Go to the documentation of this file.
1 
10 #pragma once
11 
12 #include <dispatch/dispatch.h>
13 
18 {
19 public:
33  virtual void fileChanged(const string &fileBeingWatched) = 0;
34 };
35 
40 {
41 public:
42  VuoFileWatcher(VuoFileWatcherDelegate *delegate, const string &fileToWatch, bool persistent=true);
44 
45 private:
46  VuoFileWatcher *parent;
47  VuoFileWatcherDelegate *delegate;
48  string fileToWatch;
49  bool persistent;
50  dispatch_queue_t queue;
51 
52  VuoFileWatcher(VuoFileWatcherDelegate *delegate, const string &fileToWatch, bool persistent, VuoFileWatcher *parent);
53  void initialize(VuoFileWatcherDelegate *delegate, const string &fileToWatch, bool persistent, VuoFileWatcher *parent);
54 
55  void startWatching();
56  int fileToWatchFD;
57  dispatch_source_t fileToWatchSource;
58  dispatch_group_t fileToWatchSourceRunning;
59  bool reopen;
60 
61  void periodicallyCheckForExistence();
62  dispatch_source_t periodicCheckForExistence;
63  dispatch_group_t periodicCheckForExistenceRunning;
64  static const double checkIntervalSeconds;
65 
66  void updateChildWatchers();
67  vector<VuoFileWatcher *> childWatchers;
68  dispatch_queue_t childWatchersQueue;
69 
70  void changeObserved();
71  dispatch_source_t changeNotificationDelay;
72  dispatch_group_t changeNotificationDelayRunning;
73  static const double changeNotificationDelaySeconds;
74 };