and that I’d like to be able to select, runtime, using just the name of the implementation class, which implementation to use, amongst B and C for instance.
If the ctor has no parameter, I sort of know how to do it, I’d use TClass::New(), but I do not see how to do it for ctors with parameters…
TClass::New is only able to call one constructor without any parameter.
To call a constructor with parameters you need to go directly through
CINT. For example something like:A* = (A*)gROOT->ProcessLine("new B(\"tt\",\"xx\")");
Cheers,
Philippe
using Driver* driver=...;
A* a= (A*)gROOT->ProcessLine(Form("new B(0x%x)",driver));
That will pass the value of driver to the constructor B::B(Driver* driver).
You could also have a singleton DriverManager, which stores the current driver, and which gets contacted by B’s and C’s constructors, as in [code]B::B() {
Driver* driver=DriverManager::Instance()->GetCurrentDriver();
… }