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 
38 class iEntry
39 {
40 
41 public:
42 
44 
45  // - read a keyword from stream
46  static bool readKeyword(iIstream &is, word& keyword, token& tok );
47 
48  // - create an entry (dataEntry or dictionary) from stream
49  static bool createEntry(dictionary& parDict, iIstream& is, bool hasBlockToken = false);
50 
51 protected:
52 
53  // keyWord of entry
55 
56  bool writeKeyword(iOstream& os)const;
57 
58 public:
59 
60 
61  TypeInfo("iEntry");
62 
64 
65  // - empty constructor
67  {}
68 
69  // - construct with a keyword
70  iEntry(const word& key)
71  {
72  // this moved here due to a very strange core dumped error!
73  keyword_ = key;
74  }
75 
76  // - destructor
77  virtual ~iEntry()
78  {}
79 
80 
82 
83  // - return keyword
84  virtual const word& keyword() const
85  {
86  return keyword_;
87  }
88 
89  // - return keyword
90  virtual word& keyword()
91  {
92  return keyword_;
93  }
94 
95  virtual word name()const
96  {
97  return keyword();
98  }
99 
100  // global name of entry, separated with dots
101  virtual word globalName()const = 0;
102 
103  // - pointer to this dictionary
104  virtual dictionary* dictPtr()
105  {
106  return nullptr;
107  }
108 
109  // - const pointer to this dictionary
110  virtual const dictionary* dictPtr() const
111  {
112  return nullptr;
113  }
114 
115  // - if this is a dictionary
116  virtual bool isDictionary() const
117  {
118  return false;
119  }
120 
121  // - const ref to parrent dictionary
122  virtual const dictionary& parrentDict() const = 0;
123 
124  // - ref to this dictionary, if it is a dictionary
125  virtual dictionary& dict() = 0;
126 
127  // - const ref to this dictionary, if it is a dicrionary
128  virtual const dictionary& dict() const = 0;
129 
130  // clone the object
131  virtual iEntry* clonePtr() const = 0;
132 
133  virtual uniquePtr<iEntry> clone() const = 0;
134 
135  // clone the object and change its ownership to parDict
136  virtual iEntry* clonePtr(const dictionary& parDict) const = 0;
137 
138  virtual uniquePtr<iEntry> clone(const dictionary& parDict)const = 0;
139 
141 
142  // read from stream
143  virtual bool read(iIstream& is) = 0;
144 
145  // write to stream
146  virtual bool write(iOstream& os) const =0;
147 
148 };
149 
150 
151 iOstream& operator << (iOstream& os, const iEntry& e);
152 
153 
154 iIstream& operator >> (iIstream& is, iEntry& e);
155 
156 
157 }
158 
159 
160 #endif //__iEntry_hpp__
pFlow::iEntry::clone
virtual uniquePtr< iEntry > clone() const =0
pFlow::token
Definition: token.hpp:42
pFlow::iEntry::globalName
virtual word globalName() const =0
types.hpp
pFlow::iEntry::isDictionary
virtual bool isDictionary() const
Definition: iEntry.hpp:116
pFlow::word
std::string word
Definition: builtinTypes.hpp:63
pFlow::iEntry::parrentDict
virtual const dictionary & parrentDict() const =0
pFlow::iEntry::keyword_
word keyword_
Definition: iEntry.hpp:54
pFlow::iEntry::iEntry
iEntry(const word &key)
Definition: iEntry.hpp:70
pFlow::iEntry::keyword
virtual const word & keyword() const
Definition: iEntry.hpp:84
pFlow::iEntry::TypeInfo
TypeInfo("iEntry")
pFlow::iEntry::write
virtual bool write(iOstream &os) const =0
pFlow
Definition: demComponent.hpp:28
uniquePtr.hpp
pFlow::iIstream
Definition: iIstream.hpp:33
pFlow::iEntry::read
virtual bool read(iIstream &is)=0
pFlow::iEntry::createEntry
static bool createEntry(dictionary &parDict, iIstream &is, bool hasBlockToken=false)
Definition: iEntry.cpp:64
pFlow::operator>>
INLINE_FUNCTION iIstream & operator>>(iIstream &str, AB3History &ab3)
Definition: AdamsBashforth3.hpp:41
pFlow::iEntry::keyword
virtual word & keyword()
Definition: iEntry.hpp:90
pFlow::operator<<
INLINE_FUNCTION iOstream & operator<<(iOstream &str, const AB3History &ab3)
Definition: AdamsBashforth3.hpp:57
pFlow::iEntry::dictPtr
virtual dictionary * dictPtr()
Definition: iEntry.hpp:104
pFlow::iEntry::dictPtr
virtual const dictionary * dictPtr() const
Definition: iEntry.hpp:110
pFlow::iEntry::name
virtual word name() const
Definition: iEntry.hpp:95
pFlow::iEntry::writeKeyword
bool writeKeyword(iOstream &os) const
Definition: iEntry.cpp:154
pFlow::iEntry::dict
virtual dictionary & dict()=0
pFlow::uniquePtr
Definition: uniquePtr.hpp:44
pFlow::iEntry::~iEntry
virtual ~iEntry()
Definition: iEntry.hpp:77
pFlow::iEntry::clonePtr
virtual iEntry * clonePtr() const =0
pFlow::iEntry::readKeyword
static bool readKeyword(iIstream &is, word &keyword, token &tok)
Definition: iEntry.cpp:32
typeInfo.hpp
pFlow::iEntry
Definition: iEntry.hpp:38
pFlow::iOstream
Definition: iOstream.hpp:53
pFlow::dictionary
Definition: dictionary.hpp:38
pFlow::iEntry::iEntry
iEntry()
Definition: iEntry.hpp:66