MultiRecordTable.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2013 by Andreas Lauser
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 #ifndef OPM_PARSER_MULTI_RECORD_TABLE_HPP
20 #define OPM_PARSER_MULTI_RECORD_TABLE_HPP
21 
23 
25 
26 #include <map>
27 #include <memory>
28 #include <string>
29 #include <vector>
30 #include <cassert>
31 
32 namespace Opm {
33  // forward declaration
34  class EclipseState;
35 
36  // create table from first few items of multiple records (i.e. getSIDoubleData() throws an exception)
37  class MultiRecordTable : public SimpleTable {
38  protected:
45  void init(Opm::DeckKeywordConstPtr keyword,
46  const std::vector<std::string> &columnNames,
47  size_t tableIndex);
48 
49  public:
50  MultiRecordTable() = default;
51 
52 #ifdef BOOST_TEST_MODULE
53  // DO NOT TRY TO CALL THIS METHOD! it is only for the unit tests!
54  void initFORUNITTESTONLY(Opm::DeckKeywordConstPtr keyword,
55  const std::vector<std::string> &columnNames,
56  size_t tableIndex)
57  { init(keyword, columnNames, tableIndex); }
58 #endif
59 
64  static size_t numTables(Opm::DeckKeywordConstPtr keyword);
65  static std::vector<std::pair<size_t , size_t> > recordRanges(Opm::DeckKeywordConstPtr keyword);
70  size_t firstRecordIndex() const;
71 
76  size_t numRecords() const;
77 
78  private:
79  std::pair<size_t, size_t> m_recordRange;
80  };
81 
82  typedef std::shared_ptr<MultiRecordTable> MultiRecordTablePtr;
83  typedef std::shared_ptr<const MultiRecordTable> MultiRecordTableConstPtr;
84 
85 }
86 
87 #endif
88 
Definition: Deck.hpp:29
std::shared_ptr< const DeckKeyword > DeckKeywordConstPtr
Definition: DeckKeyword.hpp:71
size_t firstRecordIndex() const
Return the index of the first record which applies for this table object.
Definition: MultiRecordTable.hpp:37
std::shared_ptr< MultiRecordTable > MultiRecordTablePtr
Definition: MultiRecordTable.hpp:82
static std::vector< std::pair< size_t, size_t > > recordRanges(Opm::DeckKeywordConstPtr keyword)
MultiRecordTable()=default
static size_t numTables(Opm::DeckKeywordConstPtr keyword)
Returns the number of tables which can be found in a given keyword.
Definition: SimpleTable.hpp:32
std::shared_ptr< const MultiRecordTable > MultiRecordTableConstPtr
Definition: MultiRecordTable.hpp:83
void init(Opm::DeckKeywordConstPtr keyword, const std::vector< std::string > &columnNames, size_t tableIndex)
Read simple tables from multi-item keywords like PVTW.
size_t numRecords() const
Return the number of records which are used by this this table object.