From patchwork Sat Oct 12 18:43:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 2167 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 9FE1361978 for ; Sat, 12 Oct 2019 20:44:20 +0200 (CEST) Received: from pendragon.bb.dnainternet.fi (dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C527933A for ; Sat, 12 Oct 2019 20:44:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1570905860; bh=IA9VBgPUp8yRKmdQjnufsiRaJSC3uSX3RWPnb4Z3Y8U=; h=From:To:Subject:Date:In-Reply-To:References:From; b=CIhr+Qr3AYmprIMfS35pvzLj+9bTrX7l+XFT5Z45oRfOzxezRhY+X9f+gkhXF6IV5 odWZRt+95wFmf7BkcRz1bTLyLh4SiO21XqTHM1PbL6CAiFWef7vVwnHPYAS/lHZ0HA DLxMYwtSg8bmnGMFGPITBjWJanLhP5o5HzguSRMo= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Sat, 12 Oct 2019 21:43:59 +0300 Message-Id: <20191012184407.31684-7-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191012184407.31684-1-laurent.pinchart@ideasonboard.com> References: <20191012184407.31684-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 06/14] libcamera: controls: Store control name in ControlId 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: Sat, 12 Oct 2019 18:44:20 -0000 The ControlId class stores a pointer to the control name. This works fine for statically-defined controls, but requires code that allocates controls dynamically (for instance based on control discovery on a V4L2 device) to keep a list of control names in separate storage. To ease usage of dynamically allocated controls, store a copy of the control name string in the ControlId class. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Niklas Söderlund --- include/libcamera/controls.h | 6 +++--- src/libcamera/controls.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 12a13aacb198..999fcf7a3a62 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -60,11 +60,11 @@ class ControlId { public: unsigned int id() const { return id_; } - const char *name() const { return name_; } + const std::string &name() const { return name_; } ControlType type() const { return type_; } protected: - ControlId(unsigned int id, const char *name, ControlType type) + ControlId(unsigned int id, const std::string &name, ControlType type) : id_(id), name_(name), type_(type) { } @@ -74,7 +74,7 @@ private: ControlId &operator=(const ControlId &) = delete; unsigned int id_; - const char *name_; + std::string name_; ControlType type_; }; diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index bfab177fc508..292e48cd6d25 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -232,7 +232,7 @@ bool ControlValue::operator==(const ControlValue &other) const */ /** - * \fn ControlId::ControlId(unsigned int id, const char *name, ControlType type) + * \fn ControlId::ControlId(unsigned int id, const std::string &name, ControlType type) * \brief Construct a ControlId instance * \param[in] id The control numerical ID * \param[in] name The control name