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
|
||||
#include "mixins/LazyLinkMixin.h"
|
||||
#include "nodes/BaseNode.h"
|
||||
#include <iostream>
|
||||
|
||||
class SimpleNode : public LazyLinkMixin<SimpleNode>,
|
||||
public std::enable_shared_from_this<SimpleNode> {
|
||||
class SimpleNode :
|
||||
public BaseNode {
|
||||
public:
|
||||
static NodePtr create(std::string name) {
|
||||
struct EnableMakeShared : public SimpleNode {
|
||||
EnableMakeShared(std::string n) : SimpleNode(std::move(n)) {}
|
||||
};
|
||||
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_;
|
||||
~SimpleNode() {
|
||||
std::cout << "--- Destructor called for: " << name_ << "\n";
|
||||
}
|
||||
SimpleNode(std::string name) : BaseNode(std::move(name)) {}
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue