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.
25 lines
816 B
C++
25 lines
816 B
C++
#pragma once
|
|
#include "ifaces/ILink.h"
|
|
#include "ifaces/INode.h"
|
|
#include <algorithm>
|
|
|
|
class BaseLink : public ILink {
|
|
public:
|
|
explicit BaseLink(NodePtr node) : owner_node_(node) {}
|
|
NodePtr getNode() const override { return owner_node_.lock(); }
|
|
NodePtr getParent() const override { return parent_.lock(); }
|
|
void setParent(const NodePtr& parent) override { parent_ = parent; }
|
|
const std::vector<NodePtr>& getChildren() const override { return children_; }
|
|
void removeChild(const NodePtr& 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<NodePtr> children_;
|
|
std::weak_ptr<INode> owner_node_;
|
|
std::weak_ptr<INode> parent_;
|
|
};
|