{"id":9669,"url":"https://patchwork.libcamera.org/api/patches/9669/?format=json","web_url":"https://patchwork.libcamera.org/patch/9669/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20200918152019.784315-3-tomi.valkeinen@iki.fi>","date":"2020-09-18T15:20:17","name":"[libcamera-devel,RFC,2/4] Add BoundMethodFunction","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"fc60cdc808a0457a8493df465de8d2e34aef9ba9","submitter":{"id":70,"url":"https://patchwork.libcamera.org/api/people/70/?format=json","name":"Tomi Valkeinen","email":"tomi.valkeinen@iki.fi"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/9669/mbox/","series":[{"id":1297,"url":"https://patchwork.libcamera.org/api/series/1297/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1297","date":"2020-09-18T15:20:15","name":"prototype python bindings","version":1,"mbox":"https://patchwork.libcamera.org/series/1297/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/9669/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/9669/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 58EE8BF01C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 18 Sep 2020 15:21:02 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2486B62FCF;\n\tFri, 18 Sep 2020 17:21:02 +0200 (CEST)","from mail-lf1-x130.google.com (mail-lf1-x130.google.com\n\t[IPv6:2a00:1450:4864:20::130])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 55AC362F4F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 18 Sep 2020 17:20:59 +0200 (CEST)","by mail-lf1-x130.google.com with SMTP id b12so6515392lfp.9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 18 Sep 2020 08:20:59 -0700 (PDT)","from deskari.ti.com (91-152-83-50.elisa-laajakaista.fi.\n\t[91.152.83.50]) by smtp.gmail.com with ESMTPSA id\n\ti63sm666472lji.66.2020.09.18.08.20.58\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 18 Sep 2020 08:20:58 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"h3wXPs/q\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=sender:from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=KsNV7hPubnwpAA0/Hbjp4VcYJ38B/XQfNuqba0A+rgc=;\n\tb=h3wXPs/qOo2L/FP6P90EnrZL7ClyoRz7vMNtTTpxTeFHtHfkU8uJ+gh2TQyQ6/yZhB\n\tA7+rlKd48Pu+OnWNFOfvdGadSenXP7R+iHVGQVGzszsz1LhwA5ZAUcWQD5F/97oxGuIm\n\t5clgfHZ2rkry6B6ocEu56XYo0RLsJ3j+xAx2Je0fYJcs3+VBRgWAt5KcGeWl7lQDbYax\n\trEeIfbPL0DOd6q7jo1aQe0eJQ772AWFpfDXwZPi19DkNJIwhwK8i4DXkepL+VPK0MEQu\n\tLWOKzLIvcNeQYZJaU/rWEbAj/jw3ERpFv/NUJVSAzwcMkcQfzue2vrf2RUC+ACZxLkaI\n\tTAWw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:sender:from:to:cc:subject:date:message-id\n\t:in-reply-to:references:mime-version:content-transfer-encoding;\n\tbh=KsNV7hPubnwpAA0/Hbjp4VcYJ38B/XQfNuqba0A+rgc=;\n\tb=Q2kBK2Nm/1Qf6587h5V6+eeN9fqMnmWBnPo70RYygMWh9lJatvmDza9WNFxoD9LEaN\n\tRkEwBbt7bAsgDwhAae/Q0JaqkGCwS69/Hz3kyVe0InOeoDs0RkUbwnfjsePfAlq30XfY\n\t8LNwaDh/VduOCt7NbzJ3q68XJBa755SQJQ6eWQmyBgcQViUE+9/jupS4XBxdNAXbD8iT\n\tdolB1V++2pveMWUnrc+NMQ1dBJZP3jCHmMp5ONhcleOahMIhZ2gtfwLvLK65hP/75XuC\n\tE/xZq0PTvFV1rta401s4fpVafvgp/+nmrsojq80s42+NW0TY1lujvCRMUqgmG7Wlwvmf\n\tUCQQ==","X-Gm-Message-State":"AOAM531hSD/U2u2Hvg1yZ7Lg8jlCCZljAbNaDmRcZLFcJJfnAxVxaoe9\n\t0ETE3zcPiA/V3a/8NS+mpYDE3aBbuOWYTA==","X-Google-Smtp-Source":"ABdhPJzTbFcNZdaZUR9T2/GY3pcCIqK3qU6Iaj2uSgr5ombjd9lWqHtBBYf+nKadO/XPi9uAag7itQ==","X-Received":"by 2002:a19:b97:: with SMTP id\n\t145mr12082108lfl.269.1600442458620; \n\tFri, 18 Sep 2020 08:20:58 -0700 (PDT)","From":"Tomi Valkeinen <tomi.valkeinen@iki.fi>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 18 Sep 2020 18:20:17 +0300","Message-Id":"<20200918152019.784315-3-tomi.valkeinen@iki.fi>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<20200918152019.784315-1-tomi.valkeinen@iki.fi>","References":"<20200918152019.784315-1-tomi.valkeinen@iki.fi>","MIME-Version":"1.0","Subject":"[libcamera-devel] [RFC 2/4] Add BoundMethodFunction","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"Tomi Valkeinen <tomi.valkeinen@iki.fi>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Note: no way to disconnect, except disconnect all.\n\nSigned-off-by: Tomi Valkeinen <tomi.valkeinen@iki.fi>\n---\n include/libcamera/bound_method.h | 25 +++++++++++++++++++++++++\n include/libcamera/signal.h       |  6 ++++++\n 2 files changed, 31 insertions(+)","diff":"diff --git a/include/libcamera/bound_method.h b/include/libcamera/bound_method.h\nindex d1e4448..d720199 100644\n--- a/include/libcamera/bound_method.h\n+++ b/include/libcamera/bound_method.h\n@@ -11,6 +11,7 @@\n #include <tuple>\n #include <type_traits>\n #include <utility>\n+#include <functional>\n \n namespace libcamera {\n \n@@ -228,6 +229,30 @@ private:\n \tR (*func_)(Args...);\n };\n \n+template<typename R, typename... Args>\n+class BoundMethodFunction : public BoundMethodArgs<R, Args...>\n+{\n+public:\n+\tBoundMethodFunction(std::function<R(Args...)> func)\n+\t        : BoundMethodArgs<R, Args...>(nullptr, nullptr, ConnectionTypeAuto),\n+\t          func_(func)\n+\t{\n+\t}\n+\n+\tR activate(Args... args, [[maybe_unused]] bool deleteMethod = false) override\n+\t{\n+\t\treturn func_(args...);\n+\t}\n+\n+\tR invoke(Args...) override\n+\t{\n+\t\treturn R();\n+\t}\n+\n+private:\n+\tstd::function<R(Args...)> func_;\n+};\n+\n } /* namespace libcamera */\n \n #endif /* __LIBCAMERA_BOUND_METHOD_H__ */\ndiff --git a/include/libcamera/signal.h b/include/libcamera/signal.h\nindex accb797..939169f 100644\n--- a/include/libcamera/signal.h\n+++ b/include/libcamera/signal.h\n@@ -68,6 +68,12 @@ public:\n \t\tSignalBase::connect(new BoundMethodStatic<R, Args...>(func));\n \t}\n \n+\ttemplate<typename R>\n+\tvoid connect(std::function<R(Args...)> func)\n+\t{\n+\t\tSignalBase::connect(new BoundMethodFunction<R, Args...>(func));\n+\t}\n+\n \tvoid disconnect()\n \t{\n \t\tSignalBase::disconnect([]([[maybe_unused]] SlotList::iterator &iter) {\n","prefixes":["libcamera-devel","RFC","2/4"]}