add hierarchical node
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
#include "links/BaseLink.h"
|
||||
#include <stdexcept>
|
||||
|
||||
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 {
|
||||
if (!this->children_.empty())
|
||||
throw std::logic_error("OneToOneLink cannot have more than one child");
|
||||
BaseLink<TElem>::addChild(child);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user