My Project
Loading...
Searching...
No Matches
DeckRecord.hpp
1/*
2 Copyright 2013 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 DECKRECORD_HPP
21#define DECKRECORD_HPP
22
23#include <string>
24#include <vector>
25#include <memory>
26#include <iosfwd>
27
28#include <opm/input/eclipse/Deck/DeckItem.hpp>
29
30namespace Opm {
31
32 class DeckRecord {
33 public:
34 typedef std::vector< DeckItem >::const_iterator const_iterator;
35
36 DeckRecord() = default;
37 explicit DeckRecord( std::vector< DeckItem >&& items, const bool check_for_duplicate_names = true );
38
39 static DeckRecord serializationTestObject();
40
41 size_t size() const;
42 void addItem( DeckItem deckItem );
43
44 DeckItem& getItem( size_t index );
45 DeckItem& getItem( const std::string& name );
46 DeckItem& getDataItem();
47
48 const DeckItem& getItem( size_t index ) const;
49 const DeckItem& getItem( const std::string& name ) const;
50 const DeckItem& getDataItem() const;
51
52 bool hasItem(const std::string& name) const;
53
54 template <class Item>
55 DeckItem& getItem() {
56 return getItem( Item::itemName );
57 }
58
59 template <class Item>
60 const DeckItem& getItem() const {
61 return getItem( Item::itemName );
62 }
63
64 const_iterator begin() const;
65 const_iterator end() const;
66
67 void write(DeckOutput& writer, std::size_t item_offset = 0) const;
68 void write_data(DeckOutput& writer, std::size_t item_offset = 0) const;
69 friend std::ostream& operator<<(std::ostream& os, const DeckRecord& record);
70
71 bool equal(const DeckRecord& other, bool cmp_default, bool cmp_numeric) const;
72 bool operator==(const DeckRecord& other) const;
73 bool operator!=(const DeckRecord& other) const;
74
75 template<class Serializer>
76 void serializeOp(Serializer& serializer)
77 {
78 serializer(m_items);
79 }
80
81 private:
82 std::vector< DeckItem > m_items;
83
84 };
85
86}
87#endif /* DECKRECORD_HPP */
88
Definition DeckItem.hpp:37
Definition DeckOutput.hpp:29
Definition DeckRecord.hpp:32
Class for (de-)serializing.
Definition Serializer.hpp:84
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30