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
I think podio should support true reference collections. Currently something similar can be achieved by defining a helper data type, a la
DataType:
Members:
- int member // just some exemplary memberDataTypeReference:
Members: {}OneToOneRelations:
- DataType referenced // reference to the actual datatype
However, this is slightly awkward in its usage, as there is always an additional indirection to get to the actual information
auto& referenceCollection = eventStore.get<DataTypeReferenceCollection>("refCollection");
auto ref = referenceCollection[0];
auto data = ref.getReferenced();
int i = data.getMember();
Also setting this is slightly cumbersome
auto& dataCollection = eventStore.create<DataTypeCollection>("dataCollection");
auto& referenceCollection = eventStore.create<DataTypeReferenceCollection>("refCollection");
auto data = dataCollection.create();
auto ref = referenceCollection.create();
ref.setReferenced(data);
Ideally, reference collections behave the same as normal collections when they are const, i.e. reference collections do not allow to alter the objects they reference in any way, but can be used for read only access to them. So something along the lines:
DataType:
Members:
- int member // just some exemplary member
for which podio would generate a DataTypeCollection and a DataTypeRefCollection (naming is just a proposal here, also to distinguish it from the above example more clearly). So that in the end the usage would look something like this
// when writingauto& dataCollection = eventStore.create<DataTypeCollection>("dataCollection");
auto& referenceCollection = eventStore.create<DataTypeRefCollection>("refCollection");
auto data = dataCollection.create();
referenceCollection.push_back(data);
// changes to data should still be properly propagated to the reference object// when readingauto& referenceCollection = eventStore.get<DataTypeRefCollection>("refCollection");
auto data = referenceCollection[0];
int i = data.getMember();
I am not yet completely sure about the internals, but I think something like this should be possible. From a persistency point of view it should in principle work like any other OneToOneRelation and storing a vector<ObjectID> should be enough to rebuild the reference collection after reading it in. One of the major changes that would be necessary is probably to change the layout of the Obj classes from storing a Data object to only having a pointer to a Data object. I have already briefly mentioned this earlier in #129 (comment) . However, since then I haven't really checked what would actually be necessary to make that change work.
This is at the moment just an idea and an early draft of an implementation, so any input is very welcome.
The text was updated successfully, but these errors were encountered:
I think podio should support true reference collections. Currently something similar can be achieved by defining a helper data type, a la
However, this is slightly awkward in its usage, as there is always an additional indirection to get to the actual information
Also setting this is slightly cumbersome
Ideally, reference collections behave the same as normal collections when they are
const
, i.e. reference collections do not allow to alter the objects they reference in any way, but can be used for read only access to them. So something along the lines:for which podio would generate a
DataTypeCollection
and aDataTypeRefCollection
(naming is just a proposal here, also to distinguish it from the above example more clearly). So that in the end the usage would look something like thisI am not yet completely sure about the internals, but I think something like this should be possible. From a persistency point of view it should in principle work like any other
OneToOneRelation
and storing avector<ObjectID>
should be enough to rebuild the reference collection after reading it in. One of the major changes that would be necessary is probably to change the layout of theObj
classes from storing aData
object to only having a pointer to aData
object. I have already briefly mentioned this earlier in #129 (comment) . However, since then I haven't really checked what would actually be necessary to make that change work.This is at the moment just an idea and an early draft of an implementation, so any input is very welcome.
The text was updated successfully, but these errors were encountered: