libcamera: include/libcamera/base/event_notifier.h Source File

libcamera v0.5.1 Supporting cameras in Linux since 2019 |

Loading...
Searching...
No Matches
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 * File descriptor event notifier
6 */
7
8#pragma once
9
10#include <libcamera/base/private.h>
11
12#include <libcamera/base/object.h>
13#include <libcamera/base/signal.h>
14
15namespace libcamera {
16
17class Message;
18
19 class EventNotifier : public Object
20{
21public:
22 enum Type {
23 Read,
24 Write,
25 Exception,
26 };
27
28 EventNotifier(int fd, Type type, Object *parent = nullptr);
29 virtual ~EventNotifier();
30
31 Type type() const { return type_; }
32 int fd() const { return fd_; }
33
34 bool enabled() const { return enabled_; }
35 void setEnabled(bool enable);
36
37 Signal<> activated;
38
39protected:
40 void message(Message *msg) override;
41
42private:
43 int fd_;
44 Type type_;
45 bool enabled_;
46};
47
48} /* namespace libcamera */
libcamera::EventNotifier
Notify of activity on a file descriptor.
Definition event_notifier.h:20
libcamera::EventNotifier::fd
int fd() const
Retrieve the file descriptor being monitored.
Definition event_notifier.h:32
libcamera::EventNotifier::type
Type type() const
Retrieve the type of the event being monitored.
Definition event_notifier.h:31
libcamera::EventNotifier::enabled
bool enabled() const
Retrieve the notifier state.
Definition event_notifier.h:34
libcamera::EventNotifier::setEnabled
void setEnabled(bool enable)
Enable or disable the notifier.
Definition event_notifier.cpp:108
libcamera::EventNotifier::message
void message(Message *msg) override
Message handler for the object.
Definition event_notifier.cpp:134
libcamera::EventNotifier::EventNotifier
EventNotifier(int fd, Type type, Object *parent=nullptr)
Construct an event notifier with a file descriptor and event type.
Definition event_notifier.cpp:69
libcamera::EventNotifier::Type
Type
Definition event_notifier.h:22
libcamera::EventNotifier::Exception
@ Exception
Definition event_notifier.h:25
libcamera::EventNotifier::Write
@ Write
Definition event_notifier.h:24
libcamera::EventNotifier::Read
@ Read
Definition event_notifier.h:23
libcamera::EventNotifier::activated
Signal activated
Signal emitted when the event occurs.
Definition event_notifier.h:37
libcamera::Message
A message that can be posted to a Thread.
Definition message.h:24
libcamera::Object
Base object to support automatic signal disconnection.
Definition object.h:27
libcamera::Object::Object
Object(Object *parent=nullptr)
Construct an Object instance.
Definition object.cpp:69
libcamera::Object::parent
Object * parent() const
Retrieve the object's parent.
Definition object.h:49
libcamera::Signal
Generic signal and slot communication mechanism.
Definition signal.h:39
libcamera
Top-level libcamera namespace.
Definition backtrace.h:17
object.h
Base object to support automatic signal disconnection.
signal.h
Signal & slot implementation.