From patchwork Wed Apr 6 15:18:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 15643 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 5703DC0F1B for ; Wed, 6 Apr 2022 15:18:43 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A570C65642; Wed, 6 Apr 2022 17:18:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1649258322; bh=cqhytSTROdXpe0QotY+gbk6xpE5iZ2xMct8+NOHsWWo=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=sCX1XoeIOdZAS8grJwDqrUYfopZ/uii1OlTTfldtYLBDWxzqHzkhcspi7q2eh/kMq YStasDQg0PkUUkFmyqLio7Ya3yngFyUobTr2s4RCi/P62ZZI+/mtUZT8fWJ7phMewn aN5jey56aALd9i1UV4YATW8GQkPlAbDp0FF5O0009fAoNLTaPkzJbVGeuuU0sYN7pe 4yb3E3J5Pn1rnTeA+8PusQHYaNhJTNCAts8VFcK5w5ZWgKQiBQoskZDwEsJqzLpBdU yMJ1nYypUvDOsscqm+bJ+31mOsLLOKhV2JTvszC7aRLroohGoFGWgcvmCdUMRR5g/l E8tD93NS5vOsQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 693F4604B8 for ; Wed, 6 Apr 2022 17:18:40 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="MxisHNnD"; dkim-atps=neutral Received: from pendragon.home (117.145-247-81.adsl-dyn.isp.belgacom.be [81.247.145.117]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 009BE482 for ; Wed, 6 Apr 2022 17:18:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1649258320; bh=cqhytSTROdXpe0QotY+gbk6xpE5iZ2xMct8+NOHsWWo=; h=From:To:Subject:Date:From; b=MxisHNnDnHlYy1qGYgJFeVN5B6cHhMNsFkQZUbTiO1QV6+fkqM3qaqcX3bRHjEyZ4 eFLQIrBjg1DBEqElk2N+/mwN5T/wDrhkU7UZpoGj8jruzxKkjElydemm+EGpB3AhLv 0dN6R/aDtbtMA2UKm0rO0hWbcXB7SVJ/4TbdjOb0= To: libcamera-devel@lists.libcamera.org Date: Wed, 6 Apr 2022 18:18:33 +0300 Message-Id: <20220406151833.1176-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] libcamera: base: utils: Add missing constructor for Duration 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-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The Duration class is missing the equivalent to the std::chrono::duration constructor that takes a number of ticks expressed as a scalar. Fix it, which allows initializing a Duration instance to 0 or 0.0. Signed-off-by: Laurent Pinchart Reviewed-by: Umang Jain Reviewed-by: Kieran Bingham --- include/libcamera/base/utils.h | 6 ++++++ src/libcamera/base/utils.cpp | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/include/libcamera/base/utils.h b/include/libcamera/base/utils.h index 9ab18101cf27..cfff05836de7 100644 --- a/include/libcamera/base/utils.h +++ b/include/libcamera/base/utils.h @@ -327,6 +327,12 @@ class Duration : public std::chrono::duration public: Duration() = default; + template + constexpr explicit Duration(const Rep &r) + : BaseDuration(r) + { + } + template constexpr Duration(const std::chrono::duration &d) : BaseDuration(d) diff --git a/src/libcamera/base/utils.cpp b/src/libcamera/base/utils.cpp index 8cf8a5b2c104..6a307940448e 100644 --- a/src/libcamera/base/utils.cpp +++ b/src/libcamera/base/utils.cpp @@ -406,6 +406,15 @@ std::string toAscii(const std::string &str) * duration in nanoseconds with double precision */ +/** + * \fn Duration::Duration(const Rep &r) + * \brief Construct a Duration with \a r ticks + * \param[in] r The number of ticks + * + * The constructed \a Duration object is internally represented in double + * precision with \a r nanoseconds ticks. + */ + /** * \fn Duration::Duration(const std::chrono::duration &d) * \brief Construct a Duration by converting an arbitrary std::chrono::duration