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 
54  // - input file stream
56 
57  // - ouput file stream
59 
60 public:
61 
62  // with owner
63  IOfileHeader(const objectFile& objf, const repository* owner = nullptr);
64 
65  // - object name
66  const word& objectName()const
67  {
68  return objectName_;
69  }
70 
71  // - object type
72  const word& objectType()const
73  {
74  return objectType_;
75  }
76 
77  // - pointer to owner repository
78  const repository* owner()const
79  {
80  return owner_;
81  }
82 
83  // - path to file name
84  fileSystem path() const;
85 
86  // - should be used for read operations
87  // check if the file exist,
88  // read the header of the file to check if it is ok
89  bool headerOk(bool silent = false);
90 
91  // - imply read
92  bool implyRead() const;
93 
94  // - imply write
95  bool implyWrite() const;
96 
97  // - check if file exists
98  bool fileExist() const;
99 
100  // - check read if present
101  bool readIfPresent()const;
102 
103  // - write the header in the file , typeName comes from caller
104  bool writeHeader(iOstream& os, const word& typeName) const;
105 
106  // - write the header in the file, typeName comes from the one read from file
107  bool writeHeader(iOstream& os) const;
108 
109  // - read the header in the file
110  bool readHeader(iIstream& is, bool silent=false);
111 
112  // - write the banner
113  bool writeBanner(iOstream& os)const;
114 
115  // - wirte a separator line
116  bool writeSeparator(iOstream& os)const;
117 
118 };
119 
120 
121 }
122 
123 #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