# PhasicFlow: src/phasicFlow/repository/IOobject/IOfileHeader.hpp Source File

IOfileHeader.hpp
Go to the documentation of this file.
/*------------------------------- phasicFlow ---------------------------------
O C enter of
O O E ngineering and
O O M ultiscale modeling of
OOOOOOO F luid flow
------------------------------------------------------------------------------
Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------
Licence:
This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------------------------------------------------------------------------*/
#ifndef __IOfileHeader_hpp__
#define __IOfileHeader_hpp__
#include "uniquePtr.hpp"
#include "objectFile.hpp"
#include "streams.hpp"
namespace pFlow
{
class repository;
class IOfileHeader
:
public objectFile
{
protected:
// owner repository
const repository* owner_ = nullptr;
// object name read from file
word objectName_;
// object type read from file
word objectType_;
// - input file stream
uniquePtr<iFstream> inStream()const;
// - ouput file stream
uniquePtr<oFstream> outStream()const;
public:
// with owner
IOfileHeader(const objectFile& objf, const repository* owner = nullptr);
// - object name
const word& objectName()const
{
return objectName_;
}
// - object type
const word& objectType()const
{
return objectType_;
}
// - pointer to owner repository
const repository* owner()const
{
return owner_;
}
// - path to file name
fileSystem path() const;
// - should be used for read operations
// check if the file exist,
// read the header of the file to check if it is ok
bool headerOk(bool silent = false);
// - imply read
bool implyRead() const;
// - imply write
bool implyWrite() const;
// - check if file exists
bool fileExist() const;
// - check read if present
bool readIfPresent()const;
// - write the header in the file , typeName comes from caller
bool writeHeader(iOstream& os, const word& typeName) const;
// - write the header in the file, typeName comes from the one read from file
bool writeHeader(iOstream& os) const;
// - read the header in the file
bool readHeader(iIstream& is, bool silent=false);
// - write the banner
bool writeBanner(iOstream& os)const;
// - wirte a separator line
bool writeSeparator(iOstream& os)const;
};
}
#endif //__objectFile_hpp__
pFlow::IOfileHeader::objectType
const word & objectType() const
Definition: IOfileHeader.hpp:72
pFlow::IOfileHeader::readIfPresent
bool readIfPresent() const
Definition: IOfileHeader.cpp:116
pFlow::IOfileHeader::objectType_
word objectType_
Definition: IOfileHeader.hpp:50
pFlow::IOfileHeader::readHeader
bool readHeader(iIstream &is, bool silent=false)
Definition: IOfileHeader.cpp:142
pFlow::IOfileHeader::fileExist
bool fileExist() const
Definition: IOfileHeader.cpp:111
pFlow::word
std::string word
Definition: builtinTypes.hpp:63
pFlow
Definition: demComponent.hpp:28
pFlow::fileSystem
Definition: fileSystem.hpp:63
pFlow::IOfileHeader::owner_
const repository * owner_
Definition: IOfileHeader.hpp:44
uniquePtr.hpp
pFlow::IOfileHeader::outStream
uniquePtr< oFstream > outStream() const
Definition: IOfileHeader.cpp:32
pFlow::iIstream
Definition: iIstream.hpp:33
pFlow::IOfileHeader::writeHeader
bool writeHeader(iOstream &os, const word &typeName) const
Definition: IOfileHeader.cpp:122
pFlow::IOfileHeader::path
fileSystem path() const
Definition: IOfileHeader.cpp:55
pFlow::IOfileHeader::IOfileHeader
IOfileHeader(const objectFile &objf, const repository *owner=nullptr)
Definition: IOfileHeader.cpp:46
pFlow::IOfileHeader::objectName_
word objectName_
Definition: IOfileHeader.hpp:47
pFlow::IOfileHeader::owner
const repository * owner() const
Definition: IOfileHeader.hpp:78
pFlow::objectFile
Definition: objectFile.hpp:33
objectFile.hpp
streams.hpp
pFlow::IOfileHeader::inStream
uniquePtr< iFstream > inStream() const
Definition: IOfileHeader.cpp:24
pFlow::IOfileHeader::implyRead
bool implyRead() const
Definition: IOfileHeader.cpp:100
pFlow::IOfileHeader
Definition: IOfileHeader.hpp:35
pFlow::IOfileHeader::writeSeparator
bool writeSeparator(iOstream &os) const
Definition: IOfileHeader.cpp:181
pFlow::IOfileHeader::headerOk
bool headerOk(bool silent=false)
Definition: IOfileHeader.cpp:71
pFlow::uniquePtr
Definition: uniquePtr.hpp:44
pFlow::IOfileHeader::objectName
const word & objectName() const
Definition: IOfileHeader.hpp:66
pFlow::repository
Definition: repository.hpp:34
pFlow::IOfileHeader::implyWrite
bool implyWrite() const
Definition: IOfileHeader.cpp:106
pFlow::iOstream
Definition: iOstream.hpp:53
pFlow::IOfileHeader::writeBanner
bool writeBanner(iOstream &os) const
Definition: IOfileHeader.cpp:170