[libcamera-devel] [PATCH 5/8] libcamera: pipeline_handler: Make factory create() function const
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Mon Oct 3 23:21:25 CEST 2022
The PipelineHandlerFactory::create() function has no need to modify the
factory instance. Make it const, as well as the createInstance()
function.
Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
include/libcamera/internal/pipeline_handler.h | 6 +++---
src/libcamera/pipeline_handler.cpp | 4 ++--
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h
index 20f1cbb07fea..46df69dc789a 100644
--- a/include/libcamera/internal/pipeline_handler.h
+++ b/include/libcamera/internal/pipeline_handler.h
@@ -104,7 +104,7 @@ public:
PipelineHandlerFactory(const char *name);
virtual ~PipelineHandlerFactory() = default;
- std::shared_ptr<PipelineHandler> create(CameraManager *manager);
+ std::shared_ptr<PipelineHandler> create(CameraManager *manager) const;
const std::string &name() const { return name_; }
@@ -112,7 +112,7 @@ public:
static std::vector<PipelineHandlerFactory *> &factories();
private:
- virtual PipelineHandler *createInstance(CameraManager *manager) = 0;
+ virtual PipelineHandler *createInstance(CameraManager *manager) const = 0;
std::string name_;
};
@@ -124,7 +124,7 @@ public: \
handler##Factory() : PipelineHandlerFactory(#handler) {} \
\
private: \
- PipelineHandler *createInstance(CameraManager *manager) \
+ PipelineHandler *createInstance(CameraManager *manager) const \
{ \
return new handler(manager); \
} \
diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp
index e5cb751cc743..4470e9041e8e 100644
--- a/src/libcamera/pipeline_handler.cpp
+++ b/src/libcamera/pipeline_handler.cpp
@@ -676,7 +676,7 @@ PipelineHandlerFactory::PipelineHandlerFactory(const char *name)
* \return A shared pointer to a new instance of the PipelineHandler subclass
* corresponding to the factory
*/
-std::shared_ptr<PipelineHandler> PipelineHandlerFactory::create(CameraManager *manager)
+std::shared_ptr<PipelineHandler> PipelineHandlerFactory::create(CameraManager *manager) const
{
PipelineHandler *handler = createInstance(manager);
handler->name_ = name_.c_str();
@@ -719,7 +719,7 @@ std::vector<PipelineHandlerFactory *> &PipelineHandlerFactory::factories()
}
/**
- * \fn PipelineHandlerFactory::createInstance()
+ * \fn PipelineHandlerFactory::createInstance() const
* \brief Create an instance of the PipelineHandler corresponding to the factory
* \param[in] manager The camera manager
*
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list