From 69243fda224ab84f2d81b630f063c795de0ad571 Mon Sep 17 00:00:00 2001 From: Henry Weller <http://cfd.direct> Date: Fri, 17 Jul 2015 16:48:35 +0100 Subject: [PATCH] OpenFOAM/primitives/functions/DataEntry/Table: Removed unnecessary multiple inheritance This resolves issues with and complexities in the virtual function inheritance --- .../primitives/functions/DataEntry/CSV/CSV.C | 2 - .../primitives/functions/DataEntry/CSV/CSV.H | 41 ------------- .../functions/DataEntry/Table/Table.C | 7 --- .../functions/DataEntry/Table/Table.H | 37 ------------ .../functions/DataEntry/Table/TableBase.C | 4 +- .../functions/DataEntry/Table/TableBase.H | 4 +- .../functions/DataEntry/Table/TableBaseIO.C | 5 +- .../functions/DataEntry/Table/TableIO.C | 58 ------------------- .../functions/DataEntry/TableFile/TableFile.C | 2 - .../functions/DataEntry/TableFile/TableFile.H | 31 ---------- .../DataEntry/TableFile/TableFileIO.C | 20 ------- 11 files changed, 10 insertions(+), 201 deletions(-) delete mode 100644 src/OpenFOAM/primitives/functions/DataEntry/Table/TableIO.C diff --git a/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.C b/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.C index 15aebc08b84..28b0924db95 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.C +++ b/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.C @@ -203,7 +203,6 @@ Foam::CSV<Type>::CSV const word& ext ) : - DataEntry<Type>(entryName), TableBase<Type>(entryName, dict.subDict(entryName + ext)), coeffs_(dict.subDict(entryName + ext)), nHeaderLine_(readLabel(coeffs_.lookup("nHeaderLine"))), @@ -230,7 +229,6 @@ Foam::CSV<Type>::CSV template<class Type> Foam::CSV<Type>::CSV(const CSV<Type>& tbl) : - DataEntry<Type>(tbl), TableBase<Type>(tbl), nHeaderLine_(tbl.nHeaderLine_), refColumn_(tbl.refColumn_), diff --git a/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.H b/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.H index 78476adc80a..5969339d67f 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.H +++ b/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.H @@ -79,7 +79,6 @@ Ostream& operator<< template<class Type> class CSV : - public DataEntry<Type>, public TableBase<Type> { // Private data @@ -150,52 +149,12 @@ public: // Member Functions - // Manipulation - - //- Convert time - virtual void convertTimeBase(const Time& t) - { - TableBase<Type>::convertTimeBase(t); - } - - // Access //- Return const access to the file name virtual const fileName& fName() const; - // Evaluation - - //- Return Table value - virtual Type value(const scalar x) const - { - return TableBase<Type>::value(x); - } - - //- Integrate between two (scalar) values - virtual Type integrate(const scalar x1, const scalar x2) const - { - return TableBase<Type>::integrate(x1, x2); - } - - //- Return dimensioned constant value - virtual dimensioned<Type> dimValue(const scalar x) const - { - return TableBase<Type>::dimValue(x); - } - - //- Integrate between two values and return dimensioned type - virtual dimensioned<Type> dimIntegrate - ( - const scalar x1, - const scalar x2 - ) const - { - return TableBase<Type>::dimIntegrate(x1, x2); - } - - // I/O //- Ostream Operator diff --git a/src/OpenFOAM/primitives/functions/DataEntry/Table/Table.C b/src/OpenFOAM/primitives/functions/DataEntry/Table/Table.C index eacfc0e1eb9..1e1e0af54e4 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/Table/Table.C +++ b/src/OpenFOAM/primitives/functions/DataEntry/Table/Table.C @@ -30,7 +30,6 @@ License template<class Type> Foam::Table<Type>::Table(const word& entryName, const dictionary& dict) : - DataEntry<Type>(entryName), TableBase<Type>(entryName, dict) { Istream& is(dict.lookup(entryName)); @@ -51,7 +50,6 @@ Foam::Table<Type>::Table(const word& entryName, const dictionary& dict) template<class Type> Foam::Table<Type>::Table(const Table<Type>& tbl) : - DataEntry<Type>(tbl), TableBase<Type>(tbl) {} @@ -63,9 +61,4 @@ Foam::Table<Type>::~Table() {} -// * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * // - -#include "TableIO.C" - - // ************************************************************************* // diff --git a/src/OpenFOAM/primitives/functions/DataEntry/Table/Table.H b/src/OpenFOAM/primitives/functions/DataEntry/Table/Table.H index 950c3790a62..9f45b69d15a 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/Table/Table.H +++ b/src/OpenFOAM/primitives/functions/DataEntry/Table/Table.H @@ -70,7 +70,6 @@ Ostream& operator<< template<class Type> class Table : - public DataEntry<Type>, public TableBase<Type> { // Private Member Functions @@ -102,42 +101,6 @@ public: //- Destructor virtual ~Table(); - - - // Member Functions - - // Manipulation - - //- Inherit convertTimeBase from TableBase - using TableBase<Type>::convertTimeBase; - - - // Evaluation - - //- Inherit value from TableBase - using TableBase<Type>::value; - - //- Inherit integrate from TableBase - using TableBase<Type>::integrate; - - //- Inherit dimValue from TableBase - using TableBase<Type>::dimValue; - - //- Inherit dimIntegrate from TableBase - using TableBase<Type>::dimIntegrate; - - - // I/O - - //- Ostream Operator - friend Ostream& operator<< <Type> - ( - Ostream& os, - const Table<Type>& tbl - ); - - //- Write in dictionary format - virtual void writeData(Ostream& os) const; }; diff --git a/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBase.C b/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBase.C index c2e768ccebc..2dedd9ffe35 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBase.C +++ b/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBase.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -57,6 +57,7 @@ const Foam::interpolationWeights& Foam::TableBase<Type>::interpolator() const template<class Type> Foam::TableBase<Type>::TableBase(const word& name, const dictionary& dict) : + DataEntry<Type>(name), name_(name), boundsHandling_ ( @@ -77,6 +78,7 @@ Foam::TableBase<Type>::TableBase(const word& name, const dictionary& dict) template<class Type> Foam::TableBase<Type>::TableBase(const TableBase<Type>& tbl) : + DataEntry<Type>(tbl), name_(tbl.name_), boundsHandling_(tbl.boundsHandling_), interpolationScheme_(tbl.interpolationScheme_), diff --git a/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBase.H b/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBase.H index 793716803ae..df7542e6fde 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBase.H +++ b/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBase.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -62,6 +62,8 @@ class interpolationWeights; template<class Type> class TableBase +: + public DataEntry<Type> { public: diff --git a/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBaseIO.C b/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBaseIO.C index 645934f5fef..d4f608b8ab2 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBaseIO.C +++ b/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBaseIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -34,6 +34,8 @@ Foam::Ostream& Foam::operator<< const TableBase<Type>& tbl ) { + os << static_cast<const DataEntry<Type>&>(tbl); + if (os.format() == IOstream::ASCII) { os << token::SPACE << tbl.table_; @@ -60,6 +62,7 @@ Foam::Ostream& Foam::operator<< template<class Type> void Foam::TableBase<Type>::writeData(Ostream& os) const { + DataEntry<Type>::writeData(os); os << nl << indent << table_ << token::END_STATEMENT << nl; writeEntries(os); } diff --git a/src/OpenFOAM/primitives/functions/DataEntry/Table/TableIO.C b/src/OpenFOAM/primitives/functions/DataEntry/Table/TableIO.C deleted file mode 100644 index ec43d46dd9c..00000000000 --- a/src/OpenFOAM/primitives/functions/DataEntry/Table/TableIO.C +++ /dev/null @@ -1,58 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "DataEntry.H" - -// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // - -template<class Type> -Foam::Ostream& Foam::operator<< -( - Ostream& os, - const Table<Type>& tbl -) -{ - os << static_cast<const DataEntry<Type>&>(tbl) - << static_cast<const TableBase<Type>&>(tbl); - - // Check state of Ostream - os.check - ( - "Ostream& operator<<(Ostream&, const Table<Type>&)" - ); - - return os; -} - - -template<class Type> -void Foam::Table<Type>::writeData(Ostream& os) const -{ - DataEntry<Type>::writeData(os); - TableBase<Type>::writeData(os); -} - - -// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/functions/DataEntry/TableFile/TableFile.C b/src/OpenFOAM/primitives/functions/DataEntry/TableFile/TableFile.C index 9119148a178..20f8a4b1d07 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/TableFile/TableFile.C +++ b/src/OpenFOAM/primitives/functions/DataEntry/TableFile/TableFile.C @@ -30,7 +30,6 @@ License template<class Type> Foam::TableFile<Type>::TableFile(const word& entryName, const dictionary& dict) : - DataEntry<Type>(entryName), TableBase<Type>(entryName, dict.subDict(entryName + "Coeffs")), fName_("none") { @@ -63,7 +62,6 @@ Foam::TableFile<Type>::TableFile(const word& entryName, const dictionary& dict) template<class Type> Foam::TableFile<Type>::TableFile(const TableFile<Type>& tbl) : - DataEntry<Type>(tbl), TableBase<Type>(tbl), fName_(tbl.fName_) {} diff --git a/src/OpenFOAM/primitives/functions/DataEntry/TableFile/TableFile.H b/src/OpenFOAM/primitives/functions/DataEntry/TableFile/TableFile.H index 537fa20a70f..dc34c00e795 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/TableFile/TableFile.H +++ b/src/OpenFOAM/primitives/functions/DataEntry/TableFile/TableFile.H @@ -82,7 +82,6 @@ Ostream& operator<< template<class Type> class TableFile : - public DataEntry<Type>, public TableBase<Type> { // Private data @@ -122,38 +121,8 @@ public: virtual ~TableFile(); - // Member Functions - - // Manipulation - - //- Inherit convertTimeBase from TableBase - using TableBase<Type>::convertTimeBase; - - - // Evaluation - - //- Inherit value from TableBase - using TableBase<Type>::value; - - //- Inherit integrate from TableBase - using TableBase<Type>::integrate; - - //- Inherit dimValue from TableBase - using TableBase<Type>::dimValue; - - //- Inherit dimIntegrate from TableBase - using TableBase<Type>::dimIntegrate; - - // I/O - //- Ostream Operator - friend Ostream& operator<< <Type> - ( - Ostream& os, - const TableFile<Type>& tbl - ); - //- Write in dictionary format virtual void writeData(Ostream& os) const; }; diff --git a/src/OpenFOAM/primitives/functions/DataEntry/TableFile/TableFileIO.C b/src/OpenFOAM/primitives/functions/DataEntry/TableFile/TableFileIO.C index adaa63119f2..5b074027fcb 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/TableFile/TableFileIO.C +++ b/src/OpenFOAM/primitives/functions/DataEntry/TableFile/TableFileIO.C @@ -27,26 +27,6 @@ License // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // -template<class Type> -Foam::Ostream& Foam::operator<< -( - Ostream& os, - const TableFile<Type>& tbl -) -{ - os << static_cast<const DataEntry<Type>&>(tbl) - << static_cast<const TableBase<Type>&>(tbl); - - // Check state of Ostream - os.check - ( - "Ostream& operator<<(Ostream&, const TableFile<Type>&)" - ); - - return os; -} - - template<class Type> void Foam::TableFile<Type>::writeData(Ostream& os) const { -- GitLab