From d362c2235b8b6b550a6647c9ee3d9eb19f90a174 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 24 Jul 2018 09:23:46 +0200 Subject: [PATCH] COMP/STYLE: change read() -> readIstream() for private methods - this eliminates a degree of ambiguity when resolving a read() method in inherited classes. --- .../DictionaryBase/DictionaryBase.H | 20 ++++----- .../PtrDictionary/PtrDictionary.C | 2 - .../PtrDictionary/PtrDictionary.H | 6 +-- .../PtrListDictionary/PtrListDictionary.H | 6 +-- .../HashTables/HashPtrTable/HashPtrTable.H | 6 +-- .../HashTables/HashPtrTable/HashPtrTableIO.C | 18 ++++---- .../LinkedLists/accessTypes/ILList/ILList.H | 6 +-- .../LinkedLists/accessTypes/ILList/ILListIO.C | 32 +++++++++----- .../accessTypes/LPtrList/LPtrList.H | 12 +++--- .../accessTypes/LPtrList/LPtrListIO.C | 42 +++++++++++++------ .../containers/PtrLists/PtrList/PtrList.H | 4 +- .../containers/PtrLists/PtrList/PtrListIO.C | 14 +++---- .../db/IOobjects/IOPtrList/IOPtrList.C | 8 ++-- src/OpenFOAM/db/IOstreams/IOstreams/INew.H | 11 +++-- 14 files changed, 108 insertions(+), 79 deletions(-) diff --git a/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.H b/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.H index 8c48737427..001e7d7951 100644 --- a/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.H +++ b/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.H @@ -56,7 +56,7 @@ SourceFiles namespace Foam { -// Forward declaration of friend functions and operators +// Forward declarations template class DictionaryBase; @@ -96,34 +96,34 @@ public: DictionaryBase(const label size = 128); //- Copy construct - DictionaryBase(const DictionaryBase&); + DictionaryBase(const DictionaryBase& dict); //- Construct from Istream using given Istream constructor class template - DictionaryBase(Istream&, const INew&); + DictionaryBase(Istream& is, const INew& inew); //- Construct from Istream using default Istream constructor class - DictionaryBase(Istream&); + DictionaryBase(Istream& is); // Member functions // Search and lookup - //- Search DictionaryBase for given keyword - bool found(const word&) const; + //- Search for given keyword + bool found(const word& keyword) const; //- Find and return an entry if present, otherwise return nullptr - const T* lookupPtr(const word&) const; + const T* lookupPtr(const word& keyword) const; //- Find and return an entry if present, otherwise return nullptr - T* lookupPtr(const word&); + T* lookupPtr(const word& keyword); //- Find and return entry - const T* lookup(const word&) const; + const T* lookup(const word& keyword) const; //- Find and return entry - T* lookup(const word&); + T* lookup(const word& keyword); //- Return the table of contents wordList toc() const; diff --git a/src/OpenFOAM/containers/Dictionaries/PtrDictionary/PtrDictionary.C b/src/OpenFOAM/containers/Dictionaries/PtrDictionary/PtrDictionary.C index bdd9e5fbc8..f297fbbca8 100644 --- a/src/OpenFOAM/containers/Dictionaries/PtrDictionary/PtrDictionary.C +++ b/src/OpenFOAM/containers/Dictionaries/PtrDictionary/PtrDictionary.C @@ -56,6 +56,4 @@ Foam::PtrDictionary::PtrDictionary(Istream& is) {} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - // ************************************************************************* // diff --git a/src/OpenFOAM/containers/Dictionaries/PtrDictionary/PtrDictionary.H b/src/OpenFOAM/containers/Dictionaries/PtrDictionary/PtrDictionary.H index 974a967890..4fb7d1a674 100644 --- a/src/OpenFOAM/containers/Dictionaries/PtrDictionary/PtrDictionary.H +++ b/src/OpenFOAM/containers/Dictionaries/PtrDictionary/PtrDictionary.H @@ -64,14 +64,14 @@ public: PtrDictionary(const label size = 128); //- Copy construct - PtrDictionary(const PtrDictionary&); + PtrDictionary(const PtrDictionary& dict); //- Construct from Istream using given Istream constructor class template - PtrDictionary(Istream&, const INew&); + PtrDictionary(Istream& is, const INew& inew); //- Construct from Istream - PtrDictionary(Istream&); + PtrDictionary(Istream& is); // Member operators diff --git a/src/OpenFOAM/containers/Dictionaries/PtrListDictionary/PtrListDictionary.H b/src/OpenFOAM/containers/Dictionaries/PtrListDictionary/PtrListDictionary.H index ab45e2c491..618363380a 100644 --- a/src/OpenFOAM/containers/Dictionaries/PtrListDictionary/PtrListDictionary.H +++ b/src/OpenFOAM/containers/Dictionaries/PtrListDictionary/PtrListDictionary.H @@ -64,14 +64,14 @@ public: PtrListDictionary(const label size); //- Copy construct - PtrListDictionary(const PtrListDictionary&); + PtrListDictionary(const PtrListDictionary& dict); //- Construct from Istream using given Istream constructor class template - PtrListDictionary(Istream&, const INew&); + PtrListDictionary(Istream& is, const INew& inew); //- Construct from Istream - PtrListDictionary(Istream&); + PtrListDictionary(Istream& is); // Member functions diff --git a/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTable.H b/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTable.H index 990e8537c2..655c715c5e 100644 --- a/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTable.H +++ b/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTable.H @@ -69,11 +69,11 @@ class HashPtrTable { // Private Member Functions - //- Read from Istream using given Istream constructor class + //- Read from Istream using Istream constructor class template - void read(Istream& is, const INew& inew); + void readIstream(Istream& is, const INew& inew); - //- Read from dictionary using given dictionary constructor class + //- Read from dictionary using Istream constructor class template void read(const dictionary& dict, const INew& inew); diff --git a/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTableIO.C b/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTableIO.C index fb123d50da..1ee34afb0e 100644 --- a/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTableIO.C +++ b/src/OpenFOAM/containers/HashTables/HashPtrTable/HashPtrTableIO.C @@ -33,7 +33,11 @@ License template template -void Foam::HashPtrTable::read(Istream& is, const INew& inew) +void Foam::HashPtrTable::readIstream +( + Istream& is, + const INew& inew +) { is.fatalCheck(FUNCTION_NAME); @@ -41,7 +45,7 @@ void Foam::HashPtrTable::read(Istream& is, const INew& inew) is.fatalCheck ( - "HashPtrTable::read(Istream&, const INew&) : " + "HashPtrTable::readIstream : " "reading first token" ); @@ -69,7 +73,7 @@ void Foam::HashPtrTable::read(Istream& is, const INew& inew) is.fatalCheck ( - "HashPtrTable::read(Istream&, const INew&) : " + "HashPtrTable::readIstream : " "reading entry" ); } @@ -114,7 +118,7 @@ void Foam::HashPtrTable::read(Istream& is, const INew& inew) is.fatalCheck ( - "HashPtrTable::read(Istream&, const INew&) : " + "HashPtrTable::readIstream : " "reading entry" ); @@ -172,14 +176,14 @@ template template Foam::HashPtrTable::HashPtrTable(Istream& is, const INew& inew) { - this->read(is, inew); + this->readIstream(is, inew); } template Foam::HashPtrTable::HashPtrTable(Istream& is) { - this->read(is, INew()); + this->readIstream(is, INew()); } @@ -196,7 +200,7 @@ template Foam::Istream& Foam::operator>>(Istream& is, HashPtrTable& tbl) { tbl.clear(); - tbl.read(is, INew()); + tbl.readIstream(is, INew()); return is; } diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILList.H b/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILList.H index d4a9e5c50d..5b6b7850d2 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILList.H +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILList.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -69,7 +69,7 @@ class ILList //- Read from Istream using given Istream constructor class template - void read(Istream& is, const INew& inew); + void readIstream(Istream& is, const INew& inew); public: @@ -138,7 +138,7 @@ public: friend Istream& operator>> ( Istream& is, - ILList& lst + ILList& list ); }; diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILListIO.C b/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILListIO.C index 4312699f16..4d1a06d5ff 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILListIO.C +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILListIO.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -31,13 +31,17 @@ License template template -void Foam::ILList::read(Istream& is, const INew& inew) +void Foam::ILList::readIstream(Istream& is, const INew& inew) { is.fatalCheck(FUNCTION_NAME); token firstToken(is); - is.fatalCheck("ILList::readList : reading first token"); + is.fatalCheck + ( + "ILList::readIstream : " + "reading first token" + ); if (firstToken.isLabel()) { @@ -55,7 +59,11 @@ void Foam::ILList::read(Istream& is, const INew& inew) T* p = inew(is).ptr(); this->append(p); - is.fatalCheck("ILList::readList : reading entry"); + is.fatalCheck + ( + "ILList::readIstream : " + "reading entry" + ); } } else @@ -63,7 +71,11 @@ void Foam::ILList::read(Istream& is, const INew& inew) T* p = inew(is).ptr(); this->append(p); - is.fatalCheck("ILList::readList : reading entry"); + is.fatalCheck + ( + "ILList::readIstream : " + "reading the single entry" + ); for (label i=1; i template Foam::ILList::ILList(Istream& is, const INew& inew) { - this->read(is, inew); + this->readIstream(is, inew); } template Foam::ILList::ILList(Istream& is) { - this->read(is, INew()); + this->readIstream(is, INew()); } // * * * * * * * * * * * * * * * Istream Operator * * * * * * * * * * * * * // template -Foam::Istream& Foam::operator>>(Istream& is, ILList& lst) +Foam::Istream& Foam::operator>>(Istream& is, ILList& list) { - lst.clear(); - lst.read(is, INew()); + list.clear(); + list.readIstream(is, INew()); return is; } diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrList.H b/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrList.H index fa7312cbd5..4051e8f50f 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrList.H +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrList.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -51,14 +51,14 @@ template Istream& operator>> ( Istream& is, - LPtrList& lst + LPtrList& list ); template Ostream& operator<< ( Ostream& os, - const LPtrList& lst + const LPtrList& list ); @@ -77,7 +77,7 @@ private: //- Read from Istream using given Istream constructor class template - void read(Istream& is, const INew& inew); + void readIstream(Istream& is, const INew& inew); public: @@ -419,13 +419,13 @@ public: friend Istream& operator>> ( Istream& is, - LPtrList& lst + LPtrList& list ); friend Ostream& operator<< ( Ostream& os, - const LPtrList& lst + const LPtrList& list ); }; diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrListIO.C b/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrListIO.C index 0421dce84f..7ba2e1234d 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrListIO.C +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrListIO.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -32,13 +32,17 @@ License template template -void Foam::LPtrList::read(Istream& is, const INew& inew) +void Foam::LPtrList::readIstream(Istream& is, const INew& inew) { is.fatalCheck(FUNCTION_NAME); token firstToken(is); - is.fatalCheck("LPtrList::readList : reading first token"); + is.fatalCheck + ( + "LPtrList::readIstream : " + "reading first token" + ); if (firstToken.isLabel()) { @@ -56,7 +60,11 @@ void Foam::LPtrList::read(Istream& is, const INew& inew) T* p = inew(is).ptr(); this->append(p); - is.fatalCheck("LPtrList::readList : reading entry"); + is.fatalCheck + ( + "LPtrList::readIstream : " + "reading entry" + ); } } else @@ -64,7 +72,11 @@ void Foam::LPtrList::read(Istream& is, const INew& inew) T* p = inew(is).ptr(); this->append(p); - is.fatalCheck("LPtrList::readList : reading entry"); + is.fatalCheck + ( + "LPtrList::readIstream : " + "reading the single entry" + ); for (label i=1; i template Foam::LPtrList::LPtrList(Istream& is, const INew& inew) { - this->read(is, inew); + this->readIstream(is, inew); } template Foam::LPtrList::LPtrList(Istream& is) { - this->read(is, INew()); + this->readIstream(is, INew()); } // * * * * * * * * * * * * * * * Istream Operator * * * * * * * * * * * * * // template -Foam::Istream& Foam::operator>>(Istream& is, LPtrList& L) +Foam::Istream& Foam::operator>>(Istream& is, LPtrList& list) { - L.clear(); - L.read(is, INew()); + list.clear(); + list.readIstream(is, INew()); return is; } @@ -151,13 +163,17 @@ Foam::Istream& Foam::operator>>(Istream& is, LPtrList& L) // * * * * * * * * * * * * * * * Ostream Operators * * * * * * * * * * * * * // template -Foam::Ostream& Foam::operator<<(Ostream& os, const LPtrList& lst) +Foam::Ostream& Foam::operator<< +( + Ostream& os, + const LPtrList& list +) { // Size and start delimiter - os << nl << lst.size() << nl << token::BEGIN_LIST << nl; + os << nl << list.size() << nl << token::BEGIN_LIST << nl; // Contents - for (auto iter = lst.cbegin(); iter != lst.cend(); ++iter) + for (auto iter = list.cbegin(); iter != list.cend(); ++iter) { os << *iter << nl; } diff --git a/src/OpenFOAM/containers/PtrLists/PtrList/PtrList.H b/src/OpenFOAM/containers/PtrLists/PtrList/PtrList.H index 4ceda992a3..291fc65ff3 100644 --- a/src/OpenFOAM/containers/PtrLists/PtrList/PtrList.H +++ b/src/OpenFOAM/containers/PtrLists/PtrList/PtrList.H @@ -73,9 +73,9 @@ protected: // Protected Member Functions - //- Read from Istream using given Istream constructor class + //- Read from Istream using Istream constructor class template - void read(Istream& is, const INew& inew); + void readIstream(Istream& is, const INew& inew); //- Delete the allocated entries, but retain the list size. inline void free(); diff --git a/src/OpenFOAM/containers/PtrLists/PtrList/PtrListIO.C b/src/OpenFOAM/containers/PtrLists/PtrList/PtrListIO.C index be3da43435..7c1dd41dee 100644 --- a/src/OpenFOAM/containers/PtrLists/PtrList/PtrListIO.C +++ b/src/OpenFOAM/containers/PtrLists/PtrList/PtrListIO.C @@ -32,7 +32,7 @@ License template template -void Foam::PtrList::read(Istream& is, const INew& inew) +void Foam::PtrList::readIstream(Istream& is, const INew& inew) { clear(); // Delete old pointers and reset the list size @@ -42,7 +42,7 @@ void Foam::PtrList::read(Istream& is, const INew& inew) is.fatalCheck ( - "PtrList::read(Istream&) : " + "PtrList::readIstream : " "reading first token" ); @@ -70,7 +70,7 @@ void Foam::PtrList::read(Istream& is, const INew& inew) is.fatalCheck ( - "PtrList::read(Istream&) : " + "PtrList::readIstream : " "reading entry" ); } @@ -82,7 +82,7 @@ void Foam::PtrList::read(Istream& is, const INew& inew) is.fatalCheck ( - "PtrList::read(Istream&) : " + "PtrList::readIstream : " "reading the single entry" ); @@ -167,14 +167,14 @@ template template Foam::PtrList::PtrList(Istream& is, const INew& inew) { - read(is, inew); + this->readIstream(is, inew); } template Foam::PtrList::PtrList(Istream& is) { - read(is, INew()); + this->readIstream(is, INew()); } @@ -183,7 +183,7 @@ Foam::PtrList::PtrList(Istream& is) template Foam::Istream& Foam::operator>>(Istream& is, PtrList& list) { - list.read(is, INew()); + list.readIstream(is, INew()); return is; } diff --git a/src/OpenFOAM/db/IOobjects/IOPtrList/IOPtrList.C b/src/OpenFOAM/db/IOobjects/IOPtrList/IOPtrList.C index aa0bcbf30c..50258ac455 100644 --- a/src/OpenFOAM/db/IOobjects/IOPtrList/IOPtrList.C +++ b/src/OpenFOAM/db/IOobjects/IOPtrList/IOPtrList.C @@ -45,7 +45,7 @@ Foam::IOPtrList::IOPtrList(const IOobject& io, const INew& inewt) // For if MUST_READ_IF_MODIFIED addWatch(); - PtrList::read(readStream(typeName), inewt); + PtrList::readIstream(readStream(typeName), inewt); close(); } } @@ -68,7 +68,7 @@ Foam::IOPtrList::IOPtrList(const IOobject& io) // For if MUST_READ_IF_MODIFIED addWatch(); - PtrList::read(readStream(typeName), INew()); + PtrList::readIstream(readStream(typeName), INew()); close(); } } @@ -106,7 +106,7 @@ Foam::IOPtrList::IOPtrList(const IOobject& io, const PtrList& content) // For if MUST_READ_IF_MODIFIED addWatch(); - PtrList::read(readStream(typeName), INew()); + PtrList::readIstream(readStream(typeName), INew()); close(); } else @@ -135,7 +135,7 @@ Foam::IOPtrList::IOPtrList(const IOobject& io, PtrList&& content) // For if MUST_READ_IF_MODIFIED addWatch(); - PtrList::read(readStream(typeName), INew()); + PtrList::readIstream(readStream(typeName), INew()); close(); } } diff --git a/src/OpenFOAM/db/IOstreams/IOstreams/INew.H b/src/OpenFOAM/db/IOstreams/IOstreams/INew.H index 6270f238b2..bf901b21e6 100644 --- a/src/OpenFOAM/db/IOstreams/IOstreams/INew.H +++ b/src/OpenFOAM/db/IOstreams/IOstreams/INew.H @@ -39,7 +39,7 @@ Description namespace Foam { -// Forward declaration of classes +// Forward declarations class Istream; /*---------------------------------------------------------------------------*\ @@ -49,32 +49,31 @@ class Istream; template class INew { - public: //- Construct null INew() {} - //- Construct from Istream + //- New from Istream autoPtr operator()(Istream& is) const { return T::New(is); } - //- Construct from word and Istream + //- New from word (unused) and Istream autoPtr operator()(const word&, Istream& is) const { return T::New(is); } - //- Construct from dictionary + //- New from dictionary autoPtr operator()(const dictionary& dict) const { return T::New(dict); } - //- Construct from word and dictionary + //- New from word (unused) and dictionary autoPtr operator()(const word&, const dictionary& dict) const { return T::New(dict);