diff --git a/src/OpenFOAM/db/IOobjects/CompactIOList/CompactIOList.C b/src/OpenFOAM/db/IOobjects/CompactIOList/CompactIOList.C index 7e5411e0bb..99862dad15 100644 --- a/src/OpenFOAM/db/IOobjects/CompactIOList/CompactIOList.C +++ b/src/OpenFOAM/db/IOobjects/CompactIOList/CompactIOList.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,7 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "CompactIOList.H" -#include "labelList.H" +#include "IOList.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -35,7 +35,7 @@ void Foam::CompactIOList::readFromStream() if (headerClassName() == IOList::typeName) { - is >> static_cast&>(*this); + is >> static_cast&>(*this); close(); } else if (headerClassName() == typeName) @@ -57,23 +57,6 @@ void Foam::CompactIOList::readFromStream() } -template -bool Foam::CompactIOList::overflows() const -{ - label size = 0; - forAll(*this, i) - { - label oldSize = size; - size += this->operator[](i).size(); - if (size < oldSize) - { - return true; - } - } - return false; -} - - // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * // template @@ -111,7 +94,7 @@ Foam::CompactIOList::CompactIOList } else { - List::setSize(size); + this->setSize(size); } } @@ -135,7 +118,7 @@ Foam::CompactIOList::CompactIOList } else { - List::operator=(list); + ListCompactIO::operator=(list); } } @@ -149,7 +132,7 @@ Foam::CompactIOList::CompactIOList : regIOobject(io) { - List::transfer(list()); + this->transfer(list()); if ( @@ -195,7 +178,7 @@ bool Foam::CompactIOList::writeObject return good; } - else if (overflows()) + else if (this->overflows()) { WarningInFunction << "Overall number of elements of CompactIOList of size " @@ -236,100 +219,7 @@ void Foam::CompactIOList::operator= const CompactIOList& rhs ) { - List::operator=(rhs); -} - - -template -void Foam::CompactIOList::operator=(const List& rhs) -{ - List::operator=(rhs); -} - - -// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // - -template -Foam::Istream& Foam::operator>> -( - Foam::Istream& is, - Foam::CompactIOList& L -) -{ - // Read compact - const labelList start(is); - const List elems(is); - - // Convert - L.setSize(start.size()-1); - - forAll(L, i) - { - T& subList = L[i]; - - label index = start[i]; - subList.setSize(start[i+1] - index); - - forAll(subList, j) - { - subList[j] = elems[index++]; - } - } - - return is; -} - - -template -Foam::Ostream& Foam::operator<< -( - Foam::Ostream& os, - const Foam::CompactIOList& L -) -{ - // Keep ascii writing same. - if (os.format() == IOstream::ASCII) - { - os << static_cast&>(L); - } - else - { - // Convert to compact format - labelList start(L.size()+1); - - start[0] = 0; - for (label i = 1; i < start.size(); i++) - { - label prev = start[i-1]; - start[i] = prev+L[i-1].size(); - - if (start[i] < prev) - { - FatalIOErrorInFunction(os) - << "Overall number of elements " << start[i] - << " of CompactIOList of size " - << L.size() << " overflows the representation of a label" - << endl << "Please recompile with a larger representation" - << " for label" << exit(FatalIOError); - } - } - - List elems(start[start.size()-1]); - - label elemI = 0; - forAll(L, i) - { - const T& subList = L[i]; - - forAll(subList, j) - { - elems[elemI++] = subList[j]; - } - } - os << start << elems; - } - - return os; + ListCompactIO::operator=(rhs); } diff --git a/src/OpenFOAM/db/IOobjects/CompactIOList/CompactIOList.H b/src/OpenFOAM/db/IOobjects/CompactIOList/CompactIOList.H index 596f829778..210f34b4fa 100644 --- a/src/OpenFOAM/db/IOobjects/CompactIOList/CompactIOList.H +++ b/src/OpenFOAM/db/IOobjects/CompactIOList/CompactIOList.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -39,7 +39,7 @@ SourceFiles #ifndef CompactIOList_H #define CompactIOList_H -#include "IOList.H" +#include "ListCompactIO.H" #include "regIOobject.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -47,23 +47,6 @@ SourceFiles namespace Foam { -class Istream; -class Ostream; - -// Forward declaration of friend functions and operators -template class CompactIOList; - -template Istream& operator>> -( - Istream&, - CompactIOList& -); -template Ostream& operator<< -( - Ostream&, - const CompactIOList& -); - /*---------------------------------------------------------------------------*\ Class CompactIOList Declaration \*---------------------------------------------------------------------------*/ @@ -72,16 +55,13 @@ template class CompactIOList : public regIOobject, - public List + public ListCompactIO { // Private Member Functions //- Read according to header type void readFromStream(); - //- Has too many elements in it? - bool overflows() const; - public: //- Runtime type information @@ -124,25 +104,6 @@ public: // Member operators void operator=(const CompactIOList&); - - void operator=(const List&); - - - // IOstream operators - - //- Read List from Istream, discarding contents of existing List. - friend Istream& operator>> - ( - Istream&, - CompactIOList& - ); - - // Write List to Ostream. - friend Ostream& operator<< - ( - Ostream&, - const CompactIOList& - ); }; diff --git a/src/OpenFOAM/meshes/meshShapes/face/faceIOList.H b/src/OpenFOAM/meshes/meshShapes/face/faceIOList.H index 5d91c7dd9c..cba62b3c2f 100644 --- a/src/OpenFOAM/meshes/meshShapes/face/faceIOList.H +++ b/src/OpenFOAM/meshes/meshShapes/face/faceIOList.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -33,6 +33,7 @@ Description #define faceIOList_H #include "face.H" +#include "IOList.H" #include "CompactIOList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //