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

Add a header file including all the collections #606

Merged
merged 9 commits into from
Jun 12, 2024

Conversation

jmcarcell
Copy link
Member

@jmcarcell jmcarcell commented May 23, 2024

BEGINRELEASENOTES

  • Add a header file including all the collections in the datamodel. This header will be generated and installed into <datamodel>/<datamodel>.h.

ENDRELEASENOTES

The usage would be

#include "edm4hep/edm4hep.h"

and all the collections will be included.

I find from time to time I need to do something with all the collections and after having a look at other options (hardcoding the includes means they always have to be changed; having some CMake magic in EDM4hep to generate this file is an option but it also can be done at the podio level) I think this is the cleanest one and other people can maybe also use it. In practice, if an algorithm does something with the collections and a new one is added, even if the include doesn't change because it comes from this file other code that does something with collections will have to be changed.

Copy link
Collaborator

@tmadlener tmadlener left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable to me. I am not sure if AllCollections.h is the best name, but I don't have a better one either. Maybe something that conveys better that this is the complete datamodel?

You also need to add the new template here to trigger re-generation in case the template changes:
https://github.com/AIDASoft/podio/blob/master/python/templates/CMakeLists.txt

@@ -0,0 +1,5 @@
// AUTOMATICALLY GENERATED FILE - DO NOT EDIT

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we generate include guards here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added, although it should not matter much since the headers have their own

Comment on lines 492 to 496
collection_files = (
os.path.basename(f)
for f in self.generated_files
if f.endswith("Collection.h") and "Mutable" not in f
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should be able to get this from self.datatypes without having to filter the generated files to find the Collection.h files?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it to use self.datamodel.datatypes

@jmcarcell
Copy link
Member Author

Looks reasonable to me. I am not sure if AllCollections.h is the best name, but I don't have a better one either. Maybe something that conveys better that this is the complete datamodel?

You also need to add the new template here to trigger re-generation in case the template changes: master/python/templates/CMakeLists.txt

I changed it to, for example for EDM4hep, edm4hep/Alledm4hepCollections.h

@hegner
Copy link
Collaborator

hegner commented May 24, 2024

Why don't we just call it edm4hep/edm4hep.h ? Because it is just edm4hep we are including with that. Or datamodel/datamodel.h ?

@m-fila
Copy link
Contributor

m-fila commented May 24, 2024

I think I prefer edm4hep/AllCollections.h over edm4hep/Alledm4hepCollections.h but just edm4hep/Collections.h reads even better for me
Name of this header technically becomes reserved for componenents/datatatypes/interfaces (for instance 'DatamodelDefinition' is already reserved as using it as a name for anything would collide with DatamodelDefinition.h). It's super formal and pedantic but a list of reserved keywords could be documented and potentially validated

Maybe something that conveys better that this is the complete datamodel?

edm4hep/Datamodel.hor edm4hep/edm4hep.h? Wouldn't the components not used in any datatype be missing though?

@hegner
Copy link
Collaborator

hegner commented May 24, 2024

edm4hep/Datamodel.hor edm4hep/edm4hep.h? Wouldn't the components not used in any datatype be missing though?

the missing components won't be needed in any case. Maybe for downstream code that would then include explicitly anyhow.

@tmadlener
Copy link
Collaborator

As decided during the EDM4hep meeting on Jun 4 the name of the header should be datamodel/datamodel.h.

@tmadlener
Copy link
Collaborator

I changed the name of the generated header and also changed the generator logic to ensure that it is installed, as I don't see a reason not to install it.

@jmcarcell
Copy link
Member Author

Looks good

@@ -1,6 +1,7 @@
set(PODIO_TEMPLATES
${CMAKE_CURRENT_LIST_DIR}/Collection.cc.jinja2
${CMAKE_CURRENT_LIST_DIR}/Collection.h.jinja2
${CMAKE_CURRENT_LIST_DIR}/AllCollections.h.jinja2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only nitpicking comment would be to change the name of the jinja2 template as well

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@tmadlener tmadlener merged commit a716c01 into AIDASoft:master Jun 12, 2024
18 checks passed
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.

4 participants