DeckRecord.hpp
Go to the documentation of this file.
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 <stdexcept>
24 #include <string>
25 #include <vector>
26 #include <map>
27 #include <memory>
29 
30 namespace Opm {
31 
32  class DeckRecord {
33  public:
34  DeckRecord();
35  size_t size() const;
36  void addItem(DeckItemPtr deckItem);
37  DeckItemPtr getItem(size_t index) const;
38  DeckItemPtr getItem(const std::string& name) const;
39  DeckItemPtr getDataItem() const;
40  bool hasItem(const std::string& name) const;
41 
42  template <class Item>
43  DeckItemPtr getItem() const {
44  return getItem( Item::itemName );
45  }
46 
47 
48  private:
49  std::vector<DeckItemPtr> m_items;
50  std::map<std::string, DeckItemPtr> m_itemMap;
51 
52  };
53  typedef std::shared_ptr<DeckRecord> DeckRecordPtr;
54  typedef std::shared_ptr<const DeckRecord> DeckRecordConstPtr;
55 
56 }
57 #endif /* DECKRECORD_HPP */
58 
DeckItemPtr getDataItem() const
size_t size() const
std::shared_ptr< DeckItem > DeckItemPtr
Definition: DeckItem.hpp:126
Definition: DeckRecord.hpp:32
Definition: Deck.hpp:29
bool hasItem(const std::string &name) const
void addItem(DeckItemPtr deckItem)
DeckItemPtr getItem() const
Definition: DeckRecord.hpp:43
std::shared_ptr< const DeckRecord > DeckRecordConstPtr
Definition: DeckRecord.hpp:54
std::shared_ptr< DeckRecord > DeckRecordPtr
Definition: DeckRecord.hpp:53