tmp
parent
3801a5dc0b
commit
f5f78308bd
@ -0,0 +1,3 @@
|
|||||||
|
*.swp
|
||||||
|
build
|
||||||
|
.vscode
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "mixins/LazyLinkMixin.h"
|
||||||
|
#include "ifaces/INode.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
class BaseNode : public INode,
|
||||||
|
public LazyLinkMixin<OneToManyLink>,
|
||||||
|
public std::enable_shared_from_this<BaseNode> {
|
||||||
|
public:
|
||||||
|
BaseNode(std::string name) : name_(std::move(name)) {}
|
||||||
|
const std::string& name() const override { return name_; }
|
||||||
|
~BaseNode() {
|
||||||
|
std::cout << "--- Destructor called for: " << name_ << "\n";
|
||||||
|
}
|
||||||
|
protected:
|
||||||
|
NodePtr getShared() override {
|
||||||
|
return shared_from_this();
|
||||||
|
}
|
||||||
|
std::string name_;
|
||||||
|
};
|
||||||
@ -1,26 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "mixins/LazyLinkMixin.h"
|
#include "nodes/BaseNode.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
class SimpleNode : public LazyLinkMixin<SimpleNode>,
|
class SimpleNode :
|
||||||
public std::enable_shared_from_this<SimpleNode> {
|
public BaseNode {
|
||||||
public:
|
public:
|
||||||
static NodePtr create(std::string name) {
|
~SimpleNode() {
|
||||||
struct EnableMakeShared : public SimpleNode {
|
std::cout << "--- Destructor called for: " << name_ << "\n";
|
||||||
EnableMakeShared(std::string n) : SimpleNode(std::move(n)) {}
|
}
|
||||||
};
|
SimpleNode(std::string name) : BaseNode(std::move(name)) {}
|
||||||
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();
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
friend class LazyLinkMixin<SimpleNode>;
|
|
||||||
explicit SimpleNode(std::string name) : name_(std::move(name)) {}
|
|
||||||
std::string name_;
|
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue