[RFC,v1,1/2] libcamera: device_enumerator: Take list of entity names in ctor
diff mbox series

Message ID 20250815135253.2231076-1-barnabas.pocze@ideasonboard.com
State New
Headers show
Series
  • [RFC,v1,1/2] libcamera: device_enumerator: Take list of entity names in ctor
Related show

Commit Message

Barnabás Pőcze Aug. 15, 2025, 1:52 p.m. UTC
Make it possible to pass a list of entity names to the `DeviceMatch`
constructor, thereby simplifying the construction if there is a known
set of entity names by avoiding the repeated `add()` calls.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
---
 include/libcamera/internal/device_enumerator.h | 5 ++++-
 src/libcamera/device_enumerator.cpp            | 7 +++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

Patch
diff mbox series

diff --git a/include/libcamera/internal/device_enumerator.h b/include/libcamera/internal/device_enumerator.h
index db3532a98..cb055e166 100644
--- a/include/libcamera/internal/device_enumerator.h
+++ b/include/libcamera/internal/device_enumerator.h
@@ -7,8 +7,10 @@ 
 
 #pragma once
 
+#include <initializer_list>
 #include <memory>
 #include <string>
+#include <string_view>
 #include <vector>
 
 #include <libcamera/base/signal.h>
@@ -20,7 +22,8 @@  class MediaDevice;
 class DeviceMatch
 {
 public:
-	DeviceMatch(const std::string &driver);
+	DeviceMatch(const std::string &driver,
+		    std::initializer_list<std::string_view> entities = {});
 
 	void add(const std::string &entity);
 
diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp
index ae17862f6..ec98418fa 100644
--- a/src/libcamera/device_enumerator.cpp
+++ b/src/libcamera/device_enumerator.cpp
@@ -66,9 +66,12 @@  LOG_DEFINE_CATEGORY(DeviceEnumerator)
 /**
  * \brief Construct a media device search pattern
  * \param[in] driver The Linux device driver name that created the media device
+ * \param[in] entities The list of media graph entity names to search
  */
-DeviceMatch::DeviceMatch(const std::string &driver)
-	: driver_(driver)
+DeviceMatch::DeviceMatch(const std::string &driver,
+			 std::initializer_list<std::string_view> entities)
+	: driver_(driver),
+	  entities_(entities.begin(), entities.end())
 {
 }