-
Notifications
You must be signed in to change notification settings - Fork 9
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
API inconsistency: Set vs Insert vs SetSingle #254
Comments
There are several different places we can go from here. Some of these are mutually exclusive.
|
I'm not sure if I'm following this completely. It seems the PODIO immutable collection issue places some practical limitations on what can be done with inserts from the JANA side. I would not want to lose the ability to Insert() single objects or vectors of objects into an event for non-PODIO applications. We may need to discuss it in person if it is more complicated than that. |
Yeah, this is a "big" discussion. Not happening overnight. |
@faustus123 In terms of functionality we would lose if we pursued (0), it's not much:
|
This aggregates a number of earlier complaints about part of our API. These all need to be solved at the same time, and would constitute a major breaking change.
JEventSources are supposed to call JEvent::Insert(), but JFactories and JEventProcessors are not. Weirdly, JEvent::Insert is incorrectly marked
const
(Public access to JEvent::Set #155). (This is probably a workaround from the days before we had Multifactories)JEvent provides two versions of Insert(), one which "inserts" a whole collection into a dummy factory, and one of which "inserts" one item into an existing collection in a dummy factory. The latter is (a) inefficient when there are multiple inserts and (b) not compatible with PODIO's immutable collection semantics. In theory the former JEvent::Insert() works with PODIO data, although we strongly encourage PODIO users to use InsertCollection() and InsertCollectionAlreadyInFrame() instead.
JFactoryT's are supposed to call JFactoryT::Set() for collections and JFactoryT::Insert() for individual items. (Note this is inconsistent with JEventSources, where you call JEvent::Insert for collections as well; see issue JEvent::Set and JFactory::Insert #154) JFactoryPodioT's, on the other hand, provide JFactoryT::Set() and JFactoryT::Insert() (which actually has SetSingle() semantics since you can't append to a PODIO collection after publishing it to the Frame) but also SetCollection(), which is what users are really supposed to be using instead.
JMultifactories are only supposed to call SetData() or SetCollection(). There is no corresponding Insert()/SetSingle(). (No SetSingle for JMultiFactory #226)
Overall, I'd say it mostly makes sense how we got here. However, the mismatch between the JANA+PODIO parts and the PODIO-free parts is definitely higher than I'd like, and naming things "Insert" some of the time (particularly when they don't have full insert semantics) was a mistake.
The text was updated successfully, but these errors were encountered: