Belle II Software  release-08-01-10
Inotify.h
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 #ifndef _Belle2_Inotify_hh
9 #define _Belle2_Inotify_hh
10 
11 #include "daq/slc/system/FileDescriptor.h"
12 
13 #include <string>
14 #include <vector>
15 
16 namespace Belle2 {
22  class InotifyEvent {
23 
24  friend class Inotify;
25 
26  public:
27  InotifyEvent()
28  : m_wd(-1), m_mask(-1), m_name() {}
29  ~InotifyEvent() {}
30 
31  private:
32  InotifyEvent(int wd, unsigned long mask, const std::string& name)
33  : m_wd(wd), m_mask(mask), m_name(name) {}
34 
35  public:
36  int get_wd() const { return m_wd;}
37  unsigned long getMask() const { return m_mask; }
38  const std::string& getName() const { return m_name; }
39 
40  private:
41  int m_wd;
42  unsigned long m_mask;
43  std::string m_name;
44 
45  };
46 
47  typedef std::vector<InotifyEvent> InotifyEventList;
48 
49  class Inotify : public FileDescriptor {
50 
51  public:
52  static const unsigned long FILE_CREATE;
53  static const unsigned long FILE_OPEN;
54  static const unsigned long FILE_CLOSE_WRITE;
55  static const unsigned long FILE_CLOSE_NOWRITE;
56  static const unsigned long FILE_DELETE;
57  static const unsigned long FILE_MODIFY;
58  static const unsigned long FILE_ACCESS;
59  static const unsigned long FILE_ATTRIB;
60 
61  public:
62  Inotify() {}
63  virtual ~Inotify() {}
64 
65  public:
66  void open();
67  int add(const std::string& path, unsigned long mask);
68  void remove(int wd);
69  InotifyEventList wait(int sec);
70 
71  };
72 
74 }
75 
76 #endif
Abstract base class for different kinds of events.