make nodes to provide nodes instead of mixins
This commit is contained in:
@@ -6,39 +6,35 @@
|
||||
#include "links/OneToOneLink.h"
|
||||
#include "Logger.h"
|
||||
|
||||
class HierarchicalLinkMixin : public LazyLinkMixin<OneToOneLink<ILinkMixin>> {
|
||||
public:
|
||||
HierarchicalLinkMixin() {}
|
||||
template <class TElem>
|
||||
class HierarchicalLinkMixin : public LazyLinkMixin<OneToOneLink<TElem>> {
|
||||
using LinkPtr = std::shared_ptr<ILink<TElem>>;
|
||||
using ElemPtr = std::shared_ptr<TElem>;
|
||||
|
||||
public:
|
||||
~HierarchicalLinkMixin() override {
|
||||
Logger::get("Mixin").dbg("--- Destructor called for: HierarchicalLinkMixin");
|
||||
}
|
||||
|
||||
void linkChild(const MixinPtr& child) override {
|
||||
void linkChild(const ElemPtr& child) override {
|
||||
hierarchicalInit(child);
|
||||
LazyLinkMixin<OneToOneLink<ILinkMixin>>::linkChild(child);
|
||||
LazyLinkMixin<OneToOneLink<TElem>>::linkChild(child);
|
||||
}
|
||||
|
||||
protected:
|
||||
void hierarchicalInit(const MixinPtr& child) {
|
||||
void hierarchicalInit(const ElemPtr& child) {
|
||||
Logger::get("Mixin").dbg("--- hierarchicalInit called");
|
||||
if (this->link_ && !this->link_->getChildren().empty())
|
||||
return; // already have children, do nothing
|
||||
|
||||
|
||||
/* 1. Have no link_ —
|
||||
* 2. Has OneToOne with parent or not
|
||||
* 3. Has OneToOne with child
|
||||
*/
|
||||
return;
|
||||
|
||||
LinkPtr newLink;
|
||||
|
||||
if (typeid(*child) == typeid(*this)) {
|
||||
Logger::get("Mixin").dbg("--- Mutate to OneToMany");
|
||||
newLink = std::make_shared<OneToManyLink<ILinkMixin>>(this->getNode());
|
||||
newLink = std::make_shared<OneToManyLink<TElem>>(this->getNode());
|
||||
} else {
|
||||
Logger::get("Mixin").dbg("--- Mutate to OneToOne");
|
||||
newLink = std::make_shared<OneToOneLink<ILinkMixin>>(this->getNode());
|
||||
newLink = std::make_shared<OneToOneLink<TElem>>(this->getNode());
|
||||
}
|
||||
|
||||
if (newLink && this->link_)
|
||||
|
||||
Reference in New Issue
Block a user