My Project
DeckKeyword.hpp
1 /*
2  Copyright 2016 Statoil ASA.
3 
4  This file is part of the Open Porous Media project (OPM).
5 
6  OPM is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  OPM is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with OPM. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #ifndef DECKKEYWORD_HPP
21 #define DECKKEYWORD_HPP
22 
23 #include <string>
24 #include <vector>
25 
26 #include <opm/input/eclipse/Deck/DeckRecord.hpp>
27 #include <opm/input/eclipse/Deck/value_status.hpp>
28 #include <opm/common/OpmLog/KeywordLocation.hpp>
29 
30 namespace Opm {
31  class DeckOutput;
32  class DeckValue;
33  class ParserKeyword;
34  class UnitSystem;
35 
36  class DeckKeyword {
37  public:
38 
39 
40  typedef std::vector< DeckRecord >::const_iterator const_iterator;
41 
42  DeckKeyword();
43  explicit DeckKeyword(const ParserKeyword& parserKeyword);
44  DeckKeyword(const KeywordLocation& location, const std::string& keywordName);
45  DeckKeyword(const ParserKeyword& parserKeyword, const std::vector<std::vector<DeckValue>>& record_list, const UnitSystem& system_active, const UnitSystem& system_default);
46  DeckKeyword(const ParserKeyword& parserKeyword, const std::vector<int>& data);
47  DeckKeyword(const ParserKeyword& parserKeyword, const std::vector<double>& data, const UnitSystem& system_active, const UnitSystem& system_default);
48 
49  static DeckKeyword serializeObject();
50 
51  const std::string& name() const;
52  void setFixedSize();
53  const KeywordLocation& location() const;
54 
55 
56  size_t size() const;
57  bool empty() const;
58  void addRecord(DeckRecord&& record);
59  const DeckRecord& getRecord(size_t index) const;
60  DeckRecord& getRecord(size_t index);
61  const DeckRecord& getDataRecord() const;
62  const DeckRecord& operator[](std::size_t index) const;
63  DeckRecord& operator[](std::size_t index);
64  void setDataKeyword(bool isDataKeyword = true);
65  void setDoubleRecordKeyword(bool isDoubleRecordKeyword = true);
66  bool isDataKeyword() const;
67  bool isDoubleRecordKeyword() const;
68 
69  const std::vector<int>& getIntData() const;
70  const std::vector<double>& getRawDoubleData() const;
71  const std::vector<double>& getSIDoubleData() const;
72  const std::vector<std::string>& getStringData() const;
73  const std::vector<value::status>& getValueStatus() const;
74  size_t getDataSize() const;
75  void write( DeckOutput& output ) const;
76  void write_data( DeckOutput& output ) const;
77  void write_TITLE( DeckOutput& output ) const;
78 
79  template <class Keyword>
80  bool is() const {
81  if (Keyword::keywordName == this->m_keywordName)
82  return true;
83  else
84  return false;
85  }
86 
87  const_iterator begin() const;
88  const_iterator end() const;
89  bool equal_data(const DeckKeyword& other, bool cmp_default = false, bool cmp_numeric = true) const;
90  bool equal(const DeckKeyword& other, bool cmp_default = false, bool cmp_numeric = true) const;
91  bool operator==(const DeckKeyword& other) const;
92  bool operator!=(const DeckKeyword& other) const;
93 
94  friend std::ostream& operator<<(std::ostream& os, const DeckKeyword& keyword);
95 
96  template<class Serializer>
97  void serializeOp(Serializer& serializer)
98  {
99  serializer(m_keywordName);
100  m_location.serializeOp(serializer);
101  serializer.vector(m_recordList);
102  serializer(m_isDataKeyword);
103  serializer(m_slashTerminated);
104  serializer(m_isDoubleRecordKeyword);
105  }
106 
107  private:
108  std::string m_keywordName;
109  KeywordLocation m_location;
110 
111  std::vector< DeckRecord > m_recordList;
112  bool m_isDataKeyword;
113  bool m_slashTerminated;
114  bool m_isDoubleRecordKeyword = false;
115  };
116 }
117 
118 #endif /* DECKKEYWORD_HPP */
119 
Definition: DeckKeyword.hpp:36
Definition: DeckOutput.hpp:29
Definition: DeckRecord.hpp:32
Definition: KeywordLocation.hpp:27
Definition: ParserKeyword.hpp:85
Definition: Serializer.hpp:38
Definition: UnitSystem.hpp:34
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:29