ChimeraTK-ApplicationCore 04.06.00
Loading...
Searching...
No Matches
PyConfigReader.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de>
2// SPDX-License-Identifier: LGPL-3.0-or-later
3#pragma once
4
5#include <pybind11/pybind11.h>
6// pybind11.h must come first
7
8#include "ConfigReader.h"
9
10#include <ChimeraTK/VariantUserTypes.h>
11
12namespace py = pybind11;
13
14namespace ChimeraTK {
15
16 /********************************************************************************************************************/
17
19 public:
20 explicit PyConfigReader(ConfigReader& wrappedReader) : _reader(wrappedReader) {}
21
22 // Config reader provides this with two functions, we move it to one single function that has an optional
23 // default value, and internally dispatches to either of the two get() functions depending on whether or not that
24 // optional was passed in.
25 UserTypeVariantNoVoid get(
26 ChimeraTK::DataType dt, const std::string& path, std::optional<UserTypeVariantNoVoid> defaultValue);
27
28 template<typename UserType>
29 using Vector = std::vector<UserType>;
30
31 // Variant of the above for getting arrays
32 UserTypeTemplateVariantNoVoid<Vector> getArray(ChimeraTK::DataType dt, const std::string& path,
33 std::optional<UserTypeTemplateVariantNoVoid<Vector>> defaultValue);
34
35 std::list<std::string> getModules(const std::string& path) { return _reader.get().getModules(path); }
36
37 static void bind(py::module& mod);
38
39 private:
40 std::reference_wrapper<ConfigReader> _reader;
41 };
42
43 /********************************************************************************************************************/
44
45} // namespace ChimeraTK
Generic module to read an XML config file and provide the defined values as constant variables.
static void bind(py::module &mod)
UserTypeTemplateVariantNoVoid< Vector > getArray(ChimeraTK::DataType dt, const std::string &path, std::optional< UserTypeTemplateVariantNoVoid< Vector > > defaultValue)
PyConfigReader(ConfigReader &wrappedReader)
std::vector< UserType > Vector
std::list< std::string > getModules(const std::string &path)
UserTypeVariantNoVoid get(ChimeraTK::DataType dt, const std::string &path, std::optional< UserTypeVariantNoVoid > defaultValue)
InvalidityTracer application module.
module_ module