Skip to content

Commit ac8b0ea

Browse files
committed
adhere to coding style
Signed-off-by: Mohamed Abdelaziz <[email protected]>
1 parent 6c81d4b commit ac8b0ea

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

greenwave_monitor/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ ament_target_dependencies(greenwave_monitor
3939
yaml_cpp_vendor
4040
)
4141
target_link_libraries(greenwave_monitor
42-
message_diagnostics
43-
yaml-cpp
42+
message_diagnostics
43+
yaml-cpp
4444
)
4545

4646
target_include_directories(greenwave_monitor PUBLIC

greenwave_monitor/include/greenwave_monitor.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class GreenwaveMonitor : public rclcpp::Node
6969
GetTimestampFromSerializedMessage(
7070
std::shared_ptr<rclcpp::SerializedMessage> serialized_message_ptr,
7171
const std::string & type);
72-
72+
7373
std::string type_registry_path_;
7474
std::map<std::string,
7575
std::unique_ptr<message_diagnostics::MessageDiagnostics>> message_diagnostics_;

greenwave_monitor/src/greenwave_monitor.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,25 @@
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

2929
using 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

Comments
 (0)