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