From 2f7e112092864a24d935210e0e8c2d0e1f2225e4 Mon Sep 17 00:00:00 2001 From: dan-du-car Date: Tue, 13 Aug 2024 02:52:01 +0000 Subject: [PATCH] address code smell --- src/tmx/Messages/include/Position.h | 4 +- .../Messages/include/SensorDetectedObject.h | 4 +- src/tmx/Messages/include/Velocity.h | 49 +++++++++---------- 3 files changed, 28 insertions(+), 29 deletions(-) diff --git a/src/tmx/Messages/include/Position.h b/src/tmx/Messages/include/Position.h index 4dbaa651f..96fa2e2c8 100644 --- a/src/tmx/Messages/include/Position.h +++ b/src/tmx/Messages/include/Position.h @@ -4,7 +4,9 @@ namespace tmx::messages { // Cartesian positiion of object. Assumed to be ENU coordinate frame. typedef struct Position{ - double x, y, z; + double x; + double y; + double z; Position()=default; explicit Position(double x, double y, double z):x(x),y(y),z(z){}; static message_tree_type to_tree(const Position& pos){ diff --git a/src/tmx/Messages/include/SensorDetectedObject.h b/src/tmx/Messages/include/SensorDetectedObject.h index 4293e4ed8..4def40746 100644 --- a/src/tmx/Messages/include/SensorDetectedObject.h +++ b/src/tmx/Messages/include/SensorDetectedObject.h @@ -17,8 +17,8 @@ namespace tmx::messages class SensorDetectedObject : public tmx::message { public: - SensorDetectedObject(){}; - SensorDetectedObject(const tmx::message_container_type &contents) : tmx::message(contents) {}; + SensorDetectedObject()=default; + explicit SensorDetectedObject(const tmx::message_container_type &contents) : tmx::message(contents) {}; ~SensorDetectedObject() override{}; // Message type for routing this message through TMX core static constexpr const char *MessageType = MSGTYPE_APPLICATION_STRING; diff --git a/src/tmx/Messages/include/Velocity.h b/src/tmx/Messages/include/Velocity.h index df931c36d..8827f53a3 100644 --- a/src/tmx/Messages/include/Velocity.h +++ b/src/tmx/Messages/include/Velocity.h @@ -1,30 +1,27 @@ #pragma once #include -namespace tmx +namespace tmx::messages { - namespace messages - { - // Cartesian velocity vector of object. Assumed to be ENU coordinate frame. - typedef struct Velocity{ - double x; - double y; - double z; - Velocity()=default; - explicit Velocity(double x, double y, double z):x(x),y(y),z(z){}; - static message_tree_type to_tree(const Velocity& velocity){ - message_tree_type tree; - tree.put("x", velocity.x); - tree.put("y", velocity.y); - tree.put("z", velocity.z); - return tree; - } - static Velocity from_tree(const message_tree_type& tree){ - Velocity velocity; - velocity.x = tree.get("x"); - velocity.y = tree.get("y"); - velocity.z = tree.get("z"); - return velocity; - } - } Velocity; - } + // Cartesian velocity vector of object. Assumed to be ENU coordinate frame. + typedef struct Velocity{ + double x; + double y; + double z; + Velocity()=default; + explicit Velocity(double x, double y, double z):x(x),y(y),z(z){}; + static message_tree_type to_tree(const Velocity& velocity){ + message_tree_type tree; + tree.put("x", velocity.x); + tree.put("y", velocity.y); + tree.put("z", velocity.z); + return tree; + } + static Velocity from_tree(const message_tree_type& tree){ + Velocity velocity; + velocity.x = tree.get("x"); + velocity.y = tree.get("y"); + velocity.z = tree.get("z"); + return velocity; + } + } Velocity; } \ No newline at end of file