libcamera: libcamera::GlobalConfiguration Class Reference

libcamera v0.7.2 Supporting cameras in Linux since 2019

Loading...
Searching...
No Matches
libcamera::GlobalConfiguration Class Reference

Support for global libcamera configuration. More...

## Public Member Functions
| GlobalConfiguration ()
| Initialize the global configuration.
unsigned int | version () const
| Retrieve the configuration version.
const ValueNode & | configuration () const
| Retrieve the libcamera global configuration.
template<typename T>
std::optional< T > | option (const std::initializer_list< std::string_view > confPath) const
| Retrieve the value of configuration option confPath.
std::optional< std::vector< std::string > > | listOption (const std::initializer_list< std::string_view > confPath) const
| Retrieve the value of configuration option confPath.

## Detailed Description

Support for global libcamera configuration.

The configuration file is a YAML file and the configuration itself is stored under a configuration top-level item.

The configuration file is looked up in the user's home directory first and, if it is not found, then in system-wide configuration directories. If multiple configuration files exist then only the first one found is used and no configuration merging is performed.

If the first found configuration file cannot be opened or parsed, an error is reported and no configuration file is used. This is to prevent libcamera from using an unintended configuration file.

The configuration can be accessed using the provided helpers, namely option() and listOption() to access individual options, or configuration() to access the whole configuration.

## Member Function Documentation

## ◆ configuration()

const ValueNode & libcamera::GlobalConfiguration::configuration | ( |  | ) | const

Retrieve the libcamera global configuration.

This returns the whole configuration stored in the top-level section configuration of the configuration file.

The requested part of the configuration can be accessed using ValueNode methods.

Returns
  The global configuration

## ◆ listOption()

std::optional< std::vector< std::string > > libcamera::GlobalConfiguration::listOption | ( | const std::initializer_list< std::string_view > | confPath | ) | const

Retrieve the value of configuration option confPath.

Parameters

  [in] | confPath | Sequence of the section names (excluding configuration) leading to the requested list option, separated by dots

Returns
  A vector of strings or no value if not found

## ◆ option()

template<typename T>

std::optional< T > libcamera::GlobalConfiguration::option | ( | const std::initializer_list< std::string_view > | confPath | ) | const
| inline

Retrieve the value of configuration option confPath.

Template Parameters

  T | The type of the retrieved configuration value

Parameters

  [in] | confPath | Sequence of the section names (excluding configuration) leading to the requested option

Returns
  The value of the configuration item corresponding to confPath if it exists in the configuration file, or no value otherwise

## ◆ version()

unsigned int libcamera::GlobalConfiguration::version | ( |  | ) | const

Retrieve the configuration version.

The version is declared in the configuration file in the top-level version element, alongside configuration. This has currently no real use but may be needed in future if configuration incompatibilities occur.

Returns
  Configuration version as declared in the configuration file or 0 if no global configuration is available

The documentation for this class was generated from the following files:

- include/libcamera/internal/global_configuration.h
- src/libcamera/global_configuration.cpp