mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
IOobjects - consistency fixes
- consistent constructors and consistent behaviour with MUST_READ,
READ_IF_PRESENT
This commit is contained in:
@ -155,7 +155,7 @@ protected:
|
|||||||
// Protected member functions
|
// Protected member functions
|
||||||
|
|
||||||
//- Construct and return an IFstream for the object.
|
//- 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();
|
Istream* objectStream();
|
||||||
|
|
||||||
//- Set the object state to bad
|
//- Set the object state to bad
|
||||||
|
|||||||
@ -29,41 +29,15 @@ License
|
|||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
Foam::IOField<Type>::IOField
|
Foam::IOField<Type>::IOField(const IOobject& io)
|
||||||
(
|
|
||||||
const IOobject& io
|
|
||||||
)
|
|
||||||
:
|
:
|
||||||
regIOobject(io),
|
regIOobject(io)
|
||||||
Field<Type>(readStream(typeName))
|
|
||||||
{
|
{
|
||||||
close();
|
if
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
Foam::IOField<Type>::IOField
|
|
||||||
(
|
(
|
||||||
const IOobject& io,
|
io.readOpt() == IOobject::MUST_READ
|
||||||
const label size
|
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
|
||||||
)
|
)
|
||||||
:
|
|
||||||
regIOobject(io),
|
|
||||||
Field<Type>(size)
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
Foam::IOField<Type>::IOField
|
|
||||||
(
|
|
||||||
const IOobject& io,
|
|
||||||
const Field<Type>& f
|
|
||||||
)
|
|
||||||
:
|
|
||||||
regIOobject(io),
|
|
||||||
Field<Type>(f)
|
|
||||||
{
|
|
||||||
if (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
|
|
||||||
{
|
{
|
||||||
readStream(typeName) >> *this;
|
readStream(typeName) >> *this;
|
||||||
close();
|
close();
|
||||||
@ -71,11 +45,77 @@ Foam::IOField<Type>::IOField
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::IOField<Type>::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<Type>::setSize(size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::IOField<Type>::IOField(const IOobject& io, const Field<Type>& f)
|
||||||
|
:
|
||||||
|
regIOobject(io)
|
||||||
|
{
|
||||||
|
if
|
||||||
|
(
|
||||||
|
io.readOpt() == IOobject::MUST_READ
|
||||||
|
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
|
||||||
|
)
|
||||||
|
{
|
||||||
|
readStream(typeName) >> *this;
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Field<Type>::operator=(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
template<class Type>
|
||||||
Foam::IOField<T>::~IOField()
|
Foam::IOField<Type>::~IOField()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
bool Foam::IOField<Type>::writeData(Ostream& os) const
|
||||||
|
{
|
||||||
|
return (os << static_cast<const Field<Type>&>(*this)).good();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::IOField<Type>::operator=(const IOField<Type>& rhs)
|
||||||
|
{
|
||||||
|
Field<Type>::operator=(rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::IOField<Type>::operator=(const Field<Type>& rhs)
|
||||||
|
{
|
||||||
|
Field<Type>::operator=(rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -63,24 +63,13 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from IOobject
|
//- Construct from IOobject
|
||||||
IOField
|
IOField(const IOobject&);
|
||||||
(
|
|
||||||
const IOobject&
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Construct from components
|
//- Construct from components
|
||||||
IOField
|
IOField(const IOobject&, const Field<Type>&);
|
||||||
(
|
|
||||||
const IOobject&,
|
|
||||||
const Field<Type>&
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Construct from IOobject and size (does not set values)
|
//- Construct from IOobject and size (does not set values)
|
||||||
IOField
|
IOField(const IOobject&, const label size);
|
||||||
(
|
|
||||||
const IOobject&,
|
|
||||||
const label size
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
@ -90,23 +79,14 @@ public:
|
|||||||
|
|
||||||
// Member functions
|
// Member functions
|
||||||
|
|
||||||
bool writeData(Ostream& os) const
|
bool writeData(Ostream&) const;
|
||||||
{
|
|
||||||
return (os << static_cast<const Field<Type>&>(*this)).good();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Member operators
|
// Member operators
|
||||||
|
|
||||||
void operator=(const IOField<Type>& iof)
|
void operator=(const IOField<Type>&);
|
||||||
{
|
|
||||||
Field<Type>::operator=(iof);
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator=(const Field<Type>& f)
|
void operator=(const Field<Type>&);
|
||||||
{
|
|
||||||
Field<Type>::operator=(f);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -84,7 +84,6 @@ Foam::IOList<T>::IOList(const IOobject& io, const List<T>& list)
|
|||||||
{
|
{
|
||||||
List<T>::operator=(list);
|
List<T>::operator=(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -95,6 +94,16 @@ Foam::IOList<T>::~IOList()
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
bool Foam::IOList<T>::writeData(Ostream& os) const
|
||||||
|
{
|
||||||
|
return (os << *this).good();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
@ -111,11 +120,4 @@ void Foam::IOList<T>::operator=(const List<T>& rhs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
bool Foam::IOList<T>::writeData(Ostream& os) const
|
|
||||||
{
|
|
||||||
return (os << *this).good();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -31,8 +31,7 @@ License
|
|||||||
template<class T>
|
template<class T>
|
||||||
Foam::IOMap<T>::IOMap(const IOobject& io)
|
Foam::IOMap<T>::IOMap(const IOobject& io)
|
||||||
:
|
:
|
||||||
regIOobject(io),
|
regIOobject(io)
|
||||||
Map<T>()
|
|
||||||
{
|
{
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
|
|||||||
@ -91,14 +91,7 @@ Foam::IOPtrList<T>::~IOPtrList()
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
|
||||||
void Foam::IOPtrList<T>::operator=(const IOPtrList<T>& rhs)
|
|
||||||
{
|
|
||||||
PtrList<T>::operator=(rhs);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
bool Foam::IOPtrList<T>::writeData(Ostream& os) const
|
bool Foam::IOPtrList<T>::writeData(Ostream& os) const
|
||||||
@ -107,4 +100,12 @@ bool Foam::IOPtrList<T>::writeData(Ostream& os) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void Foam::IOPtrList<T>::operator=(const IOPtrList<T>& rhs)
|
||||||
|
{
|
||||||
|
PtrList<T>::operator=(rhs);
|
||||||
|
}
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -42,15 +42,10 @@ namespace Foam
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::IOdictionary::IOdictionary
|
Foam::IOdictionary::IOdictionary(const IOobject& io)
|
||||||
(
|
|
||||||
const IOobject& io
|
|
||||||
)
|
|
||||||
:
|
:
|
||||||
regIOobject(io)
|
regIOobject(io)
|
||||||
{
|
{
|
||||||
dictionary::name() = IOobject::objectPath();
|
|
||||||
|
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
io.readOpt() == IOobject::MUST_READ
|
io.readOpt() == IOobject::MUST_READ
|
||||||
@ -60,18 +55,29 @@ Foam::IOdictionary::IOdictionary
|
|||||||
readStream(typeName) >> *this;
|
readStream(typeName) >> *this;
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dictionary::name() = IOobject::objectPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::IOdictionary::IOdictionary
|
Foam::IOdictionary::IOdictionary(const IOobject& io, const dictionary& dict)
|
||||||
(
|
|
||||||
const IOobject& io,
|
|
||||||
const dictionary& dict
|
|
||||||
)
|
|
||||||
:
|
:
|
||||||
regIOobject(io),
|
regIOobject(io)
|
||||||
dictionary(dict)
|
|
||||||
{
|
{
|
||||||
|
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();
|
dictionary::name() = IOobject::objectPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,9 +98,9 @@ const Foam::word& Foam::IOdictionary::name() const
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::IOdictionary::operator=(const IOdictionary& d)
|
void Foam::IOdictionary::operator=(const IOdictionary& rhs)
|
||||||
{
|
{
|
||||||
dictionary::operator=(d);
|
dictionary::operator=(rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -34,27 +34,17 @@ Description
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
bool Foam::IOdictionary::readData(Istream& is)
|
||||||
{
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
bool IOdictionary::readData(Istream& is)
|
|
||||||
{
|
{
|
||||||
is >> *this;
|
is >> *this;
|
||||||
return !is.bad();
|
return !is.bad();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool IOdictionary::writeData(Ostream& os) const
|
bool Foam::IOdictionary::writeData(Ostream& os) const
|
||||||
{
|
{
|
||||||
dictionary::write(os, false);
|
dictionary::write(os, false);
|
||||||
return os.good();
|
return os.good();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
Reference in New Issue
Block a user