From patchwork Mon Oct 7 22:46:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 2131 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D38B76196D for ; Tue, 8 Oct 2019 00:46:53 +0200 (CEST) Received: from pendragon.ideasonboard.com (modemcable118.64-20-96.mc.videotron.ca [96.20.64.118]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DD8CDB2D for ; Tue, 8 Oct 2019 00:46:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1570488413; bh=Or7twWIOEHG3Sh66YjvPhV7jDAQxmDeF4WX3kjWOeBQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Q5pTExUdclVbmBhpwDorEfH+Db3swQRm6UexUvSbhOfy9wDh9Q7NWOUByer4HnSJ+ BjlRcxuzy0vgZSvAa0mPCWNRbpFHtyr+ZdiKziejrM39wg1xTHl4JuIUJUPASO20u1 D2qSPdB5HovAIi/3encaTisiBO8dbQwfB1fi4zwM= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Tue, 8 Oct 2019 01:46:36 +0300 Message-Id: <20191007224642.6597-4-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191007224642.6597-1-laurent.pinchart@ideasonboard.com> References: <20191007224642.6597-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/9] 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: Mon, 07 Oct 2019 22:46:54 -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 --- 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 49ff1a6f747f..a5a6a135ec16 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -54,11 +54,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) { } @@ -68,7 +68,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 f862a09adef9..e528dd80a2a7 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -205,7 +205,7 @@ std::string ControlValue::toString() 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