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

podio silently skips over non-existant products #96

Closed
tmadlener opened this issue Jun 10, 2020 · 1 comment · Fixed by #97
Closed

podio silently skips over non-existant products #96

tmadlener opened this issue Jun 10, 2020 · 1 comment · Fixed by #97

Comments

@tmadlener
Copy link
Collaborator

tmadlener commented Jun 10, 2020

When getting a product from the EventStore, e.g. via store.get<edm4hep::TrackCollection>("tracks"), podio currently does not even issue any warning that the product is not available. Instead a default constructed object of the desired type is returned. The most trivial way this can happen is a simple typo. However, it might actually be the case that a user requires a product that is simply not present in the EventStore.

I think podio should at least print a warning statement that the desired product is not found. Arguably, it should be possible for the user to check whether the object is present in the EventStore or not. (I know this is in principle possible with bool EventStore::get(const std::string&, const T*&), but I think this should also be possible using the more ergonomic EventStore::get(const std::string&)). I just realized that this is actually easily possible by asking the returned collection whether it is valid via collection.isValid(). The question then becomes do we want to force the user to check whether the collection is valid or not?

This would be an excellent use case for optional, but that would require at least c++17, unless we want to pull in boost.

@andresailer
Copy link
Member

We agreed that we can use c++17 for key4hep at least:
https://codimd.web.cern.ch/lkFym47kSdKGWqmPLCpf-w#Build-system--Target-compiler--dependencies

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 a pull request may close this issue.

2 participants