Sen API
Sen Libraries
Loading...
Searching...
No Matches
bootloader.h
Go to the documentation of this file.
1// === bootloader.h ====================================================================================================
2// Sen Infrastructure
3// Released under the Apache License v2.0 (SPDX-License-Identifier Apache-2.0).
4// See the LICENSE.txt file for more information.
5// © Airbus SAS, Airbus Helicopters, and Airbus Defence and Space SAU/GmbH/SAS.
6// =====================================================================================================================
7
8#ifndef SEN_KERNEL_BOOTLOADER_H
9#define SEN_KERNEL_BOOTLOADER_H
10
11// sen
13#include "sen/kernel/kernel.h"
15
16// std
17#include <filesystem>
18#include <memory>
19#include <string>
20
21namespace sen::kernel
22{
23
27[[nodiscard]] VarMap getConfigAsVarFromYaml(const std::filesystem::path& path, bool printFinalConfig = false);
28
33[[nodiscard]] VarMap getConfigAsVarFromYaml(const std::string& content,
34 const std::filesystem::path& path,
35 bool printFinalConfig = false);
36
38class Bootloader final
39{
40 SEN_NOCOPY_NOMOVE(Bootloader)
41
42public:
44 static std::unique_ptr<Bootloader> fromYamlFile(const std::filesystem::path& path, bool printConfig);
45
47 static std::unique_ptr<Bootloader> fromYamlString(const std::string& config, bool printConfig);
48
50
51public:
53 [[nodiscard]] KernelConfig& getConfig() noexcept;
54
55private:
56 Bootloader();
57
58private:
59 void loadConfigFromString(const std::string& content, const std::filesystem::path& path, bool printFinalConfig);
60
61 void loadConfigFromFile(const std::filesystem::path& path, bool printFinalConfig);
62
63 void loadKernelConfig(const VarMap& data);
64
65 void loadComponents(const VarMap& data);
66
67 void loadPipelines(const VarMap& data);
68
69 void component(std::string_view path, const Var& data);
70
71 void pipeline(std::string_view name, const Var& data);
72
73 static void fetchPipelineObjects(KernelConfig::PipelineToLoad& pipelineConfig, const VarMap& map);
74
75 static void fetchPipelineComponentConfig(KernelConfig::PipelineToLoad& pipelineConfig, const Var& data);
76
77 static void fetchPipelineExecPeriod(KernelConfig::PipelineToLoad& pipelineConfig, const VarMap& map);
78
79 static void fetchPipelineUserDefinedParams(KernelConfig::PipelineToLoad& pipelineConfig, const VarMap& map);
80
81private:
82 KernelConfig config_;
83 VarMap configVar_;
84};
85
86} // namespace sen::kernel
87
88#endif // SEN_KERNEL_BOOTLOADER_H
Here we define a set of template meta-programming helpers to let the compiler take some decisions bas...
static std::unique_ptr< Bootloader > fromYamlString(const std::string &config, bool printConfig)
Reads the configuration from a string in YAML format.
static std::unique_ptr< Bootloader > fromYamlFile(const std::filesystem::path &path, bool printConfig)
Opens a YAML configuration file and stores it in a KernelConfig structure.
KernelConfig & getConfig() noexcept
The loaded configuration info.
Holds the kernel configuration information.
Definition kernel_config.h:33
VarMap getConfigAsVarFromYaml(const std::filesystem::path &path, bool printFinalConfig=false)
Loads a configuration YAML file and returns its contents as a sen::VarMap. This function does not val...
std::map< std::string, Var, std::less<> > VarMap
A map of vars to represent structures.
Definition var.h:107
Strong type for the unique identifier for a transport timer.
Definition native_object_impl.h:39
STL namespace.
Can hold any supported value type. Wraps std::variant to allow recursion and implements some helpers.
Definition var.h:119