www.cemf.ir
dataEntry.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 dictionary, with some modifications/simplifications
21 // to be tailored to our needs
22 
23 
24 #ifndef __dataEntry_hpp__
25 #define __dataEntry_hpp__
26 
27 
28 #include "iEntry.hpp"
29 #include "iTstream.hpp"
30 #include "oTstream.hpp"
31 
32 
33 
34 namespace pFlow
35 {
36 
37 class dictionary;
38 
48 class dataEntry
49 :
50  public iEntry
51 {
52 
53 protected:
54 
56 
59 
62 
63 
65 
67  bool readDataEntry(iIstream& is);
68 
70  bool writeDataEntry(iOstream& os) const;
71 
72 public:
73 
75 
77 
79  dataEntry();
80 
82  dataEntry(const word& keyword, const dictionary& parDict);
83 
85  dataEntry(const word& keyWord, const dictionary& parDict, const iTstream& is);
86 
87  //- construct from keyword, parDict and input stream
88  dataEntry(const word& keyWord, const dictionary& parDict, iIstream& is);
89 
91  dataEntry(const word& keyword, const dictionary& parDict, const token& tok);
92 
94  template<typename T>
95  dataEntry(const word& keyword, const dictionary& parDict, const T& v);
96 
98  dataEntry(const word& keyword, const dictionary& parDict, const dataEntry& entry );
99 
101  dataEntry(const dataEntry& src )= default;
102 
103 
105 
107  virtual word globalName()const;
108 
109 
111  virtual iTstream& stream();
112 
114  virtual dictionary* dictPtr();
115 
117  virtual const dictionary* dictPtr() const;
118 
120  virtual bool isDictionary()const;
121 
123  virtual const dictionary& parrentDict() const;
124 
126  virtual dictionary& dict();
127 
129  virtual const dictionary& dict() const;
130 
131  // clone the object
132  virtual iEntry* clonePtr() const;
133 
134  virtual uniquePtr<iEntry> clone() const;
135 
136  // clone the object and change its ownership to parDict
137  virtual iEntry* clonePtr(const dictionary& parDict) const;
138 
139  virtual uniquePtr<iEntry> clone(const dictionary& parDict)const;
140 
142 
144  virtual bool read(iIstream& is);
145 
147  virtual bool write(iOstream& os) const;
148 
149 };
150 
151 
152 
153 
154 template<typename T>
155 dataEntry::dataEntry(const word& keyword, const dictionary& parDict, const T& v)
156 :
157  dataEntry(keyword, parDict)
158 {
159 
160  oTstream os("oTStream for " + globalName());
161 
162  os<< v << endStatementToken();
163 
164  tokenStream_ = std::move(os.tokens());
165 }
166 
167 
168 } // pFlow
169 
170 
171 #endif //__dataEntry_hpp__
pFlow::oTstream
Output token stream.
Definition: oTstream.hpp:48
pFlow::dataEntry::readDataEntry
bool readDataEntry(iIstream &is)
read dataEntry from stream
Definition: dataEntry.cpp:35
iTstream.hpp
pFlow::token
Token class based on OpenFOAM stream, with some modifications/simplifications to be tailored to our n...
Definition: token.hpp:44
pFlow::dataEntry::stream
virtual iTstream & stream()
access to token stream
Definition: dataEntry.cpp:265
pFlow::endStatementToken
token endStatementToken()
Definition: token.hpp:513
pFlow::dataEntry::parrentDict
virtual const dictionary & parrentDict() const
const ref to parrent dictionary
Definition: dataEntry.cpp:301
pFlow::dataEntry::globalName
virtual word globalName() const
global name of entry, separated with dots
Definition: dataEntry.cpp:295
pFlow::dataEntry::writeDataEntry
bool writeDataEntry(iOstream &os) const
write dataEntry to stream
Definition: dataEntry.cpp:98
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
oTstream.hpp
pFlow::iEntry::keyword
virtual const word & keyword() const
return keyword
Definition: iEntry.hpp:88
pFlow::oTstream::tokens
const tokenList & tokens() const
Definition: oTstream.cpp:32
pFlow
Definition: demGeometry.hpp:27
pFlow::dataEntry::parDict_
const dictionary & parDict_
ref to parrent dictionary
Definition: dataEntry.hpp:58
pFlow::dataEntry::dataEntry
dataEntry()
construct null dataEntry
Definition: dataEntry.cpp:163
pFlow::dataEntry
Data entry to be used in dictionries.
Definition: dataEntry.hpp:48
pFlow::iIstream
Interface class for any input stream
Definition: iIstream.hpp:37
pFlow::dataEntry::tokenStream_
iTstream tokenStream_
list the tokens as input token stream
Definition: dataEntry.hpp:61
pFlow::dataEntry::dictPtr
virtual dictionary * dictPtr()
not permited to be called
Definition: dataEntry.cpp:273
iEntry.hpp
pFlow::dataEntry::nullDataEntry
static dataEntry nullDataEntry
Definition: dataEntry.hpp:74
pFlow::dataEntry::isDictionary
virtual bool isDictionary() const
should returen false;
Definition: dataEntry.cpp:290
pFlow::iTstream
Input token stream.
Definition: iTstream.hpp:27
pFlow::dataEntry::read
virtual bool read(iIstream &is)
read from stream
Definition: dataEntry.cpp:349
pFlow::uniquePtr
Definition: uniquePtr.hpp:42
pFlow::dataEntry::clone
virtual uniquePtr< iEntry > clone() const
Definition: dataEntry.cpp:325
pFlow::iEntry
Interface calss for data entry and dictionary
Definition: iEntry.hpp:42
pFlow::dataEntry::clonePtr
virtual iEntry * clonePtr() const
clone the object
Definition: dataEntry.cpp:331
pFlow::dataEntry::dict
virtual dictionary & dict()
not permited to be called
Definition: dataEntry.cpp:307
pFlow::dataEntry::write
virtual bool write(iOstream &os) const
write to stream
Definition: dataEntry.cpp:370
pFlow::iOstream
Interface class for any output stream.
Definition: iOstream.hpp:59
pFlow::dictionary
Dictionary holds a set of data entries or sub-dictionaries that are enclosed in a curely braces or ar...
Definition: dictionary.hpp:67