You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
When getting a product from the
EventStore
, e.g. viastore.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 theEventStore
.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 withI just realized that this is actually easily possible by asking the returned collection whether it is valid viabool EventStore::get(const std::string&, const T*&)
, but I think this should also be possible using the more ergonomicEventStore::get(const std::string&)
).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 inboost
.The text was updated successfully, but these errors were encountered: