www.cemf.ir
iEntry.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 #ifndef __iEntry_hpp__
24 #define __iEntry_hpp__
25 
26 
27 #include "types.hpp"
28 #include "typeInfo.hpp"
29 #include "uniquePtr.hpp"
30 
31 
32 namespace pFlow
33 {
34 
35 
36 class dictionary;
37 
42 class iEntry
43 {
44 
45 public:
46 
48 
50  static bool readKeyword(iIstream &is, word& keyword, token& tok );
51 
53  static bool createEntry(dictionary& parDict, iIstream& is, bool hasBlockToken = false);
54 
55 protected:
56 
57  // keyWord of entry
59 
60  bool writeKeyword(iOstream& os)const;
61 
62 public:
63 
65  TypeInfo("iEntry");
66 
68 
71  {}
72 
74  iEntry(const word& key)
75  {
76  // this moved here due to a very strange core dumped error!
77  keyword_ = key;
78  }
79 
81  virtual ~iEntry()
82  {}
83 
84 
86 
88  virtual const word& keyword() const
89  {
90  return keyword_;
91  }
92 
94  virtual word& keyword()
95  {
96  return keyword_;
97  }
98 
100  virtual word name()const
101  {
102  return keyword();
103  }
104 
105  // global name of entry, separated with dots
106  virtual word globalName()const = 0;
107 
109  virtual dictionary* dictPtr()
110  {
111  return nullptr;
112  }
113 
115  virtual const dictionary* dictPtr() const
116  {
117  return nullptr;
118  }
119 
121  virtual bool isDictionary() const
122  {
123  return false;
124  }
125 
127  virtual const dictionary& parrentDict() const = 0;
128 
130  virtual dictionary& dict() = 0;
131 
133  virtual const dictionary& dict() const = 0;
134 
136  virtual iEntry* clonePtr() const = 0;
137 
138  virtual uniquePtr<iEntry> clone() const = 0;
139 
141  virtual iEntry* clonePtr(const dictionary& parDict) const = 0;
142 
144  virtual uniquePtr<iEntry> clone(const dictionary& parDict)const = 0;
145 
147 
149  virtual bool read(iIstream& is) = 0;
150 
152  virtual bool write(iOstream& os) const =0;
153 
154 };
155 
156 
157 iOstream& operator << (iOstream& os, const iEntry& e);
158 
159 iIstream& operator >> (iIstream& is, iEntry& e);
160 
161 
162 } // pFlow
163 
164 
165 #endif //__iEntry_hpp__
pFlow::iEntry::clone
virtual uniquePtr< iEntry > clone() const =0
pFlow::token
Token class based on OpenFOAM stream, with some modifications/simplifications to be tailored to our n...
Definition: token.hpp:44
pFlow::iEntry::globalName
virtual word globalName() const =0
types.hpp
pFlow::iEntry::isDictionary
virtual bool isDictionary() const
if this is a dictionary
Definition: iEntry.hpp:121
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::iEntry::parrentDict
virtual const dictionary & parrentDict() const =0
const ref to parrent dictionary
pFlow::iEntry::keyword_
word keyword_
Definition: iEntry.hpp:58
pFlow::iEntry::iEntry
iEntry(const word &key)
construct with a keyword
Definition: iEntry.hpp:74
pFlow::iEntry::keyword
virtual const word & keyword() const
return keyword
Definition: iEntry.hpp:88
pFlow::iEntry::TypeInfo
TypeInfo("iEntry")
Type info.
pFlow::iEntry::write
virtual bool write(iOstream &os) const =0
write to stream
pFlow
Definition: demGeometry.hpp:27
uniquePtr.hpp
pFlow::iIstream
Interface class for any input stream
Definition: iIstream.hpp:37
pFlow::iEntry::read
virtual bool read(iIstream &is)=0
read from stream
pFlow::iEntry::createEntry
static bool createEntry(dictionary &parDict, iIstream &is, bool hasBlockToken=false)
create an entry (dataEntry or dictionary) from stream
Definition: iEntry.cpp:64
pFlow::operator>>
INLINE_FUNCTION iIstream & operator>>(iIstream &str, AB3History &ab3)
Definition: AdamsBashforth3.hpp:41
pFlow::iEntry::keyword
virtual word & keyword()
return keyword
Definition: iEntry.hpp:94
pFlow::operator<<
INLINE_FUNCTION iOstream & operator<<(iOstream &str, const AB3History &ab3)
Definition: AdamsBashforth3.hpp:57
pFlow::iEntry::dictPtr
virtual dictionary * dictPtr()
pointer to this dictionary
Definition: iEntry.hpp:109
pFlow::iEntry::dictPtr
virtual const dictionary * dictPtr() const
const pointer to this dictionary
Definition: iEntry.hpp:115
pFlow::iEntry::name
virtual word name() const
name/keyword of entry
Definition: iEntry.hpp:100
pFlow::iEntry::writeKeyword
bool writeKeyword(iOstream &os) const
Definition: iEntry.cpp:154
pFlow::iEntry::dict
virtual dictionary & dict()=0
ref to this dictionary, if it is a dictionary
pFlow::uniquePtr
Definition: uniquePtr.hpp:42
pFlow::iEntry::~iEntry
virtual ~iEntry()
destructor
Definition: iEntry.hpp:81
pFlow::iEntry::clonePtr
virtual iEntry * clonePtr() const =0
clone the object
pFlow::iEntry::readKeyword
static bool readKeyword(iIstream &is, word &keyword, token &tok)
read a keyword from stream
Definition: iEntry.cpp:32
typeInfo.hpp
pFlow::iEntry
Interface calss for data entry and dictionary
Definition: iEntry.hpp:42
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
pFlow::iEntry::iEntry
iEntry()
empty constructor
Definition: iEntry.hpp:70