From 674828e35f823433ab5469510359bea21ccd26de Mon Sep 17 00:00:00 2001 From: Jacopo Mondi Date: Tue, 17 Dec 2019 12:47:51 +0100 Subject: libcamera: camera_sensor: Introduce CameraSensorFactory Introduce a factory to create CameraSensor derived classes instances by inspecting the sensor media entity name and provide a convenience macro to register specialized sensor handlers. Signed-off-by: Jacopo Mondi Signed-off-by: Laurent Pinchart Reviewed-by: Stefan Klug --- Changes since combined RFC: - Fix indentation in REGISTER_CAMERA_SENSOR() macro --- test/camera-sensor.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'test/camera-sensor.cpp') diff --git a/test/camera-sensor.cpp b/test/camera-sensor.cpp index 1d402c43..869c7889 100644 --- a/test/camera-sensor.cpp +++ b/test/camera-sensor.cpp @@ -52,8 +52,8 @@ protected: return TestFail; } - sensor_ = new CameraSensor(entity); - if (sensor_->init() < 0) { + sensor_ = CameraSensorFactoryBase::create(entity); + if (!sensor_) { cerr << "Unable to initialise camera sensor" << endl; return TestFail; } @@ -118,13 +118,12 @@ protected: void cleanup() { - delete sensor_; } private: std::unique_ptr enumerator_; std::shared_ptr media_; - CameraSensor *sensor_; + std::unique_ptr sensor_; CameraLens *lens_; }; -- cgit v1.2.1