Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass an argument by const reference instead of value and other minor fixes #633

Merged
merged 6 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions python/templates/MutableObject.cc.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
#include "nlohmann/json.hpp"
#endif

#include <ostream>

{{ utils.namespace_open(class.namespace) }}

{{ macros.constructors_destructors(class.bare_type, Members, multi_relations=OneToManyRelations + VectorMembers, prefix='Mutable') }}
Expand Down
2 changes: 1 addition & 1 deletion python/templates/Obj.cc.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
{%- endwith %}

{% for relation in OneToOneRelations %}
if (m_{{ relation.name }}) delete m_{{ relation.name }};
delete m_{{ relation.name }};
{% endfor %}
}
{%- endif %}
Expand Down
2 changes: 1 addition & 1 deletion python/templates/macros/declarations.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
{% macro single_relation_setters(relations, get_syntax) %}
{% for relation in relations %}
/// Set the {{ relation.description }}
void {{ relation.setter_name(get_syntax) }}({{ relation.full_type }} value);
void {{ relation.setter_name(get_syntax) }}(const {{ relation.full_type }}& value);
{% endfor %}
{%- endmacro %}

Expand Down
11 changes: 3 additions & 8 deletions python/templates/macros/implementations.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,8 @@ const {{ relation.full_type }} {{ class_type }}::{{ relation.getter_name(get_syn
{% macro single_relation_setters(class, relations, get_syntax, prefix='') %}
{% set class_type = prefix + class.bare_type %}
{% for relation in relations %}
void {{ class_type }}::{{ relation.setter_name(get_syntax) }}({{ relation.full_type }} value) {
if (m_obj->m_{{ relation.name }}) {
delete m_obj->m_{{ relation.name }};
}
void {{ class_type }}::{{ relation.setter_name(get_syntax) }}(const {{ relation.full_type }}& value) {
delete m_obj->m_{{ relation.name }};
m_obj->m_{{ relation.name }} = new {{ relation.full_type }}(value);
}

Expand Down Expand Up @@ -182,10 +180,7 @@ podio::RelationRange<{{ relation.full_type }}> {{ class_type }}::{{ relation.get
{% macro common_object_funcs(class, prefix='') %}
{% set full_type = prefix + class.bare_type %}
bool {{ full_type }}::isAvailable() const {
if (m_obj) {
return true;
}
return false;
return m_obj;
}

const podio::ObjectID {{ full_type }}::getObjectID() const {
Expand Down
1 change: 0 additions & 1 deletion python/templates/macros/utils.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ namespace {{ nsp }} {
#include "{{ incfolder }}Mutable{{ type }}.h"
#include "{{ incfolder }}{{ type }}Obj.h"
#include "{{ incfolder }}{{ type }}Data.h"
#include "{{ incfolder }}{{ type }}Collection.h"
{%- endmacro %}


Expand Down