[{"id":37619,"web_url":"https://patchwork.libcamera.org/comment/37619/","msgid":"<8a3ac167-5aca-4123-8390-9125f81d2c00@ideasonboard.com>","date":"2026-01-13T16:40:28","subject":"Re: [PATCH 21/36] libcamera: global_configuration: Reorder functions","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"2026. 01. 13. 1:07 keltezéssel, Laurent Pinchart írta:\n> Member functions should be implemented in the .cpp file in the same\n> order as in the class definition, within each access group. Move them to\n> the right location. While at it, move load() before loadFile() in the\n> class definition to match execution order, making the code easier to\n> read.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n\nLooks ok.\n\nReviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n\n\n>   .../libcamera/internal/global_configuration.h |   2 +-\n>   src/libcamera/global_configuration.cpp        | 144 +++++++++---------\n>   2 files changed, 73 insertions(+), 73 deletions(-)\n> \n> diff --git a/include/libcamera/internal/global_configuration.h b/include/libcamera/internal/global_configuration.h\n> index 7ae923977aa6..84bdf90244d9 100644\n> --- a/include/libcamera/internal/global_configuration.h\n> +++ b/include/libcamera/internal/global_configuration.h\n> @@ -52,8 +52,8 @@ public:\n>   \t\tconst std::string delimiter = \":\") const;\n>   \n>   private:\n> -\tbool loadFile(const std::filesystem::path &fileName);\n>   \tvoid load();\n> +\tbool loadFile(const std::filesystem::path &fileName);\n>   \n>   \tstd::unique_ptr<ValueNode> yamlConfiguration_ =\n>   \t\tstd::make_unique<ValueNode>();\n> diff --git a/src/libcamera/global_configuration.cpp b/src/libcamera/global_configuration.cpp\n> index c4999d32d7c7..c853a028c91d 100644\n> --- a/src/libcamera/global_configuration.cpp\n> +++ b/src/libcamera/global_configuration.cpp\n> @@ -53,6 +53,48 @@ LOG_DEFINE_CATEGORY(Configuration)\n>    * options, or configuration() to access the whole configuration.\n>    */\n>   \n> +/**\n> + * \\typedef GlobalConfiguration::Configuration\n> + * \\brief Type representing global libcamera configuration\n> + *\n> + * All code outside GlobalConfiguration must use this type declaration and not\n> + * the underlying type.\n> + */\n> +\n> +/**\n> + * \\brief Initialize the global configuration\n> + */\n> +GlobalConfiguration::GlobalConfiguration()\n> +{\n> +\tload();\n> +}\n> +\n> +void GlobalConfiguration::load()\n> +{\n> +\tstd::filesystem::path userConfigurationDirectory;\n> +\tconst char *xdgConfigHome = utils::secure_getenv(\"XDG_CONFIG_HOME\");\n> +\tif (xdgConfigHome) {\n> +\t\tuserConfigurationDirectory = xdgConfigHome;\n> +\t} else {\n> +\t\tconst char *home = utils::secure_getenv(\"HOME\");\n> +\t\tif (home)\n> +\t\t\tuserConfigurationDirectory =\n> +\t\t\t\tstd::filesystem::path(home) / \".config\";\n> +\t}\n> +\n> +\tif (!userConfigurationDirectory.empty()) {\n> +\t\tstd::filesystem::path user_configuration_file =\n> +\t\t\tuserConfigurationDirectory / \"libcamera\" / \"configuration.yaml\";\n> +\t\tif (loadFile(user_configuration_file))\n> +\t\t\treturn;\n> +\t}\n> +\n> +\tfor (const auto &path : globalConfigurationFiles) {\n> +\t\tif (loadFile(path))\n> +\t\t\treturn;\n> +\t}\n> +}\n> +\n>   bool GlobalConfiguration::loadFile(const std::filesystem::path &fileName)\n>   {\n>   \tFile file(fileName);\n> @@ -85,47 +127,39 @@ bool GlobalConfiguration::loadFile(const std::filesystem::path &fileName)\n>   \treturn true;\n>   }\n>   \n> -void GlobalConfiguration::load()\n> -{\n> -\tstd::filesystem::path userConfigurationDirectory;\n> -\tconst char *xdgConfigHome = utils::secure_getenv(\"XDG_CONFIG_HOME\");\n> -\tif (xdgConfigHome) {\n> -\t\tuserConfigurationDirectory = xdgConfigHome;\n> -\t} else {\n> -\t\tconst char *home = utils::secure_getenv(\"HOME\");\n> -\t\tif (home)\n> -\t\t\tuserConfigurationDirectory =\n> -\t\t\t\tstd::filesystem::path(home) / \".config\";\n> -\t}\n> -\n> -\tif (!userConfigurationDirectory.empty()) {\n> -\t\tstd::filesystem::path user_configuration_file =\n> -\t\t\tuserConfigurationDirectory / \"libcamera\" / \"configuration.yaml\";\n> -\t\tif (loadFile(user_configuration_file))\n> -\t\t\treturn;\n> -\t}\n> -\n> -\tfor (const auto &path : globalConfigurationFiles) {\n> -\t\tif (loadFile(path))\n> -\t\t\treturn;\n> -\t}\n> -}\n> -\n>   /**\n> - * \\brief Initialize the global configuration\n> - */\n> -GlobalConfiguration::GlobalConfiguration()\n> -{\n> -\tload();\n> -}\n> -\n> -/**\n> - * \\typedef GlobalConfiguration::Configuration\n> - * \\brief Type representing global libcamera configuration\n> + * \\brief Retrieve the configuration version\n>    *\n> - * All code outside GlobalConfiguration must use this type declaration and not\n> - * the underlying type.\n> + * The version is declared in the configuration file in the top-level `%version`\n> + * element, alongside `%configuration`. This has currently no real use but may be\n> + * needed in future if configuration incompatibilities occur.\n> + *\n> + * \\return Configuration version as declared in the configuration file or 0 if\n> + * no global configuration is available\n>    */\n> +unsigned int GlobalConfiguration::version() const\n> +{\n> +\treturn (*yamlConfiguration_)[\"version\"].get<unsigned int>().value_or(0);\n> +}\n> +\n> +/**\n> + * \\brief Retrieve the libcamera global configuration\n> + *\n> + * This returns the whole configuration stored in the top-level section\n> + * `%configuration` of the YAML configuration file.\n> + *\n> + * The requested part of the configuration can be accessed using \\a ValueNode\n> + * methods.\n> + *\n> + * \\note \\a ValueNode type itself shouldn't be used in type declarations to\n> + * avoid trouble if we decide to change the underlying data objects in future.\n> + *\n> + * \\return The whole configuration section\n> + */\n> +GlobalConfiguration::Configuration GlobalConfiguration::configuration() const\n> +{\n> +\treturn (*yamlConfiguration_)[\"configuration\"];\n> +}\n>   \n>   /**\n>    * \\fn std::optional<T> GlobalConfiguration::option(const std::initializer_list<std::string_view> &confPath) const\n> @@ -216,38 +250,4 @@ std::optional<std::vector<std::string>> GlobalConfiguration::envListOption(\n>   \treturn listOption(confPath);\n>   }\n>   \n> -/**\n> - * \\brief Retrieve the configuration version\n> - *\n> - * The version is declared in the configuration file in the top-level `%version`\n> - * element, alongside `%configuration`. This has currently no real use but may be\n> - * needed in future if configuration incompatibilities occur.\n> - *\n> - * \\return Configuration version as declared in the configuration file or 0 if\n> - * no global configuration is available\n> - */\n> -unsigned int GlobalConfiguration::version() const\n> -{\n> -\treturn (*yamlConfiguration_)[\"version\"].get<unsigned int>().value_or(0);\n> -}\n> -\n> -/**\n> - * \\brief Retrieve the libcamera global configuration\n> - *\n> - * This returns the whole configuration stored in the top-level section\n> - * `%configuration` of the YAML configuration file.\n> - *\n> - * The requested part of the configuration can be accessed using \\a ValueNode\n> - * methods.\n> - *\n> - * \\note \\a ValueNode type itself shouldn't be used in type declarations to\n> - * avoid trouble if we decide to change the underlying data objects in future.\n> - *\n> - * \\return The whole configuration section\n> - */\n> -GlobalConfiguration::Configuration GlobalConfiguration::configuration() const\n> -{\n> -\treturn (*yamlConfiguration_)[\"configuration\"];\n> -}\n> -\n>   } /* namespace libcamera */","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 673A6BDCBF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 13 Jan 2026 16:40:34 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7976C61FBC;\n\tTue, 13 Jan 2026 17:40:33 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AA72C61FA0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 13 Jan 2026 17:40:32 +0100 (CET)","from [192.168.33.30] (185.221.143.114.nat.pool.zt.hu\n\t[185.221.143.114])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 629D550A;\n\tTue, 13 Jan 2026 17:40:06 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"YdHTB+et\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1768322406;\n\tbh=OdQhCiXb09smPXasmLfih3VzClUNBQGUqKCJjt9ZT7A=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=YdHTB+etNe0eXCPx4Gh/dR7AVlQcP9ztS54WOMeTkkGeXhWLH4p4dGTmRVSv22ZK3\n\tlvPzBHKzNU5+1VOx39jQjR+PYhDO432o+bwz11KLaJ6tWv0Q7jbQ8QNgVbdE0Ie9Mm\n\tBcLtY0Pww/AomisFRiQs4B5oSj1XDNwpuon58Ylw=","Message-ID":"<8a3ac167-5aca-4123-8390-9125f81d2c00@ideasonboard.com>","Date":"Tue, 13 Jan 2026 17:40:28 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH 21/36] libcamera: global_configuration: Reorder functions","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20260113000808.15395-1-laurent.pinchart@ideasonboard.com>\n\t<20260113000808.15395-22-laurent.pinchart@ideasonboard.com>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<20260113000808.15395-22-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"8bit","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]