Skip to content

Commit

Permalink
Make checking for explicit types and if-else chain
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Jan 18, 2024
1 parent 59efd11 commit 0274858
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions python/templates/macros/collections.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ std::vector<{{ member.full_type }}> {{ class.bare_type }}Collection::{{ member.n
}
{% if relation.interface_types %}
// We need the concrete collection type to assign it to an InferenceWrapper
{% set else = joiner("else") %}
{% for int_type in relation.interface_types %}
if (auto concreteColl = dynamic_cast<{{ int_type.full_type }}Collection*>(coll)) {
const auto tmp = (*concreteColl)[id.index];
{{ else() }} if (auto {{ int_type.bare_type }}Coll = dynamic_cast<{{ int_type.full_type }}Collection*>(coll)) {
const auto tmp = (*{{ int_type.bare_type }}Coll)[id.index];
m_rel_{{ relation.name }}->emplace_back(tmp);
}
{% endfor %}
Expand All @@ -102,9 +103,10 @@ std::vector<{{ member.full_type }}> {{ class.bare_type }}Collection::{{ member.n
continue;
}
{% if relation.interface_types %}
{% set else = joiner("else") %}
{% for int_type in relation.interface_types %}
if (auto concreteColl = dynamic_cast<{{ int_type.full_type }}Collection*>(coll)) {
entries[i]->m_{{ relation.name }} = new {{ relation.full_type }}((*concreteColl)[id.index]);
{{ else() }} if (auto {{ int_type.bare_type }}Coll = dynamic_cast<{{ int_type.full_type }}Collection*>(coll)) {
entries[i]->m_{{ relation.name }} = new {{ relation.full_type }}((*{{ int_type.bare_type }}Coll)[id.index]);
}
{% endfor %}
{% else %}
Expand Down

0 comments on commit 0274858

Please sign in to comment.