Refactored edge traversal diagram filter

This commit is contained in:
Bartek Kryza
2022-04-24 13:36:07 +02:00
parent 8ba5689662
commit b6390d9106
3 changed files with 119 additions and 129 deletions

View File

@@ -85,8 +85,9 @@ public:
return type_safe::optional_ref<V>{};
}
if (path.size() == 1)
if (path.size() == 1) {
return get_element<V>(path[0]);
}
auto p = get_element<T>(path[0]);
@@ -100,6 +101,18 @@ public:
return type_safe::optional_ref<V>{};
}
template <typename V = T> auto get_element_parent(const T &element) const
{
auto path = element.path();
auto parent = get_element(path);
if (parent.has_value())
return type_safe::optional_ref<V>{
type_safe::ref<V>(dynamic_cast<V &>(parent.value()))};
return type_safe::optional_ref<V>{};
}
template <typename V = T> auto get_element(const std::string &name) const
{
assert(!util::contains(name, "::"));