From 6ad0230b50be3e867e4ea1a1e33fd30c7487ec4a Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 13 Oct 2022 20:34:25 +0100 Subject: Standard typedefs for Link --- game/network/link.h | 9 ++------- game/network/network.cpp | 2 +- game/network/network.h | 18 +++++++++--------- game/network/network.impl.h | 8 ++++---- 4 files changed, 16 insertions(+), 21 deletions(-) (limited to 'game/network') diff --git a/game/network/link.h b/game/network/link.h index 2beb808..1f6b780 100644 --- a/game/network/link.h +++ b/game/network/link.h @@ -28,13 +28,9 @@ public: // Generic network link // something that can be travelled along // it joins 2 nodes -class Link; -using LinkPtr = std::shared_ptr; -using LinkCPtr = std::shared_ptr; -using LinkWPtr = std::weak_ptr; -class Link { +class Link : public StdTypeDefs { public: - using Next = std::pair; + using Next = std::pair; using Nexts = std::vector; struct End { @@ -61,7 +57,6 @@ protected: return {}; } }; -using CLinks = std::vector; bool operator<(const glm::vec3 & a, const glm::vec3 & b); bool operator<(const Node & a, const Node & b); diff --git a/game/network/network.cpp b/game/network/network.cpp index 25dc384..d78f672 100644 --- a/game/network/network.cpp +++ b/game/network/network.cpp @@ -63,7 +63,7 @@ Network::intersectRayNodes(const Ray & ray) const } void -Network::joinLinks(const LinkPtr & l, const LinkPtr & ol) +Network::joinLinks(const Link::Ptr & l, const Link::Ptr & ol) { if (l != ol) { for (const auto oe : {0U, 1U}) { diff --git a/game/network/network.h b/game/network/network.h index 4ef6a4f..60d9a02 100644 --- a/game/network/network.h +++ b/game/network/network.h @@ -17,7 +17,7 @@ class Ray; class Network { public: - using LinkEnd = std::pair; + using LinkEnd = std::pair; explicit Network(const std::string & textureName); virtual ~Network() = default; @@ -25,17 +25,17 @@ public: [[nodiscard]] Node::Ptr nodeAt(glm::vec3); [[nodiscard]] std::pair newNodeAt(glm::vec3); [[nodiscard]] std::pair candidateNodeAt(glm::vec3) const; - [[nodiscard]] virtual LinkPtr intersectRayLinks(const Ray &) const = 0; + [[nodiscard]] virtual Link::Ptr intersectRayLinks(const Ray &) const = 0; [[nodiscard]] virtual Node::Ptr intersectRayNodes(const Ray &) const; [[nodiscard]] Link::Nexts routeFromTo(const Link::End &, glm::vec3) const; [[nodiscard]] Link::Nexts routeFromTo(const Link::End &, const Node::Ptr &) const; - virtual LinkCPtr addStraight(glm::vec3, glm::vec3) = 0; - virtual CLinks addJoins(glm::vec3, glm::vec3) = 0; + virtual Link::CPtr addStraight(glm::vec3, glm::vec3) = 0; + virtual Link::CCollection addJoins(glm::vec3, glm::vec3) = 0; protected: - static void joinLinks(const LinkPtr & l, const LinkPtr & ol); + static void joinLinks(const Link::Ptr & l, const Link::Ptr & ol); using Nodes = std::set>; Nodes nodes; @@ -47,10 +47,10 @@ protected: using Network::Network; Collection links; - void joinLinks(const LinkPtr &) const; + void joinLinks(const Link::Ptr &) const; protected: - [[nodiscard]] LinkPtr intersectRayLinks(const Ray &) const override; + [[nodiscard]] Link::Ptr intersectRayLinks(const Ray &) const override; public: template @@ -64,8 +64,8 @@ public: return l; } - LinkCPtr addStraight(glm::vec3 n1, glm::vec3 n2) override; - CLinks addJoins(glm::vec3, glm::vec3) override; + Link::CPtr addStraight(glm::vec3 n1, glm::vec3 n2) override; + Link::CCollection addJoins(glm::vec3, glm::vec3) override; void render(const Shader &) const override; }; diff --git a/game/network/network.impl.h b/game/network/network.impl.h index 4e2b37e..68da5d9 100644 --- a/game/network/network.impl.h +++ b/game/network/network.impl.h @@ -15,7 +15,7 @@ NetworkOf::render(const Shader & shader) const template void -NetworkOf::joinLinks(const LinkPtr & l) const +NetworkOf::joinLinks(const Link::Ptr & l) const { for (const auto & ol : links.objects) { Network::joinLinks(l, ol); @@ -23,7 +23,7 @@ NetworkOf::joinLinks(const LinkPtr & l) const } template -LinkPtr +Link::Ptr NetworkOf::intersectRayLinks(const Ray & ray) const { // Click link @@ -38,14 +38,14 @@ NetworkOf::intersectRayLinks(const Ray & ray) const } template -LinkCPtr +Link::CPtr NetworkOf::addStraight(glm::vec3 n1, glm::vec3 n2) { return addLink(n1, n2); } template -CLinks +Link::CCollection NetworkOf::addJoins(glm::vec3 n1, glm::vec3 n2) { return {addLink(n1, n2)}; -- cgit v1.2.3