Loading...
Searching...
No Matches
libcamera::EventNotifier Class Reference

Notify of activity on a file descriptor. More...

Inheritance diagram for libcamera::EventNotifier:
[legend]
Collaboration diagram for libcamera::EventNotifier:
[legend]

## 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.
Type | type () const
| Retrieve the type of the event being monitored.
int | fd () const
| Retrieve the file descriptor being monitored.
bool | enabled () const
| Retrieve the notifier state.
void | setEnabled (bool enable)
| Enable or disable the notifier.
Public Member Functions inherited from libcamera::Object
| Object (Object *parent=nullptr)
| Construct an Object instance.
virtual | ~Object ()
| Destroy an Object instance.
void | deleteLater ()
| Schedule deletion of the instance in the thread it belongs to.
void | postMessage (std::unique_ptr< Message > msg)
| Post a message to the object's thread.
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.
Thread * | thread () const
| Retrieve the thread the object is bound to.
void | moveToThread (Thread *thread)
| Move the object and all its children to a different thread.
Object * | parent () const
| Retrieve the object's parent.

## Public Attributes

Signal | activated
| Signal emitted when the event occurs.

## Protected Member Functions

void | message (Message *msg) override
| Message handler for the object.
Protected Member Functions inherited from libcamera::Object
bool | assertThreadBound (const char *message)
| Check if the caller complies with thread-bound constraints.

## Detailed Description

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.

## Member Enumeration Documentation

## Type

enum libcamera::EventNotifier::Type

Type of file descriptor event to listen for.

Enumerator
Read | Data is available to be read from the file descriptor
Write | Data can be written to the file descriptor
Exception | An exception has occurred on the file descriptor

## Constructor & Destructor Documentation

## EventNotifier()

libcamera::EventNotifier::EventNotifier | ( | int | fd,
|  | Type | type,
|  | Object * | parent = nullptr )

Construct an event notifier with a file descriptor and event type.

Parameters

  [in] | fd | The file descriptor to monitor
  [in] | type | The event type to monitor
  [in] | parent | The parent Object

## Member Function Documentation

## enabled()

bool libcamera::EventNotifier::enabled | ( |  | ) | const

inline

Retrieve the notifier state.

Returns
  True if the notifier is enabled, or false otherwise

See also
  setEnabled()

## fd()

int libcamera::EventNotifier::fd | ( |  | ) | const

inline

Retrieve the file descriptor being monitored.

Returns
  The file descriptor

## message()

void libcamera::EventNotifier::message | ( | Message * | msg | ) |

override protected virtual

Message handler for the object.

Parameters

  [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.

## setEnabled()

void libcamera::EventNotifier::setEnabled | ( | bool | enable | ) |

Enable or disable the notifier.

Parameters

  [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.

Thread Safety
  This function is thread-bound.

## type()

Type libcamera::EventNotifier::type | ( |  | ) | const

inline

Retrieve the type of the event being monitored.

Returns
  The type of the event

## Member Data Documentation

## activated

Signal libcamera::EventNotifier::activated

Signal emitted when the event occurs.

This signal is emitted when the event type() occurs on the file descriptor monitored by the notifier. The notifier pointer is passed as a parameter.

The documentation for this class was generated from the following files:

- include/libcamera/base/event_notifier.h
- src/libcamera/base/event_notifier.cpp