RDataFrame helper class inheritance

I’m trying to write a program that allows a user to have a simple helper class that inherits from a provided helper class (which is embedded in the program and takes care of a number of default things).

So the way things look right now, I have the main program do a number of things, load all the input files into a chain, then it creates an RDataFrame with that chain as input and hands it over to a helper class.

This helper class was automatically compiled and loaded at run-time and is of type myHelper which inherits from baseHelper, and ROOT::Detail::RDF::RActionImpl<myHelper>. baseHelper inherits from ROOT::Detail::RDF::RActionImpl<baseHelper>and is the only helper class known at compile time. As such the code that load (and or compiles) the myHelper class casts the pointer of the new helper to a baseHelper pointer. This pointer is then used to call a function that takes the RDataFrame as input and books itself as the action (using the appropriate template classes for this specific helper action). This all works fine, and all the user specific code gets called at the initialization stage. But when it comes to the data processing stage, only baseHelper::Exec gets called, not myHelper::Exec.

My main question here is am I even on the right track with the way I’m doing this or is this impossible with the way RDataFrame works? Mainly with the way RDataFrame::Book takes an r-value reference of the helper class, could this result in object slicing and be the cause why this approach just can’t work? Or am I just doing another dumb mistake and this should work in principle?

I figured out what I did wrong. There was no need to have my base-class inherit frim RActionImpl at all, and I also didn’t need a variadic Exec function in the base-class (which can’t be made virtual and thus won’t be replaced by the derived class’s Exec function).
So a base-class that deals with correct initialization of various protected members and provides a default Finalize function was all I needed.

Hi @vaubee ,

sorry for the late reply, I was off last week.

can’t be made virtual and thus won’t be replaced by the derived class’s Exec function

plus

a base-class that deals with correct initialization of various protected members and provides a default Finalize function was all I needed

sounds like the solution indeed!

Let us know if you encounter any further issues.
Cheers,
Enrico

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