14 #ifndef DS3D_COMMON_HPP_YAML_CONFIG_HPP
15 #define DS3D_COMMON_HPP_YAML_CONFIG_HPP
21 #include <yaml-cpp/yaml.h>
26 namespace ds3d {
namespace config {
39 template <
class F,
typename... Args>
44 DS3D_TRY { code = f(std::forward<Args>(args)...); }
57 YAML::Node node = YAML::Load(yamlComp);
58 config.
name = node[
"name"].as<std::string>();
60 std::string type = node[
"type"].as<std::string>();
65 auto inCapsNode = node[
"in_caps"];
67 config.
gstInCaps = inCapsNode.as<std::string>();
69 auto outCapsNode = node[
"out_caps"];
71 config.
gstOutCaps = outCapsNode.as<std::string>();
73 auto linkToNode = node[
"link_to"];
75 config.
linkTo = linkToNode.as<std::string>();
77 auto linkFromNode = node[
"link_from"];
79 config.
linkFrom = linkFromNode.as<std::string>();
82 auto withQueueNode = node[
"with_queue"];
84 config.
withQueue = withQueueNode.as<std::string>();
87 if (node[
"custom_lib_path"]) {
88 config.
customLibPath = node[
"custom_lib_path"].as<std::string>();
92 if (node[
"custom_create_function"]) {
96 "custom_create_function not found in config");
99 auto bodyNode = node[
"config_body"];
102 if (!bodyNode[
"config_path"] && !path.empty()) {
103 bodyNode[
"config_path"] = path;
109 "config_body error in config, yaml error: " + body.GetLastError());
113 YAML::Emitter yRawContent;
121 const std::string& yamlDoc,
const std::string& path, std::vector<ComponentConfig>& all)
123 auto nodes = YAML::LoadAll(yamlDoc);
124 for (
const auto& doc : nodes) {
128 YAML::Emitter content;
132 "component error in config, yaml error: " + content.GetLastError());
136 "parsing a component failed in config");
137 all.push_back(config);
144 #endif // DS3D_COMMON_HPP_YAML_CONFIG_HPP