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
|
||||
|
||||
//- 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
|
||||
|
||||
@ -29,41 +29,15 @@ License
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::IOField<Type>::IOField
|
||||
(
|
||||
const IOobject& io
|
||||
)
|
||||
Foam::IOField<Type>::IOField(const IOobject& io)
|
||||
:
|
||||
regIOobject(io),
|
||||
Field<Type>(readStream(typeName))
|
||||
regIOobject(io)
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::IOField<Type>::IOField
|
||||
(
|
||||
const IOobject& io,
|
||||
const label size
|
||||
)
|
||||
:
|
||||
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())
|
||||
if
|
||||
(
|
||||
io.readOpt() == IOobject::MUST_READ
|
||||
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
|
||||
)
|
||||
{
|
||||
readStream(typeName) >> *this;
|
||||
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 * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
Foam::IOField<T>::~IOField()
|
||||
template<class Type>
|
||||
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
|
||||
|
||||
//- Construct from IOobject
|
||||
IOField
|
||||
(
|
||||
const IOobject&
|
||||
);
|
||||
IOField(const IOobject&);
|
||||
|
||||
//- Construct from components
|
||||
IOField
|
||||
(
|
||||
const IOobject&,
|
||||
const Field<Type>&
|
||||
);
|
||||
IOField(const IOobject&, const Field<Type>&);
|
||||
|
||||
//- 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<const Field<Type>&>(*this)).good();
|
||||
}
|
||||
bool writeData(Ostream&) const;
|
||||
|
||||
|
||||
// Member operators
|
||||
|
||||
void operator=(const IOField<Type>& iof)
|
||||
{
|
||||
Field<Type>::operator=(iof);
|
||||
}
|
||||
void operator=(const IOField<Type>&);
|
||||
|
||||
void operator=(const Field<Type>& f)
|
||||
{
|
||||
Field<Type>::operator=(f);
|
||||
}
|
||||
void operator=(const Field<Type>&);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -84,7 +84,6 @@ Foam::IOList<T>::IOList(const IOobject& io, const List<T>& 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 * * * * * * * * * * * * * //
|
||||
|
||||
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>
|
||||
Foam::IOMap<T>::IOMap(const IOobject& io)
|
||||
:
|
||||
regIOobject(io),
|
||||
Map<T>()
|
||||
regIOobject(io)
|
||||
{
|
||||
if
|
||||
(
|
||||
|
||||
@ -91,14 +91,7 @@ Foam::IOPtrList<T>::~IOPtrList()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
void Foam::IOPtrList<T>::operator=(const IOPtrList<T>& rhs)
|
||||
{
|
||||
PtrList<T>::operator=(rhs);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
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 * * * * * * * * * * * * * * //
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
Reference in New Issue
Block a user