fileStream.hpp
Go to the documentation of this file.
1 /*------------------------------- phasicFlow ---------------------------------
2  O C enter of
3  O O E ngineering and
4  O O M ultiscale modeling of
5  OOOOOOO F luid flow
6 ------------------------------------------------------------------------------
7  Copyright (C): www.cemf.ir
8  email: hamid.r.norouzi AT gmail.com
9 ------------------------------------------------------------------------------
10 Licence:
11  This file is part of phasicFlow code. It is a free software for simulating
12  granular and multiphase flows. You can redistribute it and/or modify it under
13  the terms of GNU General Public License v3 or any other later versions.
14 
15  phasicFlow is distributed to help others in their research in the field of
16  granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 
19 -----------------------------------------------------------------------------*/
20 // based on OpenFOAM stream, with some modifications/simplifications
21 // to be tailored to our needs
22 
23 
24 #ifndef __fileStream_hpp__
25 #define __fileStream_hpp__
26 
27 
28 #include <fstream>
29 
30 #include "fileSystem.hpp"
31 #include "uniquePtr.hpp"
32 
33 namespace pFlow
34 {
35 
37 {
38 protected:
39 
40  // - in file stream
42 
43  // - out file stream
45 
46  // - open input file
47  void openInFile(const fileSystem& path);
48 
49  // - open output file
50  void openOutFile(const fileSystem& path);
51 
52  // - close streams
53  void close();
54 
55 public:
56 
57  // - Constructors
58 
59  fileStream( const fileSystem& path, bool outStream = false);
60 
61  fileStream(const fileStream&)= delete;
62 
63  fileStream& operator=(const fileStream&)=delete;
64 
65  virtual ~fileStream()
66  {
67  close();
68  }
69 
70 
71  // - access
72 
73  std::ifstream& inStream();
74 
75  std::ofstream& outStream();
76 
77 };
78 
79 }
80 
81 #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