libcamera  v0.0.0
Supporting cameras in Linux since 2019
event_notifier.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 /*
3  * Copyright (C) 2019, Google Inc.
4  *
5  * event_notifier.h - File descriptor event notifier
6  */
7 #ifndef __LIBCAMERA_EVENT_NOTIFIER_H__
8 #define __LIBCAMERA_EVENT_NOTIFIER_H__
9 
10 #include <libcamera/object.h>
11 #include <libcamera/signal.h>
12 
13 namespace libcamera {
14 
15 class Message;
16 
17 class EventNotifier : public Object
18 {
19 public:
20  enum Type {
24  };
25 
26  EventNotifier(int fd, Type type, Object *parent = nullptr);
27  virtual ~EventNotifier();
28 
29  Type type() const { return type_; }
30  int fd() const { return fd_; }
31 
32  bool enabled() const { return enabled_; }
33  void setEnabled(bool enable);
34 
36 
37 protected:
38  void message(Message *msg) override;
39 
40 private:
41  int fd_;
42  Type type_;
43  bool enabled_;
44 };
45 
46 } /* namespace libcamera */
47 
48 #endif /* __LIBCAMERA_EVENT_NOTIFIER_H__ */
Notify of activity on a file descriptor.
Definition: event_notifier.h:18
bool enabled() const
Retrieve the notifier state.
Definition: event_notifier.h:32
int fd() const
Retrieve the file descriptor being monitored.
Definition: event_notifier.h:30
void setEnabled(bool enable)
Enable or disable the notifier.
Definition: event_notifier.cpp:105
void message(Message *msg) override
Message handler for the object.
Definition: event_notifier.cpp:128
EventNotifier(int fd, Type type, Object *parent=nullptr)
Construct an event notifier with a file descriptor and event type.
Definition: event_notifier.cpp:66
Type type() const
Retrieve the type of the event being monitored.
Definition: event_notifier.h:29
Type
Definition: event_notifier.h:20
@ Read
Definition: event_notifier.h:21
@ Write
Definition: event_notifier.h:22
@ Exception
Definition: event_notifier.h:23
Signal< EventNotifier * > activated
Signal emitted when the event occurs.
Definition: event_notifier.h:35
A message that can be posted to a Thread.
Definition: message.h:22
Base object to support automatic signal disconnection.
Definition: object.h:25
Object * parent() const
Retrieve the object's parent.
Definition: object.h:45
Generic signal and slot communication mechanism.
Definition: signal.h:39
Base object to support automatic signal disconnection.
Signal & slot implementation.