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  // owner repository
44  const repository* owner_ = nullptr;
45 
46  // object name read from file
48 
49  // object type read from file
51 
53  word fileFormat_ = "ASCII";
54 
56 
57  // - input file stream
59 
60  // - ouput file stream
62 
63 public:
64 
65  // with owner
66  IOfileHeader(const objectFile& objf, const repository* owner = nullptr);
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  const repository* owner()const
82  {
83  return owner_;
84  }
85 
86  // - path to file name
87  fileSystem path() const;
88 
89  bool outFileBinary()const;
90 
91  bool inFileBinary()const;
92 
93  // - should be used for read operations
94  // check if the file exist,
95  // read the header of the file to check if it is ok
96  bool headerOk(bool silent = false);
97 
98  // - imply read
99  bool implyRead() const;
100 
101  // - imply write
102  bool implyWrite() const;
103 
104  // - check if file exists
105  bool fileExist() const;
106 
107  // - check read if present
108  bool readIfPresent()const;
109 
110  // - write the header in the file , typeName comes from caller
111  bool writeHeader(iOstream& os, const word& typeName) const;
112 
113  // - write the header in the file, typeName comes from the one read from file
114  bool writeHeader(iOstream& os) const;
115 
116  // - read the header in the file
117  bool readHeader(iIstream& is, bool silent=false);
118 
119  // - write the banner
120  bool writeBanner(iOstream& os)const;
121 
122  // - wirte a separator line
123  bool writeSeparator(iOstream& os)const;
124 
125 };
126 
127 
128 }
129 
130 #endif //__objectFile_hpp__
pFlow::IOfileHeader::objectType
const word & objectType() const
Definition: IOfileHeader.hpp:75
pFlow::IOfileHeader::readIfPresent
bool readIfPresent() const
Definition: IOfileHeader.cpp:131
pFlow::IOfileHeader::outFileBinary
bool outFileBinary() const
Definition: IOfileHeader.cpp:73
pFlow::IOfileHeader::objectType_
word objectType_
Definition: IOfileHeader.hpp:50
pFlow::IOfileHeader::readHeader
bool readHeader(iIstream &is, bool silent=false)
Definition: IOfileHeader.cpp:166
pFlow::IOfileHeader::fileExist
bool fileExist() const
Definition: IOfileHeader.cpp:126
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:137
pFlow::IOfileHeader::path
fileSystem path() const
Definition: IOfileHeader.cpp:57
pFlow::IOfileHeader::fileFormat_
word fileFormat_
file format read from file
Definition: IOfileHeader.hpp:53
pFlow::IOfileHeader::IOfileHeader
IOfileHeader(const objectFile &objf, const repository *owner=nullptr)
Definition: IOfileHeader.cpp:48
pFlow::IOfileHeader::objectName_
word objectName_
Definition: IOfileHeader.hpp:47
pFlow::IOfileHeader::owner
const repository * owner() const
Definition: IOfileHeader.hpp:81
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:115
pFlow::IOfileHeader
Definition: IOfileHeader.hpp:35
pFlow::IOfileHeader::writeSeparator
bool writeSeparator(iOstream &os) const
Definition: IOfileHeader.cpp:217
pFlow::IOfileHeader::headerOk
bool headerOk(bool silent=false)
Definition: IOfileHeader.cpp:86
pFlow::uniquePtr
Definition: uniquePtr.hpp:44
pFlow::IOfileHeader::objectName
const word & objectName() const
Definition: IOfileHeader.hpp:69
pFlow::IOfileHeader::inFileBinary
bool inFileBinary() const
Definition: IOfileHeader.cpp:81
pFlow::repository
Definition: repository.hpp:34
pFlow::IOfileHeader::implyWrite
bool implyWrite() const
Definition: IOfileHeader.cpp:121
pFlow::iOstream
Definition: iOstream.hpp:53
pFlow::IOfileHeader::writeBanner
bool writeBanner(iOstream &os) const
Definition: IOfileHeader.cpp:206