CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Multiple inheritance paradigms in OpenFOAM (https://www.cfd-online.com/Forums/openfoam-programming-development/213451-multiple-inheritance-paradigms-openfoam.html)

raumpolizei December 27, 2018 10:05

Multiple inheritance paradigms in OpenFOAM
 
Merry Christmas everyone,

from time to time, by going through the OF code (v16.12), I see some crazy (to me) inheritance hierarchies combined with multiple inheritance. One example is the class template reactingMixture (src/thermophysicalModels/reactionThermo/mixtures/reactingMixture):

Code:

template<class ThermoType>
class reactingMixture
:
  public speciesTable,
    public autoPtr<chemistryReader<ThermoType>>,

    public multiComponentMixture<ThermoType>,
    public PtrList<Reaction<ThermoType>>
{
    // ...
    // declarations
    // ...
};

I've learned that public inheritance can be understood as "is a" relationship (here reactingMixture<ThermoType> is a autoPtr<chemistryReader<ThermoType>>, for instance). The previously posted code does not seem to fit this principle, as the "is a" criterion does not fit for most of these base classes.

My question: Is there a reason for that (some kind of paradigm I do not know about)? What are the advantages of such design? I thought that usually this kind of problem would be solved through composition. Am I just not seeing the big picture?

Thanks for your answers
RP

olesen December 30, 2018 05:18

You are probably right that the reader could/should be a member composition instead of inheritance (although I don't have the code in front of me at the moment). Please open a gitlab issue to track and discuss this.
Thanks,
/mark

olesen January 1, 2019 11:20

filed as https://develop.openfoam.com/Develop...us/issues/1144

raumpolizei January 4, 2019 08:16

Thanks Mark


All times are GMT -4. The time now is 15:37.