make nodes to provide nodes instead of mixins

This commit is contained in:
Сергей Маринкевич
2025-07-25 15:02:15 +07:00
parent c228caaa45
commit e5dc6f7502
11 changed files with 76 additions and 70 deletions
+9 -7
View File
@@ -6,12 +6,14 @@
template <class TElem>
class ILink {
public:
using ElemPtr = std::shared_ptr<TElem>;
virtual ~ILink() = default;
virtual std::shared_ptr<TElem> getNode() const = 0;
virtual std::shared_ptr<TElem> getParent() const = 0;
virtual void setParent(const std::shared_ptr<TElem>& parent) = 0;
virtual const std::vector<std::shared_ptr<TElem>>& getChildren() const = 0;
virtual void addChild(const std::shared_ptr<TElem>& child) = 0;
virtual void removeChild(const std::shared_ptr<TElem>& child) = 0;
virtual void replaceChild(const std::shared_ptr<TElem>& oldChild, const std::shared_ptr<TElem>& newChild) = 0;
virtual ElemPtr getNode() const = 0;
virtual ElemPtr getParent() const = 0;
virtual void setParent(const ElemPtr& parent) = 0;
virtual const std::vector<ElemPtr>& getChildren() const = 0;
virtual void addChild(const ElemPtr& child) = 0;
virtual void removeChild(const ElemPtr& child) = 0;
virtual void replaceChild(const ElemPtr& oldChild, const ElemPtr& newChild) = 0;
};
+6 -6
View File
@@ -2,15 +2,15 @@
#include <memory>
#include "ifaces/ILink.h"
class ILinkMixin;
using MixinPtr = std::shared_ptr<ILinkMixin>;
using LinkPtr = std::shared_ptr<ILink<ILinkMixin>>;
template <class TElem>
class ILinkMixin {
public:
using LinkPtr = std::shared_ptr<ILink<TElem>>;
using ElemPtr = std::shared_ptr<TElem>;
virtual ~ILinkMixin() = default;
virtual void linkChild(const MixinPtr& child) = 0;
virtual void linkChild(const ElemPtr& child) = 0;
virtual void unlinkParent() = 0;
virtual const std::vector<ElemPtr>& children() = 0;
virtual LinkPtr getLink() = 0;
};
+1 -1
View File
@@ -6,7 +6,7 @@ class INode;
using NodePtr = std::shared_ptr<INode>;
class INode : public virtual ILinkMixin {
class INode : public virtual ILinkMixin<INode> {
public:
~INode() = default;
virtual const std::string& name() const = 0;