atd
July 10, 2017, 1:27pm
1
Hello
I would like to fill a “std::vector” in “Begin()”, and pass it to each Slave (just for reading it, not modifying).
I found that I can do it iif the vector is related to fObject as
fObject = (TObject*) new std::vector();
I tried to use it as an internal variable, but it didn’t work.
So, apart from using “fObject” in that shoddy way, is there any other solution?
Thank you for your time.
Regards,
atd
Edit:
I found this older answer,
Dear Eric.
The constructor is run on every node, but the input list is not yet filled when the constructor is called, so if you want to use run-time arguments you have to initialize things in SlaveBegin().
For non TObject-derived objects you need a wrapper. We have TParameter for that, which is a templated class. The only trick is that dictionaries (and streamers) are not defined for all possible implementations, so you have to add the ones that you need. See the attached example, where I ha…
So, why is better a wrapper using TParameter than a (TObject*)/(myObject*) cast?
Hi atd,
you definitely cannot convert a std::vector
to a TObject*
safely. That code will probably crash, and certainly will not do what you want.
I think you can simply declare a std::vector
member variable for your selector class and then use it in its methods, as usual with c++ classes.
atd
July 10, 2017, 2:30pm
3
Hello
I was trying to prepare a simplified example code, and I discover how to set the member variables: the member variables must be set in the constructor, not during the “Begin()” step.
Thank you
Regards!
atd
system
Closed
July 24, 2017, 2:30pm
4
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.