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
+7 -3
View File
@@ -5,10 +5,14 @@
template <class TElem>
class OneToOneLink : public BaseLink<TElem> {
public:
OneToOneLink(std::shared_ptr<TElem> e) : BaseLink<TElem>(e) {}
void addChild(const std::shared_ptr<TElem>& child) override {
using ElemPtr = std::shared_ptr<TElem>;
OneToOneLink(ElemPtr e) : BaseLink<TElem>(e) {}
void addChild(const ElemPtr& child) override {
if (!this->children_.empty())
throw std::logic_error("OneToOneLink cannot have more than one child");
throw std::logic_error("Too many children");
BaseLink<TElem>::addChild(child);
}
};