Within a large software framework F used by dozens of people, I utilize ROOT::Math::GSLMinimizer::Minimize(). ROOT::Math::GSLMinimizer derives from abstract class ROOT::Math::Minimizer. I wrote F::ClassE that lives within our framework, successfully creates an object pointer of type ROOT::Math::Minimizer*, and successfully uses the function ROOT::Math::GSLMinimizer::Minimize(). What I need is a very slightly modified overloaded version of that function, Minimize( int &iteration ), that gives the end-user access to the current iteration within my F::ClassE. If I lived in a vacuum and no one else needed to use ROOT, I would just modify the source code for ROOT::Math::GSLMinimizer to include my overloaded function, and la la la la life goes on. However, many people rely on ROOT, and it is not the best idea for me to patch ROOT and try to convince the powers-that-be to use my patched version of ROOT for everything else, even though the change would not affect others.
I propose to create either a friend class (which I have never used) or an inherited class (which I have used plenty, but not from an already derived class) F::ClassG, which should live inside my package, include this overloaded function that I want, allow me to use it within F::ClassE, and not disrupt ROOT as it is compiled for everyone’s use. Should ClassG inherit from ROOT::Math::Minimizer, or from R::Math::GSLMinimizer? Or some other approach? I’ve tried a few approaches that do not compile, either because they are incorrect or because I haven’t carried them out properly.
I currently create the object pointer this way:
ROOT::Math::Minimzer* min = ROOT::Math::CreateMinimizer( m_MinCategory, m_MinType );
The method Minimize() exists in both the parent class ROOT::Math::Minimizer (abstract) and the derived class ROOT::Math::GSLMinimizer, where I need the overloaded function.
The m_MinCategory selects GSLMinimizer, which selects that class’s implementation of the abstract method ::Minimize().
Do I need a modified version of ROOT::Math::Factory that would CreateMinimizer of my new category/type? Is there a simple solution that I am overlooking completely, besides using a private version of ROOT?