shared children disappear

This commit is contained in:
Сергей Маринкевич
2025-07-21 19:28:17 +07:00
parent b2be9b51ca
commit 44480a7128
5 changed files with 43 additions and 222 deletions
+4
View File
@@ -13,6 +13,10 @@ public:
void removeChild(const LinkPtr& child) override {
children_.erase(std::remove(children_.begin(), children_.end(), child), children_.end());
}
~BaseLink() override {
std::cout << "--- Destructor called for: " << "BaseLink" << "\n";
}
protected:
std::vector<LinkPtr> children_;
std::weak_ptr<INode> owner_node_;
+5
View File
@@ -1,4 +1,5 @@
#pragma once
#include <iostream>
#include "ifaces/INode.h"
#include "links/LeafLink.h"
#include "links/OneToManyLink.h"
@@ -28,6 +29,10 @@ public:
return link_;
}
~LazyLinkMixin() override {
std::cout << "--- Destructor called for: " << "LazyLinkMixin" << "\n";
}
protected:
virtual std::shared_ptr<TFinalNode> getShared() = 0;
NodePtr getSelf() override { return getShared(); }
+4
View File
@@ -1,5 +1,6 @@
#pragma once
#include "mixins/LazyLinkMixin.h"
#include <iostream>
class SimpleNode : public LazyLinkMixin<SimpleNode>,
public std::enable_shared_from_this<SimpleNode> {
@@ -11,6 +12,9 @@ public:
return std::make_shared<EnableMakeShared>(std::move(name));
}
const std::string& name() const override { return name_; }
~SimpleNode() {
std::cout << "--- Destructor called for: " << name_ << "\n";
}
protected:
std::shared_ptr<SimpleNode> getShared() override {
return shared_from_this();