unlink the links
This commit is contained in:
@@ -1,26 +1,23 @@
|
||||
#pragma once
|
||||
#include <iostream>
|
||||
#include "ifaces/INode.h"
|
||||
#include "ifaces/ILinkMixin.h"
|
||||
#include "links/LeafLink.h"
|
||||
#include "links/OneToManyLink.h"
|
||||
#include <memory>
|
||||
|
||||
#include "ifaces/ILinkMixin.h"
|
||||
|
||||
class BaseLinkMixin : public virtual ILinkMixin,
|
||||
public virtual INode,
|
||||
public std::enable_shared_from_this<INode> {
|
||||
public std::enable_shared_from_this<ILinkMixin> {
|
||||
public:
|
||||
void linkChild(const NodePtr& childNode) override {
|
||||
LinkPtr childLink = childNode->getLink();
|
||||
void linkChild(const MixinPtr& child) override {
|
||||
LinkPtr childLink = child->getLink();
|
||||
childLink->setParent(getNode());
|
||||
|
||||
getLink()->addChild(childNode);
|
||||
getLink()->addChild(child);
|
||||
}
|
||||
|
||||
void unlinkParent() override {
|
||||
LinkPtr link = getLink();
|
||||
|
||||
NodePtr parent = link->getParent();
|
||||
MixinPtr parent = link->getParent();
|
||||
if (!parent)
|
||||
throw std::logic_error("Have no parent!");
|
||||
|
||||
@@ -35,7 +32,7 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
NodePtr getNode() {
|
||||
MixinPtr getNode() {
|
||||
return shared_from_this();
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user