Message ID | 20191028104913.14985-4-laurent.pinchart@ideasonboard.com |
---|---|
State | Accepted |
Headers | show |
Series |
|
Related | show |
Hi Laurent, Thanks for your patch. On 2019-10-28 12:49:07 +0200, Laurent Pinchart wrote: > Store the connection type in the base BoundMethodBase class to make it > accessible to all bound methods. The default type is ConnectionTypeAuto. > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> > --- > include/libcamera/bound_method.h | 24 +++++++++++++++++------- > 1 file changed, 17 insertions(+), 7 deletions(-) > > diff --git a/include/libcamera/bound_method.h b/include/libcamera/bound_method.h > index e1524c917e4b..06c5a3b12305 100644 > --- a/include/libcamera/bound_method.h > +++ b/include/libcamera/bound_method.h > @@ -24,8 +24,10 @@ enum ConnectionType { > class BoundMethodBase > { > public: > - BoundMethodBase(void *obj, Object *object) > - : obj_(obj), object_(object) {} > + BoundMethodBase(void *obj, Object *object, ConnectionType type) > + : obj_(obj), object_(object), connectionType_(type) > + { > + } > virtual ~BoundMethodBase() {} > > template<typename T, typename std::enable_if<!std::is_same<Object, T>::value>::type * = nullptr> > @@ -33,6 +35,7 @@ public: > bool match(Object *object) { return object == object_; } > > Object *object() const { return object_; } > + ConnectionType connectionType() const { return connectionType_; } > > void activatePack(void *pack); > virtual void invokePack(void *pack) = 0; > @@ -40,6 +43,7 @@ public: > protected: > void *obj_; > Object *object_; > + ConnectionType connectionType_; > }; > > template<typename... Args> > @@ -76,8 +80,8 @@ private: > } > > public: > - BoundMethodArgs(void *obj, Object *object) > - : BoundMethodBase(obj, object) {} > + BoundMethodArgs(void *obj, Object *object, ConnectionType type) > + : BoundMethodBase(obj, object, type) {} > > void invokePack(void *pack) override > { > @@ -94,8 +98,11 @@ class BoundMemberMethod : public BoundMethodArgs<Args...> > public: > using PackType = std::tuple<typename std::remove_reference<Args>::type...>; > > - BoundMemberMethod(T *obj, Object *object, void (T::*func)(Args...)) > - : BoundMethodArgs<Args...>(obj, object), func_(func) {} > + BoundMemberMethod(T *obj, Object *object, void (T::*func)(Args...), > + ConnectionType type = ConnectionTypeAuto) > + : BoundMethodArgs<Args...>(obj, object, type), func_(func) > + { > + } > > bool match(void (T::*func)(Args...)) const { return func == func_; } > > @@ -121,7 +128,10 @@ class BoundStaticMethod : public BoundMethodArgs<Args...> > { > public: > BoundStaticMethod(void (*func)(Args...)) > - : BoundMethodArgs<Args...>(nullptr, nullptr), func_(func) {} > + : BoundMethodArgs<Args...>(nullptr, nullptr, ConnectionTypeAuto), > + func_(func) > + { > + } > > bool match(void (*func)(Args...)) const { return func == func_; } > > -- > Regards, > > Laurent Pinchart > > _______________________________________________ > libcamera-devel mailing list > libcamera-devel@lists.libcamera.org > https://lists.libcamera.org/listinfo/libcamera-devel
diff --git a/include/libcamera/bound_method.h b/include/libcamera/bound_method.h index e1524c917e4b..06c5a3b12305 100644 --- a/include/libcamera/bound_method.h +++ b/include/libcamera/bound_method.h @@ -24,8 +24,10 @@ enum ConnectionType { class BoundMethodBase { public: - BoundMethodBase(void *obj, Object *object) - : obj_(obj), object_(object) {} + BoundMethodBase(void *obj, Object *object, ConnectionType type) + : obj_(obj), object_(object), connectionType_(type) + { + } virtual ~BoundMethodBase() {} template<typename T, typename std::enable_if<!std::is_same<Object, T>::value>::type * = nullptr> @@ -33,6 +35,7 @@ public: bool match(Object *object) { return object == object_; } Object *object() const { return object_; } + ConnectionType connectionType() const { return connectionType_; } void activatePack(void *pack); virtual void invokePack(void *pack) = 0; @@ -40,6 +43,7 @@ public: protected: void *obj_; Object *object_; + ConnectionType connectionType_; }; template<typename... Args> @@ -76,8 +80,8 @@ private: } public: - BoundMethodArgs(void *obj, Object *object) - : BoundMethodBase(obj, object) {} + BoundMethodArgs(void *obj, Object *object, ConnectionType type) + : BoundMethodBase(obj, object, type) {} void invokePack(void *pack) override { @@ -94,8 +98,11 @@ class BoundMemberMethod : public BoundMethodArgs<Args...> public: using PackType = std::tuple<typename std::remove_reference<Args>::type...>; - BoundMemberMethod(T *obj, Object *object, void (T::*func)(Args...)) - : BoundMethodArgs<Args...>(obj, object), func_(func) {} + BoundMemberMethod(T *obj, Object *object, void (T::*func)(Args...), + ConnectionType type = ConnectionTypeAuto) + : BoundMethodArgs<Args...>(obj, object, type), func_(func) + { + } bool match(void (T::*func)(Args...)) const { return func == func_; } @@ -121,7 +128,10 @@ class BoundStaticMethod : public BoundMethodArgs<Args...> { public: BoundStaticMethod(void (*func)(Args...)) - : BoundMethodArgs<Args...>(nullptr, nullptr), func_(func) {} + : BoundMethodArgs<Args...>(nullptr, nullptr, ConnectionTypeAuto), + func_(func) + { + } bool match(void (*func)(Args...)) const { return func == func_; }
Store the connection type in the base BoundMethodBase class to make it accessible to all bound methods. The default type is ConnectionTypeAuto. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- include/libcamera/bound_method.h | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-)