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

[WIP] Improve user facing API: make Object ctor from Obj* private #221

Closed
wants to merge 1 commit into from

Conversation

vvolkl
Copy link
Contributor

@vvolkl vvolkl commented Sep 28, 2021

This PR makes this and similar constructors



edm4hep::MCParticle::MCParticle  (  MCParticleObj *  obj  ) 

private. As far as I can see there is no way for users to access a MCParticleObj* and they are not intended to do so, so this should not be part of the public API.

The downside implementationwise is that the constructors templating macro does not cover private, so I had to move it out of the macro.

BEGINRELEASENOTES

  • Improve user facing API: make Object ctor from Obj* private

ENDRELEASENOTES

@tmadlener
Copy link
Collaborator

I agree that the constructor from an Obj* should be private. However, it is not entirely trivial, because it is also used for OneToOneRelations that are missing or not (yet) set, i.e. the constructor from a nullptr below.

const {{ relation.relation_type }} {{ class_type }}::{{ relation.getter_name(get_syntax) }}() const {
if (!m_obj->m_{{ relation.name }}) {
return {{ relation.relation_type }}(nullptr);
}
return {{ relation.relation_type }}(*(m_obj->m_{{ relation.name }}));
}

One way out of this would be to declare all of the related classes as friend, but that can become quite a list, and I am not sure we want to go into that direction.

@tmadlener
Copy link
Collaborator

I just realized this constructor is also used in setReferences, e.g. here:

https://github.com/AIDASoft/podio/blob/master/python/templates/macros/collections.jinja2#L63-L69

@vvolkl vvolkl changed the title Improve user facing API: make Object ctor from Obj* private [WIP] Improve user facing API: make Object ctor from Obj* private Sep 28, 2021
@vvolkl
Copy link
Contributor Author

vvolkl commented Sep 28, 2021

Ok, first step is then probably to update to doc string to clearly state that this is an internal method, and then fix this in the long run.

@tmadlener
Copy link
Collaborator

Superseded by #514

@tmadlener tmadlener closed this Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants