qosd: добавлены базовые дисциплины Complex QoS ESR
А именно: + [B|P]FIFO; + HTB; + RED; + WRED (a.k.a. `gred` в Linux/TC и нашем CLI); + SFQ. Два замечания: 1. Вместо GRED и RED теперь WRED и RED: RED — как был, так и есть, а WRED — специальный узел, который несёт глобальные настройки GRED, но параметры RED на VQ задаются через подключение дочерних узлов RED. 2. Параметры RED для SFQ также были оптимизированы: в узле SFQ их не будет, но зато к SFQ можно подключить один дочерний узел. Если подключить туда RED, то настройки RED будут применяться для per-flow RED дисциплины SFQ.
This commit is contained in:
@@ -3,9 +3,10 @@
|
||||
#include <stdexcept>
|
||||
|
||||
/// \brief Связь для листового узла, не допускающая дочерних элементов.
|
||||
class LeafLink : public BaseLink {
|
||||
template <class TElem>
|
||||
class LeafLink : public BaseLink<TElem> {
|
||||
public:
|
||||
using BaseLink::BaseLink;
|
||||
using BaseLink<TElem>::BaseLink;
|
||||
void addChild(const NodePtr&) override {
|
||||
throw std::logic_error("LeafLink cannot have children");
|
||||
}
|
||||
|
||||
@@ -1,17 +1,7 @@
|
||||
#pragma once
|
||||
#include "links/BaseLink.h"
|
||||
|
||||
/// \brief Связь "один-ко-многим" между элементами одного типа.
|
||||
/// Каждый дочерний элемент должен быть того же типа, что и родитель.
|
||||
/// \brief Связь "один-ко-многим" между элементами любого типа.
|
||||
/// \tparam TElem Тип элемента.
|
||||
template <class TElem>
|
||||
class OneToManyLink : public BaseLink<TElem> {
|
||||
public:
|
||||
OneToManyLink(std::shared_ptr<TElem> e) : BaseLink<TElem>(e) {}
|
||||
void addChild(const std::shared_ptr<TElem>& child) override {
|
||||
/* Each child must be exactly the same type as parent */
|
||||
if (typeid(*child) != typeid(*this->owner_node_.lock()))
|
||||
throw std::logic_error("Foundling child");
|
||||
BaseLink<TElem>::addChild(child);
|
||||
}
|
||||
};
|
||||
using OneToManyLink = BaseLink<TElem>;
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
#include <stdexcept>
|
||||
|
||||
/// \brief Обёртка для связей, чтобы сделать их типизированными.
|
||||
/// Типизированная связь позволяет подключать только узлы заданного типа.
|
||||
/// \tparam TElem Тип элемента.
|
||||
/// \tparam TBase Базовый Link. После проверки типа, управление передаётся этому классу.
|
||||
/// \tparam TExpected Опциональный ожидаемый конкретный тип детей.
|
||||
/// Если не задан, сравниваем с родителем.
|
||||
template <class TElem, class TBase, class TExpected = void>
|
||||
class TypedLink : public TBase {
|
||||
public:
|
||||
using ElemPtr = std::shared_ptr<TElem>;
|
||||
|
||||
TypedLink(ElemPtr e) : TBase(e) {}
|
||||
|
||||
void addChild(const ElemPtr& child) override {
|
||||
/* Validate type according to policy */
|
||||
if constexpr (std::is_void_v<TExpected>) {
|
||||
/* Default behavior: child must be exactly the same type as parent */
|
||||
if (typeid(*child) != typeid(*this->owner_node_.lock()))
|
||||
throw std::logic_error("Foundling child");
|
||||
} else {
|
||||
/* Explicit expected child type */
|
||||
if (typeid(*child) != typeid(TExpected))
|
||||
throw std::logic_error("Unexpected child type");
|
||||
}
|
||||
|
||||
TBase::addChild(child);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
#include "links/TypedLink.h"
|
||||
#include "links/OneToManyLink.h"
|
||||
#include <type_traits>
|
||||
#include <typeinfo>
|
||||
|
||||
/// \brief Связь "один-ко-многим" между элементами одного типа.
|
||||
/// Каждый дочерний элемент должен быть того же типа, что и родитель.
|
||||
/// \tparam TElem Тип элемента.
|
||||
/// \tparam TExpected Опциональный ожидаемый конкретный тип детей.
|
||||
template <class TElem, class TExpected = void>
|
||||
using TypedOneToManyLink = TypedLink<TElem, OneToManyLink<TElem>, TExpected>;
|
||||
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
#include "links/BaseLink.h"
|
||||
#include <stdexcept>
|
||||
|
||||
/// \brief Связь "один-к-одному" между элементами заданного типа.
|
||||
/// Позволяет добавить только одного дочернего элемента.
|
||||
/// \tparam TElem Тип элемента.
|
||||
/// \tparam TExpected Опциональный ожидаемый конкретный тип детей.
|
||||
/// Если не задан, сравниваем с родителем.
|
||||
template <class TElem, class TExpected = void>
|
||||
using TypedOneToOneLink = TypedLink<TElem, OneToOneLink<TElem>, TExpected>;
|
||||
Reference in New Issue
Block a user