Belle II Software  release-05-01-25
Inotify.h
1 #ifndef _Belle2_Inotify_hh
2 #define _Belle2_Inotify_hh
3 
4 #include "daq/slc/system/FileDescriptor.h"
5 
6 #include <string>
7 #include <vector>
8 
9 namespace Belle2 {
15  class InotifyEvent {
16 
17  friend class Inotify;
18 
19  public:
20  InotifyEvent()
21  : m_wd(-1), m_mask(-1), m_name() {}
22  ~InotifyEvent() {}
23 
24  private:
25  InotifyEvent(int wd, unsigned long mask, const std::string& name)
26  : m_wd(wd), m_mask(mask), m_name(name) {}
27 
28  public:
29  int get_wd() const { return m_wd;}
30  unsigned long getMask() const { return m_mask; }
31  const std::string& getName() const { return m_name; }
32 
33  private:
34  int m_wd;
35  unsigned long m_mask;
36  std::string m_name;
37 
38  };
39 
40  typedef std::vector<InotifyEvent> InotifyEventList;
41 
42  class Inotify : public FileDescriptor {
43 
44  public:
45  static const unsigned long FILE_CREATE;
46  static const unsigned long FILE_OPEN;
47  static const unsigned long FILE_CLOSE_WRITE;
48  static const unsigned long FILE_CLOSE_NOWRITE;
49  static const unsigned long FILE_DELETE;
50  static const unsigned long FILE_MODIFY;
51  static const unsigned long FILE_ACCESS;
52  static const unsigned long FILE_ATTRIB;
53 
54  public:
55  Inotify() {}
56  virtual ~Inotify() {}
57 
58  public:
59  void open();
60  int add(const std::string& path, unsigned long mask);
61  void remove(int wd);
62  InotifyEventList wait(int sec);
63 
64  };
65 
67 }
68 
69 #endif
Belle2::Inotify
Definition: Inotify.h:42
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::InotifyEvent
Definition: Inotify.h:15
Belle2::FileDescriptor
Definition: FileDescriptor.h:10