IAP GITLAB

Skip to content
Snippets Groups Projects
Commit f7de1b85 authored by Maximilian Reininghaus's avatar Maximilian Reininghaus :vulcan:
Browse files

added walk() to traverse the tree

parent bcc387b1
No related branches found
No related tags found
No related merge requests found
......@@ -66,6 +66,24 @@ namespace corsika::environment {
}
}
/**
* Traverses the VolumeTree pre- or post-order and calls the functor \p func for each
* node. \p func takes a reference to VolumeTreeNode as argument. The return value \p
* func is ignored.
*/
template <typename TCallable, bool preorder = true>
void walk(TCallable func) {
if constexpr (preorder) {
func(*this);
std::for_each(fChildNodes.begin(), fChildNodes.end(),
[&](auto& v) { v->walk(func); });
} else {
std::for_each(fChildNodes.begin(), fChildNodes.end(),
[&](auto& v) { v->walk(func); });
t(*this);
}
}
void AddChild(VTNUPtr pChild) {
pChild->fParentNode = this;
fChildNodes.push_back(std::move(pChild));
......@@ -88,6 +106,8 @@ namespace corsika::environment {
auto const& GetModelProperties() const { return *fModelProperties; }
IMPSharedPtr GetModelPropertiesPtr() const { return fModelProperties; }
template <typename TModelProperties, typename... Args>
auto SetModelProperties(Args&&... args) {
static_assert(std::is_base_of_v<IModelProperties, TModelProperties>,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment