summaryrefslogtreecommitdiff
path: root/include/libcamera/base/event_notifier.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/libcamera/base/event_notifier.h')
-rw-r--r--include/libcamera/base/event_notifier.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/include/libcamera/base/event_notifier.h b/include/libcamera/base/event_notifier.h
new file mode 100644
index 00000000..5aa2784a
--- /dev/null
+++ b/include/libcamera/base/event_notifier.h
@@ -0,0 +1,48 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2019, Google Inc.
+ *
+ * event_notifier.h - File descriptor event notifier
+ */
+#ifndef __LIBCAMERA_BASE_EVENT_NOTIFIER_H__
+#define __LIBCAMERA_BASE_EVENT_NOTIFIER_H__
+
+#include <libcamera/base/object.h>
+#include <libcamera/base/signal.h>
+
+namespace libcamera {
+
+class Message;
+
+class EventNotifier : public Object
+{
+public:
+ enum Type {
+ Read,
+ Write,
+ Exception,
+ };
+
+ EventNotifier(int fd, Type type, Object *parent = nullptr);
+ virtual ~EventNotifier();
+
+ Type type() const { return type_; }
+ int fd() const { return fd_; }
+
+ bool enabled() const { return enabled_; }
+ void setEnabled(bool enable);
+
+ Signal<EventNotifier *> activated;
+
+protected:
+ void message(Message *msg) override;
+
+private:
+ int fd_;
+ Type type_;
+ bool enabled_;
+};
+
+} /* namespace libcamera */
+
+#endif /* __LIBCAMERA_BASE_EVENT_NOTIFIER_H__ */