Call streamer for member class inside custom streamer

I am writing a custom streamer for a class which has member objects. I’d need an example about how to call the member objects streamers inside the custom streamer of the main class, I’ve been not able to find one.
Thanks in advance.

Before we delve into the answer, what are you trying to accomplish (i.e. maybe you don’t need a custom streamer)?

Hi Philippe, what need to do is roughly what follows.

I have a class with an int member called a in version 1. In version 2 I need to add a bool member b which must be set to true when a>=0 and to false when a<0. So in the readout of version 1 objects from Root files I need to check the value of a and set b accordingly, and think this can be done only through a custom streamer. Additionally, both versions of the class have an object member c, for which I don’t want to replicate the implementation of the readout logic in my custom streamer, hence my original question.

Do you see any alternative to a custom streamer for handling this situation?

Hi @pcanal, any hint about this issue? Thanks.

Yes. This is exactly the type of case for which we developed the I/O customization rules.

Add to your LinkDef file:

#pragma read sourceClass="YourClassName" targetClass="YourClassName" version="[1]" source="int a" target="b" code="{ b = (onfile.a >=0); }"

Great, I already used the customization rules for handling renamed variables but I didn’t know it was also possible to define custom code. I’ll give it a try.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.