Summary
Extract common YAML parsing helpers to a shared utility header to reduce code duplication and improve consistency.
Currently we have YAML parsing helpers in two places:
- correlation/config_parser.cpp - get_string(), get_bool(), get_uint32(), get_double()
- fault_manager_node.cpp - raw YAML::Node access for snapshot config
Proposed solution (optional)
Create include/ros2_medkit_fault_manager/yaml_utils.hpp with:
namespace ros2_medkit_fault_manager::yaml_utils {
std::string get_string(const YAML::Node&, const std::string& key, const std::string& default_value = "");
bool get_bool(const YAML::Node&, const std::string& key, bool default_value = false);
uint32_t get_uint32(const YAML::Node&, const std::string& key, uint32_t default_value = 0);
double get_double(const YAML::Node&, const std::string& key, double default_value = 0.0);
}
Then refactor:
- config_parser.cpp - use shared utils
- fault_manager_node.cpp (load_snapshot_config_from_yaml) - use shared utils
Additional context (optional)
Originated from code review discussion: #121 (comment)