From 57d8978b92f0f570e07716f7caf0211090e5f91c Mon Sep 17 00:00:00 2001 From: Chi Huu Huynh <73843190+Chi-EEE@users.noreply.github.com> Date: Fri, 15 Dec 2023 11:43:56 +0000 Subject: [PATCH] Refactor code --- app/backend/src/room/RoomManager.hpp | 2 +- app/backend/src/room/User.hpp | 6 +++--- app/raspberry_pi/src/car/system/CarSystem.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/backend/src/room/RoomManager.hpp b/app/backend/src/room/RoomManager.hpp index 043144cd..59ef14b6 100644 --- a/app/backend/src/room/RoomManager.hpp +++ b/app/backend/src/room/RoomManager.hpp @@ -27,7 +27,7 @@ class RoomManager { this->rooms.erase(name); } - std::map> getRooms() { + std::map> getRooms() const { return this->rooms; } diff --git a/app/backend/src/room/User.hpp b/app/backend/src/room/User.hpp index a6c7788d..0822e96c 100644 --- a/app/backend/src/room/User.hpp +++ b/app/backend/src/room/User.hpp @@ -11,20 +11,20 @@ class User { public: - User(drogon::SubscriberID id, drogon::WebSocketConnectionPtr conn, const std::string chat_room_name, UserType type) : id(id), connection(conn), chat_room_name(chat_room_name), type(type) {}; + User(drogon::SubscriberID id, drogon::WebSocketConnectionPtr conn, const std::string chat_room_name, UserType type) : id(id), connection(conn), chat_room_name(chat_room_name), type(type){}; UserType getType() const { return this->type; } std::string getChatRoomName() const { return this->chat_room_name; } drogon::SubscriberID getId() const { return this->id; } - void setName(const std::string name) { this->name = name; } + void setName(const std::string &name) { this->name = name; } std::string getName() const { return this->name; } const drogon::WebSocketConnectionPtr getConnection() const { return this->connection; } private: - const UserType type; const std::string chat_room_name; + const UserType type; const drogon::SubscriberID id; const drogon::WebSocketConnectionPtr connection; diff --git a/app/raspberry_pi/src/car/system/CarSystem.cpp b/app/raspberry_pi/src/car/system/CarSystem.cpp index 0fde5ee5..c637779b 100644 --- a/app/raspberry_pi/src/car/system/CarSystem.cpp +++ b/app/raspberry_pi/src/car/system/CarSystem.cpp @@ -15,11 +15,11 @@ namespace car::system { this->messaging_system->initalize(); this->lidar_device->initialize(); - this->messaging_system->move_command_signal.connect([this](MoveCommand move_command) { + this->messaging_system->move_command_signal.connect([this](const MoveCommand move_command) { this->move(move_command); }); - this->messaging_system->turn_command_signal.connect([this](TurnCommand turn_command) { + this->messaging_system->turn_command_signal.connect([this](const TurnCommand turn_command) { this->turn(turn_command); }); }