summaryrefslogtreecommitdiff
path: root/test/event.cpp
AgeCommit message (Collapse)Author
2019-08-19test: Get event dispatcher from current threadLaurent Pinchart
For all tests that don't otherwise require access to the camera manager, get the event dispatcher from the current thread instead of the camera manager. This prepares for the removal of CameraManager::instance(). Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-04-29libcamera: Don't ignore the return value of read() and write()Laurent Pinchart
The glibc read() and write() functions are defined with the __warn_unused_result__ attribute when using FORTIFY_SOURCE. Don't ignore their return value. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-01-08test: Add event notifier testLaurent Pinchart
The test covers read notification and notifier enable/disable. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
70c4be180a2c2191d74e'>plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
 * Copyright (C) 2019, Google Inc.
 *
 * event_notifier.h - File descriptor event notifier
 */

#pragma once

#include <libcamera/base/private.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<> activated;

protected:
	void message(Message *msg) override;

private:
	int fd_;
	Type type_;
	bool enabled_;
};

} /* namespace libcamera */