1717
1818#include " greenwave_monitor.hpp"
1919
20+ #include < sys/stat.h>
21+ #include < yaml-cpp/yaml.h>
2022#include < algorithm>
2123#include < cstring>
2224#include < mutex>
23- #include < sys/stat.h>
2425#include < unordered_map>
25- #include < yaml-cpp/yaml.h>
2626
2727#include " rosidl_typesupport_introspection_cpp/message_introspection.hpp"
2828
2929using namespace std ::chrono_literals;
3030
31- namespace {
31+ namespace
32+ {
3233
3334// Check if a file exists and is a regular file
34- bool is_valid_file (const std::string& path) {
35+ bool is_valid_file (const std::string & path)
36+ {
3537 struct stat st;
36- if (stat (path.c_str (), &st) != 0 ) { return false ; }
38+ if (stat (path.c_str (), &st) != 0 ) {return false ;}
3739 return static_cast <bool >(st.st_mode & S_IFREG);
3840}
3941
@@ -286,13 +288,14 @@ bool GreenwaveMonitor::has_header_from_type(const std::string & type_name)
286288 return has_header;
287289}
288290
289- bool GreenwaveMonitor::has_header_from_type_registry (const std::string & type_name) {
291+ bool GreenwaveMonitor::has_header_from_type_registry (const std::string & type_name)
292+ {
290293 try {
291294 YAML::Node config = YAML::LoadFile (type_registry_path_);
292295 if (config[" has_header" ]) {
293296 // Check if 'has_header' is a sequence (list)
294297 if (config[" has_header" ].IsSequence ()) {
295- for (const auto & type_node : config[" has_header" ]) {
298+ for (const auto & type_node : config[" has_header" ]) {
296299 if (type_node.IsScalar ()) {
297300 // Check if the type matches
298301 if (type_node.as <std::string>() == type_name) {
@@ -315,11 +318,11 @@ bool GreenwaveMonitor::has_header_from_type_registry(const std::string & type_na
315318 this ->get_logger (),
316319 " 'has_header' key is not found in the YAML file." );
317320 }
318- } catch (const YAML::BadFile& e) {
321+ } catch (const YAML::BadFile & e) {
319322 RCLCPP_ERROR (this ->get_logger (), " Error reading YAML file: %s" , e.what ());
320- } catch (const YAML::ParserException& e) {
323+ } catch (const YAML::ParserException & e) {
321324 RCLCPP_ERROR (this ->get_logger (), " Error parsing YAML string: %s" , e.what ());
322- } catch (const std::exception& e) {
325+ } catch (const std::exception & e) {
323326 RCLCPP_ERROR (this ->get_logger (), " An unexpected error occurred: %s" , e.what ());
324327 }
325328 return false ;
0 commit comments