#pragma once #include #include #include "ifaces/ILink.h" #include "Logger.h" template class BaseLink : public ILink { public: BaseLink(std::shared_ptr node) : owner_node_(node) {} std::shared_ptr getNode() const override { return owner_node_.lock(); } std::shared_ptr getParent() const override { return parent_.lock(); } void setParent(const std::shared_ptr& parent) override { parent_ = parent; } const std::vector>& getChildren() const override { return children_; } void addChild(const std::shared_ptr& child) override { this->children_.push_back(child); } void removeChild(const std::shared_ptr& child) override { children_.erase(std::remove(children_.begin(), children_.end(), child), children_.end()); } void replaceChild(const std::shared_ptr& oldChild, const std::shared_ptr& newChild) override { auto it = std::find(children_.begin(), children_.end(), oldChild); if (it != children_.end()) { *it = newChild; } } ~BaseLink() override { Logger::get("Link").dbg("--- Destructor called for: BaseLink"); } protected: std::vector> children_; std::weak_ptr owner_node_; std::weak_ptr parent_; };