DeckKeyword.hpp
Go to the documentation of this file.
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#include <memory>
26#include <utility>
27
33
34namespace Opm {
35 class DeckOutput;
36 class ParserKeyword;
37
39 public:
40
41
42 typedef std::vector< DeckRecord >::const_iterator const_iterator;
43
45 explicit DeckKeyword(const ParserKeyword& parserKeyword);
46 DeckKeyword(const Location& location, const std::string& keywordName);
47 DeckKeyword(const ParserKeyword& parserKeyword, const std::vector<std::vector<DeckValue>>& record_list, UnitSystem& system_active, UnitSystem& system_default);
48 DeckKeyword(const ParserKeyword& parserKeyword, const std::vector<int>& data);
49 DeckKeyword(const ParserKeyword& parserKeyword, const std::vector<double>& data, UnitSystem& system_active, UnitSystem& system_default);
50
52
53 const std::string& name() const;
55 const Location& location() const;
56
57
58 size_t size() const;
59 void addRecord(DeckRecord&& record);
60 const DeckRecord& getRecord(size_t index) const;
62 const DeckRecord& getDataRecord() const;
63 void setDataKeyword(bool isDataKeyword = true);
65 bool isDataKeyword() const;
67
68 const std::vector<int>& getIntData() const;
69 const std::vector<double>& getRawDoubleData() const;
70 const std::vector<double>& getSIDoubleData() const;
71 const std::vector<std::string>& getStringData() const;
72 const std::vector<value::status>& getValueStatus() const;
73 size_t getDataSize() const;
74 void write( DeckOutput& output ) const;
75 void write_data( DeckOutput& output ) const;
76 void write_TITLE( DeckOutput& output ) const;
77
78 template <class Keyword>
79 bool isKeyword() const {
80 if (Keyword::keywordName == m_keywordName)
81 return true;
82 else
83 return false;
84 }
85
88 bool equal_data(const DeckKeyword& other, bool cmp_default = false, bool cmp_numeric = true) const;
89 bool equal(const DeckKeyword& other, bool cmp_default = false, bool cmp_numeric = true) const;
90 bool operator==(const DeckKeyword& other) const;
91 bool operator!=(const DeckKeyword& other) const;
92
93 friend std::ostream& operator<<(std::ostream& os, const DeckKeyword& keyword);
94
95 template<class Serializer>
96 void serializeOp(Serializer& serializer)
97 {
98 serializer(m_keywordName);
99 m_location.serializeOp(serializer);
100 serializer.vector(m_recordList);
101 serializer(m_isDataKeyword);
102 serializer(m_slashTerminated);
103 serializer(m_isDoubleRecordKeyword);
104 }
105
106 private:
107 std::string m_keywordName;
108 Location m_location;
109
110 std::vector< DeckRecord > m_recordList;
111 bool m_isDataKeyword;
112 bool m_slashTerminated;
113 bool m_isDoubleRecordKeyword = false;
114 };
115}
116
117#endif /* DECKKEYWORD_HPP */
118
int index
Definition: cJSON.h:168
const char *const string
Definition: cJSON.h:170
Definition: DeckKeyword.hpp:38
const std::string & name() const
void addRecord(DeckRecord &&record)
const DeckRecord & getDataRecord() const
friend std::ostream & operator<<(std::ostream &os, const DeckKeyword &keyword)
void setDataKeyword(bool isDataKeyword=true)
bool isDataKeyword() const
bool operator==(const DeckKeyword &other) const
size_t size() const
bool operator!=(const DeckKeyword &other) const
bool isKeyword() const
Definition: DeckKeyword.hpp:79
const std::vector< int > & getIntData() const
DeckKeyword(const ParserKeyword &parserKeyword, const std::vector< double > &data, UnitSystem &system_active, UnitSystem &system_default)
const Location & location() const
std::vector< DeckRecord >::const_iterator const_iterator
Definition: DeckKeyword.hpp:42
void write_TITLE(DeckOutput &output) const
DeckKeyword(const ParserKeyword &parserKeyword, const std::vector< std::vector< DeckValue > > &record_list, UnitSystem &system_active, UnitSystem &system_default)
DeckKeyword(const ParserKeyword &parserKeyword, const std::vector< int > &data)
void write(DeckOutput &output) const
void setDoubleRecordKeyword(bool isDoubleRecordKeyword=true)
const DeckRecord & getRecord(size_t index) const
const std::vector< double > & getSIDoubleData() const
DeckKeyword(const ParserKeyword &parserKeyword)
void serializeOp(Serializer &serializer)
Definition: DeckKeyword.hpp:96
void write_data(DeckOutput &output) const
const_iterator begin() const
const std::vector< std::string > & getStringData() const
bool equal_data(const DeckKeyword &other, bool cmp_default=false, bool cmp_numeric=true) const
static DeckKeyword serializeObject()
DeckKeyword(const Location &location, const std::string &keywordName)
const std::vector< value::status > & getValueStatus() const
bool equal(const DeckKeyword &other, bool cmp_default=false, bool cmp_numeric=true) const
size_t getDataSize() const
DeckRecord & getRecord(size_t index)
const_iterator end() const
const std::vector< double > & getRawDoubleData() const
bool isDoubleRecordKeyword() const
Definition: DeckOutput.hpp:29
Definition: DeckRecord.hpp:32
Definition: Location.hpp:25
void serializeOp(Serializer &serializer)
Definition: Location.hpp:51
Definition: ParserKeyword.hpp:73
Definition: Serializer.hpp:38
Definition: UnitSystem.hpp:32
UDAKeyword keyword(UDAControl control)
Definition: A.hpp:4
static std::string data()
Definition: exprtk.hpp:40022