From c0d39bab5bf3be585a7860d51429913187d05f04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= Date: Fri, 21 Dec 2018 15:54:23 +0100 Subject: libcamera: device_enumerator: add DeviceMatch class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Provide a DeviceMatch class which represents all properties of a media device a pipeline hander can specify when searching for a device to use in its pipeline. Signed-off-by: Niklas Söderlund Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- src/libcamera/device_enumerator.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src/libcamera/device_enumerator.cpp') diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp index 83dcda94..61b32bb9 100644 --- a/src/libcamera/device_enumerator.cpp +++ b/src/libcamera/device_enumerator.cpp @@ -75,4 +75,40 @@ int DeviceInfo::lookup(const std::string &name, std::string &devnode) const return 0; } +/* ----------------------------------------------------------------------------- + * DeviceMatch + */ + +DeviceMatch::DeviceMatch(const std::string &driver) + : driver_(driver) +{ +} + +void DeviceMatch::add(const std::string &entity) +{ + entities_.push_back(entity); +} + +bool DeviceMatch::match(const DeviceInfo *info) const +{ + if (driver_ != info->info().driver) + return false; + + for (const std::string &name : entities_) { + bool found = false; + + for (const std::string &entity : info->entities()) { + if (name == entity) { + found = true; + break; + } + } + + if (!found) + return false; + } + + return true; +} + } /* namespace libcamera */ -- cgit v1.2.1