summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libcamera/include/pipeline_handler.h16
-rw-r--r--src/libcamera/pipeline_handler.cpp33
2 files changed, 25 insertions, 24 deletions
diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h
index 84307e40..a4cbc593 100644
--- a/src/libcamera/include/pipeline_handler.h
+++ b/src/libcamera/include/pipeline_handler.h
@@ -107,17 +107,16 @@ public:
PipelineHandlerFactory(const char *name);
virtual ~PipelineHandlerFactory() { };
- virtual std::shared_ptr<PipelineHandler> create(CameraManager *manager) = 0;
+ std::shared_ptr<PipelineHandler> create(CameraManager *manager);
const std::string &name() const { return name_; }
static void registerType(PipelineHandlerFactory *factory);
static std::vector<PipelineHandlerFactory *> &factories();
-protected:
- void setInfo(PipelineHandler *handler, const char *name);
-
private:
+ virtual PipelineHandler *createInstance(CameraManager *manager) = 0;
+
std::string name_;
};
@@ -126,12 +125,11 @@ class handler##Factory final : public PipelineHandlerFactory \
{ \
public: \
handler##Factory() : PipelineHandlerFactory(#handler) {} \
- std::shared_ptr<PipelineHandler> create(CameraManager *manager) \
+ \
+private: \
+ PipelineHandler *createInstance(CameraManager *manager) \
{ \
- std::shared_ptr<handler> h = \
- std::make_shared<handler>(manager); \
- setInfo(h.get(), #handler); \
- return h; \
+ return new handler(manager); \
} \
}; \
static handler##Factory global_##handler##Factory;
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