diff --git a/src/OpenFOAM/db/IOobject/IOobject.H b/src/OpenFOAM/db/IOobject/IOobject.H index 5046b21555..ff1e8b6296 100644 --- a/src/OpenFOAM/db/IOobject/IOobject.H +++ b/src/OpenFOAM/db/IOobject/IOobject.H @@ -155,7 +155,7 @@ protected: // Protected member functions //- Construct and return an IFstream for the object. - // The results is NULL if the stream constuction failed + // The results is NULL if the stream construction failed Istream* objectStream(); //- Set the object state to bad diff --git a/src/OpenFOAM/db/IOobjects/IOField/IOField.C b/src/OpenFOAM/db/IOobjects/IOField/IOField.C index 85ccd83d0e..973f7de1c1 100644 --- a/src/OpenFOAM/db/IOobjects/IOField/IOField.C +++ b/src/OpenFOAM/db/IOobjects/IOField/IOField.C @@ -29,41 +29,15 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template -Foam::IOField::IOField -( - const IOobject& io -) +Foam::IOField::IOField(const IOobject& io) : - regIOobject(io), - Field(readStream(typeName)) + regIOobject(io) { - close(); -} - - -template -Foam::IOField::IOField -( - const IOobject& io, - const label size -) -: - regIOobject(io), - Field(size) -{} - - -template -Foam::IOField::IOField -( - const IOobject& io, - const Field& f -) -: - regIOobject(io), - Field(f) -{ - if (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk()) + if + ( + io.readOpt() == IOobject::MUST_READ + || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk()) + ) { readStream(typeName) >> *this; close(); @@ -71,11 +45,77 @@ Foam::IOField::IOField } +template +Foam::IOField::IOField(const IOobject& io, const label size) +: + regIOobject(io) +{ + if + ( + io.readOpt() == IOobject::MUST_READ + || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk()) + ) + { + readStream(typeName) >> *this; + close(); + } + else + { + Field::setSize(size); + } +} + + +template +Foam::IOField::IOField(const IOobject& io, const Field& f) +: + regIOobject(io) +{ + if + ( + io.readOpt() == IOobject::MUST_READ + || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk()) + ) + { + readStream(typeName) >> *this; + close(); + } + else + { + Field::operator=(f); + } +} + + // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * // -template -Foam::IOField::~IOField() +template +Foam::IOField::~IOField() {} +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +bool Foam::IOField::writeData(Ostream& os) const +{ + return (os << static_cast&>(*this)).good(); +} + + +// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // + +template +void Foam::IOField::operator=(const IOField& rhs) +{ + Field::operator=(rhs); +} + + +template +void Foam::IOField::operator=(const Field& rhs) +{ + Field::operator=(rhs); +} + // ************************************************************************* // diff --git a/src/OpenFOAM/db/IOobjects/IOField/IOField.H b/src/OpenFOAM/db/IOobjects/IOField/IOField.H index 3da97e2009..e42cca65db 100644 --- a/src/OpenFOAM/db/IOobjects/IOField/IOField.H +++ b/src/OpenFOAM/db/IOobjects/IOField/IOField.H @@ -63,24 +63,13 @@ public: // Constructors //- Construct from IOobject - IOField - ( - const IOobject& - ); + IOField(const IOobject&); //- Construct from components - IOField - ( - const IOobject&, - const Field& - ); + IOField(const IOobject&, const Field&); //- Construct from IOobject and size (does not set values) - IOField - ( - const IOobject&, - const label size - ); + IOField(const IOobject&, const label size); // Destructor @@ -90,23 +79,14 @@ public: // Member functions - bool writeData(Ostream& os) const - { - return (os << static_cast&>(*this)).good(); - } + bool writeData(Ostream&) const; // Member operators - void operator=(const IOField& iof) - { - Field::operator=(iof); - } + void operator=(const IOField&); - void operator=(const Field& f) - { - Field::operator=(f); - } + void operator=(const Field&); }; diff --git a/src/OpenFOAM/db/IOobjects/IOList/IOList.C b/src/OpenFOAM/db/IOobjects/IOList/IOList.C index 5c55da8399..11a80cbb2c 100644 --- a/src/OpenFOAM/db/IOobjects/IOList/IOList.C +++ b/src/OpenFOAM/db/IOobjects/IOList/IOList.C @@ -84,7 +84,6 @@ Foam::IOList::IOList(const IOobject& io, const List& list) { List::operator=(list); } - } @@ -95,6 +94,16 @@ Foam::IOList::~IOList() {} + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +bool Foam::IOList::writeData(Ostream& os) const +{ + return (os << *this).good(); +} + + // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template @@ -111,11 +120,4 @@ void Foam::IOList::operator=(const List& rhs) } -template -bool Foam::IOList::writeData(Ostream& os) const -{ - return (os << *this).good(); -} - - // ************************************************************************* // diff --git a/src/OpenFOAM/db/IOobjects/IOMap/IOMap.C b/src/OpenFOAM/db/IOobjects/IOMap/IOMap.C index 62a9523a5b..dffbda46d6 100644 --- a/src/OpenFOAM/db/IOobjects/IOMap/IOMap.C +++ b/src/OpenFOAM/db/IOobjects/IOMap/IOMap.C @@ -31,8 +31,7 @@ License template Foam::IOMap::IOMap(const IOobject& io) : - regIOobject(io), - Map() + regIOobject(io) { if ( diff --git a/src/OpenFOAM/db/IOobjects/IOPtrList/IOPtrList.C b/src/OpenFOAM/db/IOobjects/IOPtrList/IOPtrList.C index d42634dae6..e6fae97c27 100644 --- a/src/OpenFOAM/db/IOobjects/IOPtrList/IOPtrList.C +++ b/src/OpenFOAM/db/IOobjects/IOPtrList/IOPtrList.C @@ -91,14 +91,7 @@ Foam::IOPtrList::~IOPtrList() {} -// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // - -template -void Foam::IOPtrList::operator=(const IOPtrList& rhs) -{ - PtrList::operator=(rhs); -} - +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template bool Foam::IOPtrList::writeData(Ostream& os) const @@ -107,4 +100,12 @@ bool Foam::IOPtrList::writeData(Ostream& os) const } +// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // + +template +void Foam::IOPtrList::operator=(const IOPtrList& rhs) +{ + PtrList::operator=(rhs); +} + // ************************************************************************* // diff --git a/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionary.C b/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionary.C index 221496165a..33ff91412c 100644 --- a/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionary.C +++ b/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionary.C @@ -42,15 +42,10 @@ namespace Foam // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::IOdictionary::IOdictionary -( - const IOobject& io -) +Foam::IOdictionary::IOdictionary(const IOobject& io) : regIOobject(io) { - dictionary::name() = IOobject::objectPath(); - if ( io.readOpt() == IOobject::MUST_READ @@ -60,18 +55,29 @@ Foam::IOdictionary::IOdictionary readStream(typeName) >> *this; close(); } + + dictionary::name() = IOobject::objectPath(); } -Foam::IOdictionary::IOdictionary -( - const IOobject& io, - const dictionary& dict -) +Foam::IOdictionary::IOdictionary(const IOobject& io, const dictionary& dict) : - regIOobject(io), - dictionary(dict) + regIOobject(io) { + if + ( + io.readOpt() == IOobject::MUST_READ + || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk()) + ) + { + readStream(typeName) >> *this; + close(); + } + else + { + dictionary::operator=(dict); + } + dictionary::name() = IOobject::objectPath(); } @@ -92,9 +98,9 @@ const Foam::word& Foam::IOdictionary::name() const // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // -void Foam::IOdictionary::operator=(const IOdictionary& d) +void Foam::IOdictionary::operator=(const IOdictionary& rhs) { - dictionary::operator=(d); + dictionary::operator=(rhs); } diff --git a/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionaryIO.C b/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionaryIO.C index 633ed3c7e9..2e861ac34c 100644 --- a/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionaryIO.C +++ b/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionaryIO.C @@ -34,27 +34,17 @@ Description // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -namespace Foam -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -bool IOdictionary::readData(Istream& is) +bool Foam::IOdictionary::readData(Istream& is) { is >> *this; return !is.bad(); } -bool IOdictionary::writeData(Ostream& os) const +bool Foam::IOdictionary::writeData(Ostream& os) const { dictionary::write(os, false); return os.good(); } - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* //