You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
871 B
C++
27 lines
871 B
C++
#pragma once
|
|
#include "mixins/LazyLinkMixin.h"
|
|
#include <iostream>
|
|
|
|
class SimpleNode : public LazyLinkMixin<SimpleNode>,
|
|
public std::enable_shared_from_this<SimpleNode> {
|
|
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_;
|
|
};
|