qosd: сдавленные наброски по абстрактному дереву

This commit is contained in:
Сергей Маринкевич
2025-07-21 15:52:36 +07:00
commit 5df05f703a
20 changed files with 650 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
#pragma once
#include <memory>
#include <vector>
#include "ifaces/ILinkMixin.h"
/// \brief Интерфейс для классов-связей между элементами.
/// \tparam TElem Тип элемента, между которыми устанавливается связь.
template <class TElem>
class ILink {
public:
using ElemPtr = std::shared_ptr<TElem>;
virtual ~ILink() = default;
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;
};
+18
View File
@@ -0,0 +1,18 @@
#pragma once
#include <memory>
#include "ifaces/ILink.h"
/// \brief Интерфейс для классов, поддерживающих связь с дочерними элементами через ILink.
/// \tparam TElem Тип дочернего элемента.
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 ElemPtr& child) = 0;
virtual void unlinkParent() = 0;
virtual const std::vector<ElemPtr>& children() = 0;
virtual LinkPtr getLink() = 0;
};
+17
View File
@@ -0,0 +1,17 @@
#pragma once
#include "ifaces/ILinkMixin.h"
#include <string>
class INode;
/// \brief Умный указатель на INode.
using NodePtr = std::shared_ptr<INode>;
/// \brief Интерфейс для узлов дерева.
/// Определяет базовые методы для работы с именем и типом узла.
class INode : public virtual ILinkMixin<INode> {
public:
~INode() = default;
virtual const std::string& name() const = 0;
virtual const std::string& kind() const = 0;
};