diff --git a/python/templates/MutableObject.cc.jinja2 b/python/templates/MutableObject.cc.jinja2 index ad08b5019..0eeb97b3f 100644 --- a/python/templates/MutableObject.cc.jinja2 +++ b/python/templates/MutableObject.cc.jinja2 @@ -17,7 +17,7 @@ {{ utils.namespace_open(class.namespace) }} -{{ macros.common_constructors_destructors(class.bare_type, Members, prefix='Mutable') }} +{{ macros.constructors_destructors(class.bare_type, Members, prefix='Mutable') }} Mutable{{ class.bare_type }}::operator {{ class.bare_type }}() const { return {{ class.bare_type }}(m_obj); } diff --git a/python/templates/MutableObject.h.jinja2 b/python/templates/MutableObject.h.jinja2 index 4eea894a7..1c1e33f74 100644 --- a/python/templates/MutableObject.h.jinja2 +++ b/python/templates/MutableObject.h.jinja2 @@ -38,7 +38,7 @@ public: using object_type = {{ class.bare_type }}; using collection_type = {{ class.bare_type }}Collection; -{{ macros.common_constructors_destructors(class.bare_type, Members, prefix='Mutable') }} +{{ macros.constructors_destructors(class.bare_type, Members, prefix='Mutable') }} /// conversion to const object operator {{ class.bare_type }}() const; @@ -54,9 +54,6 @@ public: {{ utils.if_present(MutableExtraCode, "declaration") }} {{ macros.common_object_funcs(class.bare_type, prefix='Mutable') }} - /// disconnect from {{ class.bare_type }}Obj instance - void unlink() { m_obj = podio::utils::MaybeSharedPtr<{{ class.bare_type }}Obj>{nullptr}; } - private: /// constructor from existing {{ class.bare_type }}Obj explicit Mutable{{ class.bare_type }}(podio::utils::MaybeSharedPtr<{{ class.bare_type }}Obj> obj); diff --git a/python/templates/Object.cc.jinja2 b/python/templates/Object.cc.jinja2 index b197cfcd6..1ba27fb51 100644 --- a/python/templates/Object.cc.jinja2 +++ b/python/templates/Object.cc.jinja2 @@ -17,7 +17,7 @@ {{ utils.namespace_open(class.namespace) }} -{{ macros.common_constructors_destructors(class.bare_type, Members) }} +{{ macros.constructors_destructors(class.bare_type, Members) }} {{ class.bare_type }}::{{ class.bare_type }}({{ class.bare_type }}Obj* obj) : m_obj(podio::utils::MaybeSharedPtr<{{ class.bare_type }}Obj>(obj)) {} diff --git a/python/templates/Object.h.jinja2 b/python/templates/Object.h.jinja2 index e6784bc5c..89b6127ce 100644 --- a/python/templates/Object.h.jinja2 +++ b/python/templates/Object.h.jinja2 @@ -39,7 +39,7 @@ public: using mutable_type = Mutable{{ class.bare_type }}; using collection_type = {{ class.bare_type }}Collection; -{{ macros.common_constructors_destructors(class.bare_type, Members) }} +{{ macros.constructors_destructors(class.bare_type, Members) }} static {{ class.bare_type }} makeEmpty(); @@ -51,9 +51,6 @@ public: {{ utils.if_present(ExtraCode, "declaration") }} {{ macros.common_object_funcs(class.bare_type) }} - /// disconnect from {{ class.bare_type }}Obj instance - void unlink() { m_obj = podio::utils::MaybeSharedPtr<{{ class.bare_type }}Obj>{nullptr}; } - private: /// constructor from existing {{ class.bare_type }}Obj explicit {{ class.bare_type}}(podio::utils::MaybeSharedPtr<{{ class.bare_type }}Obj> obj); diff --git a/python/templates/SIOBlock.cc.jinja2 b/python/templates/SIOBlock.cc.jinja2 index 0e7c0745d..4fc065b46 100644 --- a/python/templates/SIOBlock.cc.jinja2 +++ b/python/templates/SIOBlock.cc.jinja2 @@ -89,7 +89,7 @@ namespace { // library actually needs linking to the core library. Otherwise it is // possible that the registry is not populated when the SioBlock library is // loaded, e.g. when using the python bindings. - const auto elem = {{ class.full_type }}::makeEmpty(); + const auto elem = {{ class.full_type }}{}; } {% endwith %} diff --git a/python/templates/macros/declarations.jinja2 b/python/templates/macros/declarations.jinja2 index 3fee6332b..192acd8d1 100644 --- a/python/templates/macros/declarations.jinja2 +++ b/python/templates/macros/declarations.jinja2 @@ -54,9 +54,9 @@ {% endmacro %} -{% macro common_constructors_destructors(type, members, prefix='') %} +{% macro constructors_destructors(type, members, prefix='') %} {% set full_type = prefix + type %} - /// Default constructor + /// default constructor {{ full_type }}(); {%if members %} @@ -82,6 +82,8 @@ {% set full_type = prefix + type %} /// check whether the object is actually available bool isAvailable() const; + /// disconnect from {{ type }}Obj instance + void unlink() { m_obj = podio::utils::MaybeSharedPtr<{{ type }}Obj>{nullptr}; } {% set inverse_type = type if prefix else 'Mutable' + type %} bool operator==(const {{ full_type }}& other) const { return m_obj == other.m_obj; } diff --git a/python/templates/macros/implementations.jinja2 b/python/templates/macros/implementations.jinja2 index b67e81c68..54dba3cec 100644 --- a/python/templates/macros/implementations.jinja2 +++ b/python/templates/macros/implementations.jinja2 @@ -1,4 +1,4 @@ -{% macro common_constructors_destructors(type, members, prefix='') %} +{% macro constructors_destructors(type, members, prefix='') %} {% set full_type = prefix + type %} {{ full_type }}::{{ full_type }}() :