#ifndef NETWORK_H #define NETWORK_H #include "link.h" #include #include #include #include #include #include #include #include class Texture; class Shader; class Network { public: explicit Network(const std::string & textureName); [[nodiscard]] NodePtr findNodeAt(glm::vec3) const; [[nodiscard]] NodePtr nodeAt(glm::vec3); [[nodiscard]] std::pair newNodeAt(glm::vec3); [[nodiscard]] Link::Nexts routeFromTo(const Link::End &, glm::vec3) const; [[nodiscard]] Link::Nexts routeFromTo(const Link::End &, const NodePtr &) const; protected: static void joinLinks(const LinkPtr & l, const LinkPtr & ol); using Nodes = std::set>; Nodes nodes; std::shared_ptr texture; }; template class NetworkOf : public Network, public Renderable { protected: using Network::Network; Collection links; void joinLinks(const LinkPtr &) const; public: template std::shared_ptr addLink(glm::vec3 a, glm::vec3 b, Params &&... params) requires std::is_base_of_v { const auto node1 = nodeAt(a), node2 = nodeAt(b); auto l {links.template create(node1, node2, std::forward(params)...)}; joinLinks(l); return l; } void render(const Shader &) const override; }; #endif