add hierarchical node
This commit is contained in:
@@ -5,5 +5,10 @@ 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 { this->children_.push_back(child); }
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user