libcamera v0.7.1
Supporting cameras in Linux since 2019
Loading...
Searching...
No Matches
global_configuration.h
1/* SPDX-License-Identifier: LGPL-2.1-or-later */
2/*
3 * Copyright (C) 2024-2025 Red Hat, inc.
4 *
5 * Global configuration handling
6 */
7
8#pragma once
9
10#include <filesystem>
11#include <initializer_list>
12#include <optional>
13#include <string>
14#include <string_view>
15
17
19
20namespace libcamera {
21
23{
24public:
26
27 unsigned int version() const;
28 const ValueNode &configuration() const;
29
30 template<typename T>
31 std::optional<T> option(
32 const std::initializer_list<std::string_view> confPath) const
33 {
34 const ValueNode *c = &configuration();
35 for (auto part : confPath) {
36 c = &(*c)[part];
37 if (!*c)
38 return {};
39 }
40 return c->get<T>();
41 }
42
43 std::optional<std::vector<std::string>> listOption(
44 const std::initializer_list<std::string_view> confPath) const;
45
46private:
47 void load();
48 bool loadFile(const std::filesystem::path &fileName);
49
50 std::unique_ptr<ValueNode> configuration_ =
51 std::make_unique<ValueNode>();
52};
53
54} /* namespace libcamera */
GlobalConfiguration()
Initialize the global configuration.
Definition global_configuration.cpp:155
const ValueNode & configuration() const
Retrieve the libcamera global configuration.
Definition global_configuration.cpp:268
unsigned int version() const
Retrieve the configuration version.
Definition global_configuration.cpp:252
std::optional< std::vector< std::string > > listOption(const std::initializer_list< std::string_view > confPath) const
Retrieve the value of configuration option confPath.
Definition global_configuration.cpp:289
std::optional< T > option(const std::initializer_list< std::string_view > confPath) const
Retrieve the value of configuration option confPath.
Definition global_configuration.h:31
A class representing a tree structure of values.
Definition value_node.h:27
std::optional< T > get() const
Parse the ValueNode as a T value.
Definition value_node.h:211
Top-level libcamera namespace.
Definition backtrace.h:17
Miscellaneous utility functions.
Data structure to manage tree of values.