diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2022-10-03 22:55:11 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2022-10-07 18:10:05 +0300 |
commit | 014698cba1f4e6a0325fe070c9208c74d7639b74 (patch) | |
tree | 3f21840c07962e1b0389f1f732453ff6f9c9eaf6 /src/ipa/libipa/camera_sensor_helper.h | |
parent | 9d9481188fc3a4291b33a2d53e9e331cc2d7a023 (diff) |
ipa: camera_sensor_helper: Implement factories through class templates
The REGISTER_CAMERA_SENSOR_HELPER() macro defines a class type that
inherits from the CameraSensorHelperFactory class, and implements a
constructor and createInstance() function. Replace the code generation
through macro with the C++ equivalent, a class template, as done by the
Algorithm factory.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Xavier Roumegue <xavier.roumegue@oss.nxp.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src/ipa/libipa/camera_sensor_helper.h')
-rw-r--r-- | src/ipa/libipa/camera_sensor_helper.h | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/src/ipa/libipa/camera_sensor_helper.h b/src/ipa/libipa/camera_sensor_helper.h index 21ee43cc..3ea1806c 100644 --- a/src/ipa/libipa/camera_sensor_helper.h +++ b/src/ipa/libipa/camera_sensor_helper.h @@ -58,39 +58,44 @@ private: LIBCAMERA_DISABLE_COPY_AND_MOVE(CameraSensorHelper) }; -class CameraSensorHelperFactory +class CameraSensorHelperFactoryBase { public: - CameraSensorHelperFactory(const std::string name); - virtual ~CameraSensorHelperFactory() = default; + CameraSensorHelperFactoryBase(const std::string name); + virtual ~CameraSensorHelperFactoryBase() = default; static std::unique_ptr<CameraSensorHelper> create(const std::string &name); - static std::vector<CameraSensorHelperFactory *> &factories(); + static std::vector<CameraSensorHelperFactoryBase *> &factories(); private: - LIBCAMERA_DISABLE_COPY_AND_MOVE(CameraSensorHelperFactory) + LIBCAMERA_DISABLE_COPY_AND_MOVE(CameraSensorHelperFactoryBase) - static void registerType(CameraSensorHelperFactory *factory); + static void registerType(CameraSensorHelperFactoryBase *factory); virtual std::unique_ptr<CameraSensorHelper> createInstance() const = 0; std::string name_; }; -#define REGISTER_CAMERA_SENSOR_HELPER(name, helper) \ -class helper##Factory final : public CameraSensorHelperFactory \ -{ \ -public: \ - helper##Factory() : CameraSensorHelperFactory(name) {} \ - \ -private: \ - std::unique_ptr<CameraSensorHelper> createInstance() const \ - { \ - return std::make_unique<helper>(); \ - } \ -}; \ -static helper##Factory global_##helper##Factory; +template<typename _Helper> +class CameraSensorHelperFactory final : public CameraSensorHelperFactoryBase +{ +public: + CameraSensorHelperFactory(const char *name) + : CameraSensorHelperFactoryBase(name) + { + } + +private: + std::unique_ptr<CameraSensorHelper> createInstance() const + { + return std::make_unique<_Helper>(); + } +}; + +#define REGISTER_CAMERA_SENSOR_HELPER(name, helper) \ +static CameraSensorHelperFactory<helper> global_##helper##Factory(name); } /* namespace ipa */ |