libcamera
v0.4.0
Supporting cameras in Linux since 2019
|
Notify of activity on a file descriptor. More...
Public Types | |
enum | Type { Read, Write, Exception } |
Public Member Functions | |
EventNotifier (int fd, Type type, Object *parent=nullptr) | |
Construct an event notifier with a file descriptor and event type. More... | |
Type | type () const |
Retrieve the type of the event being monitored. More... | |
int | fd () const |
Retrieve the file descriptor being monitored. More... | |
bool | enabled () const |
Retrieve the notifier state. More... | |
void | setEnabled (bool enable) |
Enable or disable the notifier. More... | |
Public Member Functions inherited from libcamera::Object | |
Object (Object *parent=nullptr) | |
Construct an Object instance. More... | |
virtual | ~Object () |
Destroy an Object instance. More... | |
void | deleteLater () |
Schedule deletion of the instance in the thread it belongs to. More... | |
void | postMessage (std::unique_ptr< Message > msg) |
Post a message to the object's thread. More... | |
template<typename T , typename R , typename... FuncArgs, typename... Args, std::enable_if_t< std::is_base_of< Object, T >::value > * = nullptr> | |
R | invokeMethod (R(T::*func)(FuncArgs...), ConnectionType type, Args &&... args) |
Invoke a method asynchronously on an Object instance. More... | |
Thread * | thread () const |
Retrieve the thread the object is bound to. More... | |
void | moveToThread (Thread *thread) |
Move the object and all its children to a different thread. More... | |
Object * | parent () const |
Retrieve the object's parent. More... | |
Public Attributes | |
Signal | activated |
Signal emitted when the event occurs. More... | |
Protected Member Functions | |
void | message (Message *msg) override |
Message handler for the object. More... | |
Protected Member Functions inherited from libcamera::Object | |
bool | assertThreadBound (const char *message) |
Check if the caller complies with thread-bound constraints. More... | |
Notify of activity on a file descriptor.
The EventNotifier models a file descriptor event source that can be monitored. It is created with the file descriptor to be monitored and the type of event, and is enabled by default. It will emit the activated signal whenever an event of the monitored type occurs on the file descriptor.
Supported type of events are EventNotifier::Read, EventNotifier::Write and EventNotifier::Exception. The type is specified when constructing the notifier, and can be retrieved using the type() function. To listen to multiple event types on the same file descriptor multiple notifiers must be created.
The notifier can be disabled with the setEnabled() function. When the notifier is disabled it ignores events and does not emit the activated signal. The notifier can then be re-enabled with the setEnabled() function.
Creating multiple notifiers of the same type for the same file descriptor is not allowed and results in undefined behaviour.
Notifier events are detected and dispatched from the EventDispatcher::processEvents() function.
Construct an event notifier with a file descriptor and event type.
[in] | fd | The file descriptor to monitor |
[in] | type | The event type to monitor |
[in] | parent | The parent Object |
|
inline |
Retrieve the notifier state.
|
inline |
Retrieve the file descriptor being monitored.
|
overrideprotectedvirtual |
Message handler for the object.
[in] | msg | The message |
This virtual function receives messages for the object. It is called in the context of the object's thread, and can be overridden to process custom messages. The parent Object::message() function shall be called for any message not handled by the override function.
The message msg is valid only for the duration of the call, no reference to it shall be kept after this function returns.
Reimplemented from libcamera::Object.
void libcamera::EventNotifier::setEnabled | ( | bool | enable | ) |
Enable or disable the notifier.
[in] | enable | True to enable the notifier, false to disable it |
This function enables or disables the notifier. A disabled notifier ignores events and does not emit the activated signal.
|
inline |
Retrieve the type of the event being monitored.
libcamera::EventNotifier::activated |