From patchwork Thu Jul 15 21:14:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 12980 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 B7DB1C3226 for ; Thu, 15 Jul 2021 21:15:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DE02F68570; Thu, 15 Jul 2021 23:15:15 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="oOApXN9Y"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8E33968546 for ; Thu, 15 Jul 2021 23:15:07 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2AA20A24 for ; Thu, 15 Jul 2021 23:15:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1626383707; bh=3CbVBqlvR4y2KFGEeYoAcZ0MxdCSJT+hk2B2NKx6XR4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=oOApXN9Y1ntIx2bgN16xXcpuqq1nQ6fWTb9GEj24skxrkbMDEtXGY+/tQJYXeM6O5 jsfX6eJL7p+V8sI7+ujihoNlyIlsBswvJ7Bp/qxaAkyE/b878zE0bE6/MxbD7tpwUW HjOa+RbEVQBDyxNxNBYUvCcJZwrrZOktJkRZBDIw= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Fri, 16 Jul 2021 00:14:35 +0300 Message-Id: <20210715211459.19373-10-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210715211459.19373-1-laurent.pinchart@ideasonboard.com> References: <20210715211459.19373-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 09/33] cam: options: Support parent-child relationship between options 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add support for creating a tree-based hieararchy of options instead of a flat list. This is useful to support options that need to be interpreted in the context of a particular occurrence of an array option. The usage text automatically documents the options in their corresponding context: Options: -c, --camera camera ... Specify which camera to operate on, by id or by index -h, --help Display this help message -I, --info Display information about stream(s) -l, --list List all cameras --list-controls List cameras controls -p, --list-properties List cameras properties -m, --monitor Monitor for hotplug and unplug camera events Options valid in the context of --camera: -C, --capture[=count] Capture until interrupted by user or until frames captured -F, --file[=filename] Write captured frames to disk If the file name ends with a '/', it sets the directory in which to write files, using the default file name. Otherwise it sets the full file path and name. The first '#' character in the file name is expanded to the camera index, stream name and frame sequence number. The default file name is 'frame-#.bin'. -s, --stream key=value[,key=value,...] ... Set configuration of a camera stream height=integer Height in pixels pixelformat=string Pixel format name role=string Role for the stream (viewfinder, video, still, raw) width=integer Width in pixels --strict-formats Do not allow requested stream format(s) to be adjusted --metadata Print the metadata for completed requests Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- Changes since v1: - Add a sample help text to the commit message - Clarify comments - Fix typos --- src/cam/options.cpp | 217 ++++++++++++++++++++++++++++++++++++++------ src/cam/options.h | 14 ++- 2 files changed, 199 insertions(+), 32 deletions(-) diff --git a/src/cam/options.cpp b/src/cam/options.cpp index 379b68c3be60..59b26be4deff 100644 --- a/src/cam/options.cpp +++ b/src/cam/options.cpp @@ -79,6 +79,12 @@ * \var Option::isArray * \brief Whether the option can appear once or multiple times * + * \var Option::parent + * \brief The parent option + * + * \var Option::children + * \brief List of child options, storing all options whose parent is this option + * * \fn Option::hasShortOption() * \brief Tell if the option has a short option specifier (e.g. `-f`) * \return True if the option has a short option specifier, false otherwise @@ -96,6 +102,8 @@ struct Option { const char *help; KeyValueParser *keyValueParser; bool isArray; + Option *parent; + std::list