From 06e2ac2e2f5798463676f7d46dae7fcb67fc62da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= Date: Fri, 21 Dec 2018 02:45:14 +0100 Subject: libcamera: device_enumerator: add factory for DeviceEnumerators MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Provide a factory for DeviceEnumerator objects. Depending on which libraries are available there will be different ways to enumerate information in the system. This factory hides this from the rest of the library. Currently udev enumeration is the only supported implementation, a sysfs implementation is another method that surely will be added in the future. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart Reviewed-by: Jacopo Mondi --- src/libcamera/device_enumerator.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/libcamera/device_enumerator.cpp') diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp index 8e8b280f..4373fdf0 100644 --- a/src/libcamera/device_enumerator.cpp +++ b/src/libcamera/device_enumerator.cpp @@ -121,6 +121,25 @@ bool DeviceMatch::match(const DeviceInfo *info) const * Enumerator Base */ +DeviceEnumerator *DeviceEnumerator::create() +{ + DeviceEnumerator *enumerator; + + /* TODO: add compile time checks to only try udev enumerator if libudev is available */ + enumerator = new DeviceEnumeratorUdev(); + if (!enumerator->init()) + return enumerator; + + /* + * NOTE: Either udev is not available or initialization of it + * failed, use/fallback on sysfs enumerator + */ + + /* TODO: add a sysfs based enumerator */ + + return nullptr; +} + DeviceEnumerator::~DeviceEnumerator() { for (DeviceInfo *dev : devices_) { -- cgit v1.2.1