# PhasicFlow: src/phasicFlow/streams/Fstream/fileStream.hpp Source File

fileStream.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.
-----------------------------------------------------------------------------*/
// based on OpenFOAM stream, with some modifications/simplifications
// to be tailored to our needs
#ifndef __fileStream_hpp__
#define __fileStream_hpp__
#include <fstream>
#include "fileSystem.hpp"
#include "uniquePtr.hpp"
namespace pFlow
{
class fileStream
{
protected:
// - in file stream
uniquePtr<std::ifstream> inStream_;
// - out file stream
uniquePtr<std::ofstream> outStream_;
// - open input file
void openInFile(const fileSystem& path);
// - open output file
void openOutFile(const fileSystem& path);
// - close streams
void close();
public:
// - Constructors
fileStream( const fileSystem& path, bool outStream = false);
fileStream(const fileStream&)= delete;
fileStream& operator=(const fileStream&)=delete;
virtual ~fileStream()
{
close();
}
// - access
std::ifstream& inStream();
std::ofstream& outStream();
};
}
#endif
pFlow::fileStream::outStream_
uniquePtr< std::ofstream > outStream_
Definition: fileStream.hpp:44
pFlow::fileStream::openInFile
void openInFile(const fileSystem &path)
Definition: fileStream.cpp:30
pFlow::fileStream::fileStream
fileStream(const fileSystem &path, bool outStream=false)
Definition: fileStream.cpp:93
pFlow::fileStream::close
void close()
Definition: fileStream.cpp:79
pFlow::fileStream::operator=
fileStream & operator=(const fileStream &)=delete
pFlow::fileStream::~fileStream
virtual ~fileStream()
Definition: fileStream.hpp:65
fileSystem.hpp
pFlow
Definition: demComponent.hpp:28
pFlow::fileSystem
Definition: fileSystem.hpp:63
pFlow::fileStream::outStream
std::ofstream & outStream()
Definition: fileStream.cpp:117
uniquePtr.hpp
pFlow::fileStream::inStream_
uniquePtr< std::ifstream > inStream_
Definition: fileStream.hpp:41
pFlow::fileStream
Definition: fileStream.hpp:36
pFlow::uniquePtr< std::ifstream >
pFlow::fileStream::openOutFile
void openOutFile(const fileSystem &path)
Definition: fileStream.cpp:56
pFlow::fileStream::inStream
std::ifstream & inStream()
Definition: fileStream.cpp:112