{"id":26472,"url":"https://patchwork.libcamera.org/api/patches/26472/?format=json","web_url":"https://patchwork.libcamera.org/patch/26472/","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":"<20260407153427.1825999-33-laurent.pinchart@ideasonboard.com>","date":"2026-04-07T15:34:17","name":"[v2,32/42] 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/26472/mbox/","series":[{"id":5873,"url":"https://patchwork.libcamera.org/api/series/5873/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5873","date":"2026-04-07T15:33:45","name":"libcamera: Global configuration file improvements","version":2,"mbox":"https://patchwork.libcamera.org/series/5873/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/26472/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/26472/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 E2190C3323\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  7 Apr 2026 15:35:19 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 644F862E3A;\n\tTue,  7 Apr 2026 17:35:19 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D95E762E12\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  7 Apr 2026 17:35:12 +0200 (CEST)","from killaraus.ideasonboard.com\n\t(2001-14ba-703d-e500--2a1.rev.dnainternet.fi\n\t[IPv6:2001:14ba:703d:e500::2a1])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 42893DA4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  7 Apr 2026 17:33:45 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"MrbxktGT\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1775576025;\n\tbh=lXFT8sbMKANHO79mqPYgg46EfdY7jAa3FvD524sI4Qo=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=MrbxktGTHMLKjqVN6w03anK4GRkdpxeTzKlzksfHY2uAKN8xrakLbrgNnHhLPLWCa\n\tPzKwTUClaxcwL0lQhN+CJVuGQmpFsi+mckQf8ALxygJ/PjpBA2BaN32kGVcJJquaDL\n\tIEP1tKAjTUuLgWVaMsUaeARxowatSSxTNsx2iRlo=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Subject":"[PATCH v2 32/42] libcamera: global_configuration: Reorder functions","Date":"Tue,  7 Apr 2026 18:34:17 +0300","Message-ID":"<20260407153427.1825999-33-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.52.0","In-Reply-To":"<20260407153427.1825999-1-laurent.pinchart@ideasonboard.com>","References":"<20260407153427.1825999-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","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>\nReviewed-by: Barnabás Pőcze <barnabas.pocze@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":["v2","32/42"]}