From ae516c00f24000c83cee319a8bf12b3464e033fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20=C5=A0toura=C4=8D?= <525032@mail.muni.cz> Date: Fri, 17 May 2024 10:01:22 +0200 Subject: [PATCH] remove enum class from parameter definitions --- src/rofi/include/rofi/connector.hpp | 18 +++++++------- src/rofi/include/rofi/voxel.hpp | 36 +++++++++++++-------------- src/rofi/include/rofi/voxel_graph.hpp | 8 +++--- src/rofi/src/connector.cpp | 4 +-- src/rofi/src/voxel_graph.cpp | 6 ++--- 5 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/rofi/include/rofi/connector.hpp b/src/rofi/include/rofi/connector.hpp index c9308c5..84dc476 100644 --- a/src/rofi/include/rofi/connector.hpp +++ b/src/rofi/include/rofi/connector.hpp @@ -29,11 +29,11 @@ class Connector : public ObjectBase friend class VoxelGraph; protected: std::pair<voxel_weak_ptr, voxel_weak_ptr> connection = std::pair(voxel_weak_ptr(), voxel_weak_ptr()); - std::pair<enum class side, enum class side> voxel_side = std::pair(side::undefined, side::undefined); + std::pair<side, side> voxel_side = std::pair(side::undefined, side::undefined); - virtual void connectVoxel(enum class side s, voxel_weak_ptr voxel); + virtual void connectVoxel(side s, voxel_weak_ptr voxel); virtual void disconnectVoxel(voxel_weak_ptr voxel); - virtual void disconnectVoxel(enum class side s); + virtual void disconnectVoxel(side s); Connector(const Connector &other); Connector(const Connector &&other); @@ -58,9 +58,9 @@ public: node_ptr getNode() { return node; } voxel_weak_ptr getOppositeConnection(); - voxel_weak_ptr getOppositeConnection(enum class side s); + voxel_weak_ptr getOppositeConnection(side s); const std::pair<voxel_weak_ptr, voxel_weak_ptr> &getConnection() { return connection; } - const std::pair<enum class side, enum class side> &getVoxelSide() { return voxel_side; } + const std::pair<side, side> &getVoxelSide() { return voxel_side; } voxel_weak_ptr getModuleLink() const; virtual const connector_type getType(voxel_weak_ptr) const = 0; @@ -113,7 +113,7 @@ class RotationConnector : public Connector bool is_head; std::pair<connector_weak_ptr, connector_weak_ptr> bound_connectors = std::pair(connector_weak_ptr(), connector_weak_ptr()); - enum class connector_type semantic_type = connector_type::empty; + connector_type semantic_type = connector_type::empty; float neg_rotation_limit = -90.0f; float pos_rotation_limit = 90.0f; float current_rotation = 0.0f; @@ -133,7 +133,7 @@ public: static std::shared_ptr<RotationConnector> copy(std::shared_ptr<RotationConnector> other_rotation_connector); - const enum class connector_type getType(voxel_weak_ptr from_voxel) const override + const connector_type getType(voxel_weak_ptr from_voxel) const override { if (connection.first.expired()) return connector_type::rotation; @@ -202,8 +202,8 @@ public: void setRotationAxis(glm::vec3 _rotation_axis) { rotation_axis = _rotation_axis; } }; -enum class side vec_to_enum(glm::vec3 local_direction); -glm::vec3 enum_to_vec(enum class side s); +side vec_to_enum(glm::vec3 local_direction); +glm::vec3 enum_to_vec(side s); cardinal degree_to_cardinal(float degree_angle); float cardinal_to_degree(cardinal orientation); diff --git a/src/rofi/include/rofi/voxel.hpp b/src/rofi/include/rofi/voxel.hpp index 04d66dc..b9106be 100644 --- a/src/rofi/include/rofi/voxel.hpp +++ b/src/rofi/include/rofi/voxel.hpp @@ -12,7 +12,7 @@ namespace rofi { class Connector; -enum class side vec_to_enum(glm::vec3 local_direction); +side vec_to_enum(glm::vec3 local_direction); using connector_weak_ptr = std::weak_ptr<Connector>; @@ -22,7 +22,7 @@ using voxel_ptr = std::shared_ptr<Voxel>; class Voxel : public ObjectBase { using enum connector_type; - std::map<const enum class side, std::map<const enum class rofi::connector_type, bool>> slots = { + std::map<const side, std::map<const rofi::connector_type, bool>> slots = { {side::x_pos, {{fixed, true}, {open, true}, {rotation, true}, {shared_rotation, true}}}, {side::x_neg, {{fixed, true}, {open, true}, {rotation, true}, {shared_rotation, true}}}, {side::y_pos, {{fixed, true}, {open, true}, {rotation, true}, {shared_rotation, true}}}, @@ -33,21 +33,21 @@ class Voxel : public ObjectBase protected: node_ptr node; - std::map<enum class side, connector_weak_ptr> connections; + std::map<side, connector_weak_ptr> connections; friend class VoxelGraph; - void connectConnection(enum class side s, connector_weak_ptr connector); - void disconnectConnection(enum class side s); + void connectConnection(side s, connector_weak_ptr connector); + void disconnectConnection(side s); void disconnectConnection(connector_weak_ptr connector); - const std::map<enum class side, connector_weak_ptr> &getConnections() { return connections; } + const std::map<side, connector_weak_ptr> &getConnections() { return connections; } - void restrictSlotsRotation(const enum class side s, connector_weak_ptr connector); - void restrictSlotsSharedRotation(const enum class side s); + void restrictSlotsRotation(const side s, connector_weak_ptr connector); + void restrictSlotsSharedRotation(const side s); - void releaseSlotsRotation(const enum class side s, connector_weak_ptr connector); - void releaseSlotsSharedRotation(const enum class side s); + void releaseSlotsRotation(const side s, connector_weak_ptr connector); + void releaseSlotsSharedRotation(const side s); Voxel(const Voxel &other); Voxel(const Voxel &&other); @@ -64,36 +64,36 @@ public: virtual ~Voxel() = default; node_ptr getNode() const { return node; } - bool isConnectedAt(enum class side s) const { return connections.contains(s); } + bool isConnectedAt(side s) const { return connections.contains(s); } bool isConnectedAt(glm::vec3 side_direction) const { return isConnectedAt(vec_to_enum(side_direction)); } side getSideWithConnector(connector_weak_ptr connector) const; - connector_weak_ptr getConnectorAt(enum class side s) const; + connector_weak_ptr getConnectorAt(side s) const; connector_weak_ptr getConnectorAt(glm::vec3 side_direction) const { return getConnectorAt(vec_to_enum(side_direction)); }; connector_weak_ptr getOppositeConnector(connector_weak_ptr connector) const; connector_weak_ptr getSharedConnector() const; connector_weak_ptr getRotationConnector() const; - voxel_weak_ptr getVoxelAt(enum class side s) const; + voxel_weak_ptr getVoxelAt(side s) const; voxel_weak_ptr getVoxelAt(glm::vec3 side_direction) const { return getVoxelAt(vec_to_enum(side_direction)); } bool hasNoConnections() const { return connections.empty(); } bool hasSharedRotation() const; bool hasRotationConnector() const; - bool slotCompatible(const enum class side s, const connector_type type) const; + bool slotCompatible(const side s, const connector_type type) const; bool slotCompatible(const glm::vec3 side_direction, const connector_type type) const { return slotCompatible(vec_to_enum(side_direction), type); } - void restrictSlots(const enum class side s, connector_weak_ptr connector); - void releaseSlots(const enum class side s, connector_weak_ptr connector); + void restrictSlots(const side s, connector_weak_ptr connector); + void releaseSlots(const side s, connector_weak_ptr connector); }; class ModuleLink : public Voxel { using enum connector_type; - std::map<const enum class side, std::map<const enum class rofi::connector_type, bool>> slots = { + std::map<const side, std::map<const rofi::connector_type, bool>> slots = { {side::x_pos, {{fixed, false}, {open, false}, {rotation, false}, {shared_rotation, false}}}, {side::x_neg, {{fixed, false}, {open, false}, {rotation, false}, {shared_rotation, false}}}, {side::y_pos, {{fixed, false}, {open, false}, {rotation, false}, {shared_rotation, false}}}, @@ -120,7 +120,7 @@ public: class PadBoard : public Voxel { using enum connector_type; - std::map<const enum class side, std::map<const enum class rofi::connector_type, bool>> slots = { + std::map<const side, std::map<const rofi::connector_type, bool>> slots = { {side::x_pos, {{fixed, false}, {open, false}, {rotation, false}, {shared_rotation, false}}}, {side::x_neg, {{fixed, false}, {open, false}, {rotation, false}, {shared_rotation, false}}}, {side::y_pos, {{fixed, false}, {open, true}, {rotation, false}, {shared_rotation, false}}}, diff --git a/src/rofi/include/rofi/voxel_graph.hpp b/src/rofi/include/rofi/voxel_graph.hpp index bde705b..6eaa86a 100644 --- a/src/rofi/include/rofi/voxel_graph.hpp +++ b/src/rofi/include/rofi/voxel_graph.hpp @@ -56,9 +56,9 @@ public: voxel_ptr addVoxel(node_ptr node); voxel_ptr addModuleLink(node_ptr node); voxel_ptr addPadBoard(node_ptr node); - connector_ptr addConnector(node_ptr node, enum class connector_type t); - connector_ptr addConnector(node_ptr node, enum class connector_type t, glm::vec3 rotation_axis); - connector_ptr addConnector(node_ptr node, enum class connector_type t, glm::vec3 rotation_axis, glm::vec3 highlight_direction); + connector_ptr addConnector(node_ptr node, connector_type t); + connector_ptr addConnector(node_ptr node, connector_type t, glm::vec3 rotation_axis); + connector_ptr addConnector(node_ptr node, connector_type t, glm::vec3 rotation_axis, glm::vec3 highlight_direction); void removeVoxel(voxel_ptr voxel); void removeConnector(connector_ptr connector); @@ -86,7 +86,7 @@ public: }; // NOTE: now only by position, no rotation taken into account -enum class side in_proximity(connector_ptr connector, voxel_ptr voxel); +side in_proximity(connector_ptr connector, voxel_ptr voxel); } diff --git a/src/rofi/src/connector.cpp b/src/rofi/src/connector.cpp index 7327354..cf6d6c3 100644 --- a/src/rofi/src/connector.cpp +++ b/src/rofi/src/connector.cpp @@ -127,7 +127,7 @@ voxel_weak_ptr Connector::getModuleLink() const return connection.first; } -void Connector::connectVoxel(enum class side s, voxel_weak_ptr voxel) +void Connector::connectVoxel(side s, voxel_weak_ptr voxel) { ASSUMPTION(!isFull()); @@ -355,7 +355,7 @@ std::shared_ptr<SharedRotationConnector> SharedRotationConnector::copy(std::shar return std::shared_ptr<SharedRotationConnector>{ new SharedRotationConnector(*other_shared_rotation_connector) }; } -enum class side vec_to_enum(glm::vec3 local_direction) +side vec_to_enum(glm::vec3 local_direction) { using enum side; float epsilon = 0.0001f; diff --git a/src/rofi/src/voxel_graph.cpp b/src/rofi/src/voxel_graph.cpp index 284a9f1..b024b27 100644 --- a/src/rofi/src/voxel_graph.cpp +++ b/src/rofi/src/voxel_graph.cpp @@ -256,7 +256,7 @@ connector_ptr VoxelGraph::addConnector(node_ptr node, connector_type t) return connections.back(); } -connector_ptr VoxelGraph::addConnector(node_ptr node, enum class connector_type t, glm::vec3 rotation_axis) +connector_ptr VoxelGraph::addConnector(node_ptr node, connector_type t, glm::vec3 rotation_axis) { using enum connector_type; ASSUMPTION(t == shared_rotation); @@ -266,7 +266,7 @@ connector_ptr VoxelGraph::addConnector(node_ptr node, enum class connector_type return connections.back(); } -connector_ptr VoxelGraph::addConnector(node_ptr node, enum class connector_type t, glm::vec3 rotation_axis, glm::vec3 highlight_direction) +connector_ptr VoxelGraph::addConnector(node_ptr node, connector_type t, glm::vec3 rotation_axis, glm::vec3 highlight_direction) { using enum connector_type; ASSUMPTION(t == rotation); @@ -503,7 +503,7 @@ void VoxelGraph::joinImplicit() } } -enum class side in_proximity(connector_ptr connector, voxel_ptr voxel) +side in_proximity(connector_ptr connector, voxel_ptr voxel) { // TO DO: adjust for rotations auto con_position = connector->getNode()->getPositionWorld(); -- GitLab