libcamera: pipeline_handler: Store the camera manager pointer
Instead of passing the camera manager pointer to the match() function, and later to more PipelineHandler functions, store it in the PipelineHandler::manager_ member variable at construction time and access it from there. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
This commit is contained in:
@@ -19,9 +19,13 @@ class DeviceEnumerator;
|
||||
class PipelineHandler
|
||||
{
|
||||
public:
|
||||
virtual ~PipelineHandler() { };
|
||||
PipelineHandler(CameraManager *manager);
|
||||
virtual ~PipelineHandler();
|
||||
|
||||
virtual bool match(CameraManager *manager, DeviceEnumerator *enumerator) = 0;
|
||||
virtual bool match(DeviceEnumerator *enumerator) = 0;
|
||||
|
||||
protected:
|
||||
CameraManager *manager_;
|
||||
};
|
||||
|
||||
class PipelineHandlerFactory
|
||||
@@ -30,7 +34,7 @@ public:
|
||||
PipelineHandlerFactory(const char *name);
|
||||
virtual ~PipelineHandlerFactory() { };
|
||||
|
||||
virtual PipelineHandler *create() = 0;
|
||||
virtual PipelineHandler *create(CameraManager *manager) = 0;
|
||||
|
||||
const std::string &name() const { return name_; }
|
||||
|
||||
@@ -42,11 +46,13 @@ private:
|
||||
};
|
||||
|
||||
#define REGISTER_PIPELINE_HANDLER(handler) \
|
||||
class handler##Factory : public PipelineHandlerFactory { \
|
||||
class handler##Factory : public PipelineHandlerFactory \
|
||||
{ \
|
||||
public: \
|
||||
handler##Factory() : PipelineHandlerFactory(#handler) { } \
|
||||
PipelineHandler *create() final { \
|
||||
return new handler(); \
|
||||
handler##Factory() : PipelineHandlerFactory(#handler) {} \
|
||||
PipelineHandler *create(CameraManager *manager) final \
|
||||
{ \
|
||||
return new handler(manager); \
|
||||
} \
|
||||
}; \
|
||||
static handler##Factory global_##handler##Factory;
|
||||
|
||||
Reference in New Issue
Block a user