libfswatch  1.9.3
fen_monitor.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-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_FEN_MONITOR_H
27 # define FSW_FEN_MONITOR_H
28 
29 # include "monitor.hpp"
30 # include <string>
31 # include <vector>
32 
33 namespace fsw
34 {
39  struct fen_monitor_load;
40 
45  struct fen_info;
46 
53  class fen_monitor : public monitor
54  {
55  REGISTER_MONITOR(fen_monitor, fen_monitor_type);
56 
57  public:
61  fen_monitor(std::vector<std::string> paths,
63  void *context = nullptr);
64 
68  virtual ~fen_monitor();
69 
70  protected:
78  void run() override;
79 
80  private:
81  fen_monitor(const fen_monitor& orig) = delete;
82  fen_monitor& operator=(const fen_monitor& that) = delete;
83 
84  void scan_root_paths();
85  bool scan(const std::string& path, bool is_root_path = true);
86  bool is_path_watched(const std::string& path) const;
87  bool add_watch(const std::string& path, const struct stat& fd_stat);
88  bool associate_port(struct fen_info *finfo, const struct stat& fd_stat);
89  void process_events(struct fen_info *obj, int events);
90  void rescan_removed();
91  void rescan_pending();
92 
93  // pimpl
94  fen_monitor_load *load;
95  };
96 }
97 
98 #endif /* FSW_FEN_MONITOR_H */
void run() override
Executes the monitor loop.
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
Solaris/Illumos monitor.
Definition: fen_monitor.hpp:53
Definition: cmonitor.h:51
virtual ~fen_monitor()
Destroys an instance of this class.
Header of the fsw::monitor class.
fen_monitor(std::vector< std::string > paths, FSW_EVENT_CALLBACK *callback, void *context=nullptr)
Constructs an instance of this class.
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