event_notifier.h
Go to the documentation of this file.
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2019, Google Inc.
*
* event_notifier.h - File descriptor event notifier
*/
#ifndef __LIBCAMERA_EVENT_NOTIFIER_H__
#define __LIBCAMERA_EVENT_NOTIFIER_H__
#include <libcamera/object.h>
#include <libcamera/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_EVENT_NOTIFIER_H__ */
libcamera::EventNotifier
Notify of activity on a file descriptor.
Definition: event_notifier.h:18
libcamera::EventNotifier::enabled
bool enabled() const
Retrieve the notifier state.
Definition: event_notifier.h:32
libcamera::EventNotifier::fd
int fd() const
Retrieve the file descriptor being monitored.
Definition: event_notifier.h:30
libcamera::EventNotifier::setEnabled
void setEnabled(bool enable)
Enable or disable the notifier.
Definition: event_notifier.cpp:105
libcamera::EventNotifier::message
void message(Message *msg) override
Message handler for the object.
Definition: event_notifier.cpp:128
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:66
libcamera::EventNotifier::type
Type type() const
Retrieve the type of the event being monitored.
Definition: event_notifier.h:29
libcamera::EventNotifier::Type
Type
Definition: event_notifier.h:20
libcamera::EventNotifier::Read
@ Read
Definition: event_notifier.h:21
libcamera::EventNotifier::Write
@ Write
Definition: event_notifier.h:22
libcamera::EventNotifier::Exception
@ Exception
Definition: event_notifier.h:23
libcamera::EventNotifier::activated
Signal< EventNotifier * > activated
Signal emitted when the event occurs.
Definition: event_notifier.h:35
libcamera::Message
A message that can be posted to a Thread.
Definition: message.h:22
libcamera::Object
Base object to support automatic signal disconnection.
Definition: object.h:25
libcamera::Object::parent
Object * parent() const
Retrieve the object's parent.
Definition: object.h:45
libcamera::Signal
Generic signal and slot communication mechanism.
Definition: signal.h:39
object.h
Base object to support automatic signal disconnection.
signal.h
Signal & slot implementation.