summaryrefslogtreecommitdiff
path: root/src/libcamera/pipeline_handler.cpp
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-06-05 17:11:51 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-06-10 17:29:27 +0300
commit33534000275020cacaeddde6bee7f98377bf1170 (patch)
tree914eac5112d5ae967489f0d65333ffe1aad8f16c /src/libcamera/pipeline_handler.cpp
parent339e9b2d976cc726ee4ec7de78ab5b7978b2eb8e (diff)
libcamera: pipeline_handler: Optimise factory implementation
The REGISTER_PIPELINE_HANDLER() macro defines and instantiates a subclass of the PipelineHandlerFactory class that specialises the virtual create() method. Now that create() does more than just creating an instance, boilerplate code gets duplicated between different factories. Factor out the instance creation code to a new virtual createInstance() method, and turn create() into a non-virtual method of the base class that can then be defined in the .cpp file. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Diffstat (limited to 'src/libcamera/pipeline_handler.cpp')
-rw-r--r--src/libcamera/pipeline_handler.cpp33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp
index 800931d8..af19f4a3 100644
--- a/src/libcamera/pipeline_handler.cpp
+++ b/src/libcamera/pipeline_handler.cpp
@@ -539,17 +539,18 @@ PipelineHandlerFactory::PipelineHandlerFactory(const char *name)
}
/**
- * \fn PipelineHandlerFactory::create()
* \brief Create an instance of the PipelineHandler corresponding to the factory
* \param[in] manager The camera manager
*
- * This virtual function is implemented by the REGISTER_PIPELINE_HANDLER()
- * macro. It creates a pipeline handler instance associated with the camera
- * \a manager.
- *
- * \return a pointer to a newly constructed instance of the PipelineHandler
- * subclass corresponding to the factory
+ * \return A shared pointer to a new instance of the PipelineHandler subclass
+ * corresponding to the factory
*/
+std::shared_ptr<PipelineHandler> PipelineHandlerFactory::create(CameraManager *manager)
+{
+ PipelineHandler *handler = createInstance(manager);
+ handler->name_ = name_.c_str();
+ return std::shared_ptr<PipelineHandler>(handler);
+}
/**
* \fn PipelineHandlerFactory::name()
@@ -589,15 +590,17 @@ std::vector<PipelineHandlerFactory *> &PipelineHandlerFactory::factories()
}
/**
- * \brief Set the information of a given pipeline handler
- * \param[in] handler The handler whose info is to be set
- * \param[in] name The name of the pipeline handler
+ * \fn PipelineHandlerFactory::createInstance()
+ * \brief Create an instance of the PipelineHandler corresponding to the factory
+ * \param[in] manager The camera manager
+ *
+ * This virtual function is implemented by the REGISTER_PIPELINE_HANDLER()
+ * macro. It creates a pipeline handler instance associated with the camera
+ * \a manager.
+ *
+ * \return a pointer to a newly constructed instance of the PipelineHandler
+ * subclass corresponding to the factory
*/
-void PipelineHandlerFactory::setInfo(PipelineHandler *handler,
- const char *name)
-{
- handler->name_ = name;
-}
/**
* \def REGISTER_PIPELINE_HANDLER