From patchwork Mon Oct 28 10:49:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 2276 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 31D226017E for ; Mon, 28 Oct 2019 11:49:26 +0100 (CET) Received: from pendragon.ideasonboard.com (unknown [91.217.168.176]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DF000A4C for ; Mon, 28 Oct 2019 11:49:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1572259766; bh=GPxlhK6U01oMVH8OGNLeyCuixGsGDfei1PeXb8w4vFo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=QzfrqDvj0MnB0OtAQFa7HAaDJIp4pQAq/P9D5ShVvQSLdgzy5JCDH0rnNqJJlzYG7 KmO5LQTb2I9gn8JW25PVY7w6YxyxW44LWhLMkwgrp+dU8nPMI1gtq3SV5PMKS1cGaN soJf1wANZhgiGSAx9SSMEb1w6Fzk4pJ4eAnk/wgk= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 28 Oct 2019 12:49:07 +0200 Message-Id: <20191028104913.14985-4-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191028104913.14985-1-laurent.pinchart@ideasonboard.com> References: <20191028104913.14985-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 3/9] libcamera: bound_method: Store connection type in BoundMethodBase X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Oct 2019 10:49:26 -0000 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 Reviewed-by: Niklas Söderlund --- 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::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 @@ -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 public: using PackType = std::tuple::type...>; - BoundMemberMethod(T *obj, Object *object, void (T::*func)(Args...)) - : BoundMethodArgs(obj, object), func_(func) {} + BoundMemberMethod(T *obj, Object *object, void (T::*func)(Args...), + ConnectionType type = ConnectionTypeAuto) + : BoundMethodArgs(obj, object, type), func_(func) + { + } bool match(void (T::*func)(Args...)) const { return func == func_; } @@ -121,7 +128,10 @@ class BoundStaticMethod : public BoundMethodArgs { public: BoundStaticMethod(void (*func)(Args...)) - : BoundMethodArgs(nullptr, nullptr), func_(func) {} + : BoundMethodArgs(nullptr, nullptr, ConnectionTypeAuto), + func_(func) + { + } bool match(void (*func)(Args...)) const { return func == func_; }