18 #ifndef DS3D_COMMON_HPP_YAML_CONFIG_HPP
19 #define DS3D_COMMON_HPP_YAML_CONFIG_HPP
21 #include <ds3d/common/common.h>
22 #include <ds3d/common/idatatype.h>
23 #include <ds3d/common/type_trait.h>
24 #include <ds3d/common/config.h>
25 #include <yaml-cpp/yaml.h>
30 namespace ds3d {
namespace config {
43 template <
class F,
typename... Args>
48 DS3D_TRY { code = f(std::forward<Args>(args)...); }
61 YAML::Node node = YAML::Load(yamlComp);
62 config.
name = node[
"name"].as<std::string>();
64 std::string type = node[
"type"].as<std::string>();
69 auto inCapsNode = node[
"in_caps"];
71 config.
gstInCaps = inCapsNode.as<std::string>();
73 auto outCapsNode = node[
"out_caps"];
75 config.
gstOutCaps = outCapsNode.as<std::string>();
77 auto linkToNode = node[
"link_to"];
79 config.
linkTo = linkToNode.as<std::string>();
81 auto linkFromNode = node[
"link_from"];
83 config.
linkFrom = linkFromNode.as<std::string>();
86 auto withQueueNode = node[
"with_queue"];
88 config.
withQueue = withQueueNode.as<std::string>();
91 if (node[
"custom_lib_path"]) {
92 config.
customLibPath = node[
"custom_lib_path"].as<std::string>();
96 if (node[
"custom_create_function"]) {
100 "custom_create_function not found in config");
103 auto bodyNode = node[
"config_body"];
106 if (!bodyNode[
"config_path"] && !path.empty()) {
107 bodyNode[
"config_path"] = path;
113 "config_body error in config, yaml error: " + body.GetLastError());
117 YAML::Emitter yRawContent;
125 const std::string& yamlDoc,
const std::string& path, std::vector<ComponentConfig>& all)
127 auto nodes = YAML::LoadAll(yamlDoc);
128 for (
const auto& doc : nodes) {
132 YAML::Emitter content;
136 "component error in config, yaml error: " + content.GetLastError());
140 "parsing a component failed in config");
141 all.push_back(config);
148 #endif // DS3D_COMMON_HPP_YAML_CONFIG_HPP