|
[Sponsors] |
Lazy programming: ommitting multiple inheritance |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
October 18, 2021, 12:35 |
Lazy programming: ommitting multiple inheritance
|
#1 |
Member
Bram Kerkhofs1
Join Date: Oct 2016
Posts: 30
Rep Power: 9 |
Dear Foamers
Untill now I've been able to program my own function objects by copying useful code from different existing function objects. So far everything is working, but it's always a hustle of selecting the code and reading existing code, which takes a lot of time. So I figured that it would just be more easy to just make instances of the existing classes and 'grab' the info from the instances and preform the action you want to preform on them. So the goal is for instance to make the header file like this: Code:
#include "functionA.H" #include "functionB.H" #include "functionC.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { namespace functionObjects { /*---------------------------------------------------------------------------*\ Class myOwnStuff Declaration \*---------------------------------------------------------------------------*/ class myOwnStuff : public functionA, public functionB, public functionC, { // Private Data ....... This variable is an fvMesh and is being used multiple times in different classes and represents (most of the time) the same thing. An fvMesh holds a lot of information which you want to extract. But since this is created multiple times your compiler returns a lot of errors. Not only instances of classes but also methods and variables are inherited multiple times. So this is more than just one type of diamond problem. My question is: is there an elegant way of programming like this and ommitting the multiple inheritance issues? For instance: the 'mesh_' errors can be omitted by declaring a private data member Code:
//- Reference to the fvMesh const fvMesh& mesh_; Code:
mesh_(refCast<const fvMesh>(obr_)) |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
how to set periodic boundary conditions | Ganesh | FLUENT | 15 | November 18, 2020 07:09 |
Multiple inheritance paradigms in OpenFOAM | raumpolizei | OpenFOAM Programming & Development | 3 | January 4, 2019 09:16 |
[OpenFOAM.org] Install openFOAM 3.0.1 in Ubuntu 16.04 LTS from Deb packs | Pier84 | OpenFOAM Installation | 4 | June 18, 2016 17:22 |
OpenFOAM static build on Cray XT5 | asaijo | OpenFOAM Installation | 9 | April 6, 2011 13:21 |
Multiple inheritance, function pointers or? | ngj | OpenFOAM | 0 | March 20, 2009 11:36 |