{"id":25741,"url":"https://patchwork.libcamera.org/api/patches/25741/?format=json","web_url":"https://patchwork.libcamera.org/patch/25741/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260113000808.15395-22-laurent.pinchart@ideasonboard.com>","date":"2026-01-13T00:07:53","name":"[21/36] libcamera: global_configuration: Reorder functions","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"299bfc686886761347fa3df75a1244fdeff7eb2d","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/25741/mbox/","series":[{"id":5703,"url":"https://patchwork.libcamera.org/api/series/5703/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5703","date":"2026-01-13T00:07:32","name":"libcamera: Global configuration file improvements","version":1,"mbox":"https://patchwork.libcamera.org/series/5703/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/25741/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/25741/checks/","tags":{},"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 1BB72C32E0\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 13 Jan 2026 00:09:07 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A4D6461FC8;\n\tTue, 13 Jan 2026 01:09:06 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5519E61FD7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 13 Jan 2026 01:09:04 +0100 (CET)","from pendragon.ideasonboard.com (81-175-209-152.bb.dnainternet.fi\n\t[81.175.209.152])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id ABA5E66B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 13 Jan 2026 01:08:38 +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=\"lT91nOu1\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1768262918;\n\tbh=xAOfLR3namUexCO9dQWb16Jb+d6ytgSbp861prCGnus=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=lT91nOu1/XfO2W70ZP1ST6m0LNDSVxqDnLrZ1Uq2T0+jo+7UUTcPMOuhqYnAMjOVL\n\t12i4TAZLtR+qOC+qFKngIC4WQGA0ezcP2sBep4TIn6BeH+1K9BTAfvjiC8a1+s7xQX\n\tk1Xu/1hqvqA58sz0O9esZpe3IMVNL0Tt74P+il/0=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Subject":"[PATCH 21/36] libcamera: global_configuration: Reorder functions","Date":"Tue, 13 Jan 2026 02:07:53 +0200","Message-ID":"<20260113000808.15395-22-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.51.2","In-Reply-To":"<20260113000808.15395-1-laurent.pinchart@ideasonboard.com>","References":"<20260113000808.15395-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","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>"},"content":"Member functions should be implemented in the .cpp file in the same\norder as in the class definition, within each access group. Move them to\nthe right location. While at it, move load() before loadFile() in the\nclass definition to match execution order, making the code easier to\nread.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n .../libcamera/internal/global_configuration.h |   2 +-\n src/libcamera/global_configuration.cpp        | 144 +++++++++---------\n 2 files changed, 73 insertions(+), 73 deletions(-)","diff":"diff --git a/include/libcamera/internal/global_configuration.h b/include/libcamera/internal/global_configuration.h\nindex 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>();\ndiff --git a/src/libcamera/global_configuration.cpp b/src/libcamera/global_configuration.cpp\nindex 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 */\n","prefixes":["21/36"]}