www.cemf.ir
IOfileHeader.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 
21 
22 #ifndef __IOfileHeader_hpp__
23 #define __IOfileHeader_hpp__
24 
25 
26 #include "uniquePtr.hpp"
27 #include "objectFile.hpp"
28 #include "streams.hpp"
29 
30 namespace pFlow
31 {
32 
33 class repository;
34 
36 :
37  public objectFile
38 {
39 protected:
40 
41 
43 
44  // object name read from file
46 
47  // object type read from file
49 
51  word fileFormat_ = "ASCII";
52 
54 
55  // - input file stream
57 
58  // - ouput file stream
60 
62 
63 public:
64 
65  // with owner
66  IOfileHeader(const objectFile& objf);
67 
68  // - object name
69  const word& objectName()const
70  {
71  return objectName_;
72  }
73 
74  // - object type
75  const word& objectType()const
76  {
77  return objectType_;
78  }
79 
80  // - pointer to owner repository
81  virtual
82  const repository* owner()const
83  {
84  return nullptr;
85  }
86 
87  virtual
88  bool isIncluded(const word& objName)const
89  {
90  return false;
91  }
92 
93  virtual
94  bool isExcluded(const word& objName)const
95  {
96  return false;
97  }
98 
99  // - path to file name
100  fileSystem path() const;
101 
102  bool outFileBinary()const;
103 
104  bool inFileBinary()const;
105 
106  // - should be used for read operations
107  // check if the file exist,
108  // read the header of the file to check if it is ok
109  bool headerOk(bool silent = false);
110 
112  bool implyRead() const;
113 
115  bool implyWrite() const;
116 
118  bool fileExist() const;
119 
121  bool readIfPresent()const;
122 
126  bool writeHeader()const;
127 
129  bool writeHeader(iOstream& os, const word& typeName, bool forceWrite = false ) const;
130 
132  bool writeHeader(iOstream& os, bool forceWrite = false) const;
133 
135  bool readHeader()const;
136 
138  bool readHeader(iIstream& is, bool silent=false);
139 
140 
141 
143  bool writeBanner(iOstream& os)const;
144 
146  bool writeSeparator(iOstream& os)const;
147 
148 };
149 
150 
151 }
152 
153 #endif //__objectFile_hpp__
pFlow::IOfileHeader::isExcluded
virtual bool isExcluded(const word &objName) const
Definition: IOfileHeader.hpp:94
pFlow::IOfileHeader::objectType
const word & objectType() const
Definition: IOfileHeader.hpp:75
pFlow::IOfileHeader::readIfPresent
bool readIfPresent() const
Check read if present.
Definition: IOfileHeader.cpp:139
pFlow::IOfileHeader::outFileBinary
bool outFileBinary() const
Definition: IOfileHeader.cpp:79
pFlow::IOfileHeader::objectType_
word objectType_
Definition: IOfileHeader.hpp:48
pFlow::IOfileHeader::fileExist
bool fileExist() const
Check if file exists.
Definition: IOfileHeader.cpp:134
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::IOfileHeader::writeHeader
bool writeHeader() const
Check if the header should be written to file True: on master + implyWrite + readWriteHeader = true F...
Definition: IOfileHeader.cpp:144
pFlow
Definition: demGeometry.hpp:27
pFlow::fileSystem
Manages file pathes, manupulate and combines them.
Definition: fileSystem.hpp:71
uniquePtr.hpp
pFlow::IOfileHeader::outStream
uniquePtr< oFstream > outStream() const
Definition: IOfileHeader.cpp:32
pFlow::iIstream
Interface class for any input stream
Definition: iIstream.hpp:37
pFlow::IOfileHeader::path
fileSystem path() const
Definition: IOfileHeader.cpp:63
pFlow::IOfileHeader::fileFormat_
word fileFormat_
file format read from file
Definition: IOfileHeader.hpp:51
pFlow::IOfileHeader::objectName_
word objectName_
Definition: IOfileHeader.hpp:45
pFlow::objectFile
Definition: objectFile.hpp:30
objectFile.hpp
streams.hpp
pFlow::IOfileHeader::inStream
uniquePtr< iFstream > inStream() const
Definition: IOfileHeader.cpp:24
pFlow::IOfileHeader::implyRead
bool implyRead() const
Imply read.
Definition: IOfileHeader.cpp:121
pFlow::IOfileHeader
Definition: IOfileHeader.hpp:35
pFlow::IOfileHeader::writeSeparator
bool writeSeparator(iOstream &os) const
wirte a separator line
Definition: IOfileHeader.cpp:249
pFlow::IOfileHeader::headerOk
bool headerOk(bool silent=false)
Definition: IOfileHeader.cpp:92
pFlow::uniquePtr
Definition: uniquePtr.hpp:42
pFlow::IOfileHeader::readHeader
bool readHeader() const
Check if header should be read from file.
Definition: IOfileHeader.cpp:189
pFlow::IOfileHeader::objectName
const word & objectName() const
Definition: IOfileHeader.hpp:69
pFlow::IOfileHeader::IOfileHeader
IOfileHeader(const objectFile &objf)
Definition: IOfileHeader.cpp:58
pFlow::IOfileHeader::inFileBinary
bool inFileBinary() const
Definition: IOfileHeader.cpp:87
pFlow::repository
Definition: repository.hpp:34
pFlow::IOfileHeader::dummyOutStream
uniquePtr< oFstream > dummyOutStream() const
Definition: IOfileHeader.cpp:45
pFlow::IOfileHeader::implyWrite
bool implyWrite() const
Imply write.
Definition: IOfileHeader.cpp:127
pFlow::IOfileHeader::isIncluded
virtual bool isIncluded(const word &objName) const
Definition: IOfileHeader.hpp:88
pFlow::iOstream
Interface class for any output stream.
Definition: iOstream.hpp:59
pFlow::IOfileHeader::owner
virtual const repository * owner() const
Definition: IOfileHeader.hpp:82
pFlow::IOfileHeader::writeBanner
bool writeBanner(iOstream &os) const
write the banner
Definition: IOfileHeader.cpp:238