Deck.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 DECK_HPP
21 #define DECK_HPP
22 
23 #include <vector>
24 #include <memory>
25 
28 
29 namespace Opm {
30 
31  class Deck {
32  public:
33  Deck();
34  bool hasKeyword(DeckKeywordConstPtr keyword) const;
35  bool hasKeyword( const std::string& keyword ) const;
36  void addKeyword( DeckKeywordConstPtr keyword);
37  DeckKeywordConstPtr getKeyword(const std::string& keyword , size_t index) const;
38  DeckKeywordConstPtr getKeyword(const std::string& keyword) const;
39  DeckKeywordConstPtr getKeyword(size_t index) const;
40 
41  size_t getKeywordIndex(DeckKeywordConstPtr keyword) const;
42 
43 
44  size_t numKeywords(const std::string& keyword) const;
45  const std::vector<DeckKeywordConstPtr>& getKeywordList(const std::string& keyword) const;
46  size_t size() const;
47  void initUnitSystem();
48  std::shared_ptr<UnitSystem> getDefaultUnitSystem() const;
49  std::shared_ptr<UnitSystem> getActiveUnitSystem() const;
50  std::vector<DeckKeywordConstPtr>::const_iterator begin() const;
51  std::vector<DeckKeywordConstPtr>::const_iterator end() const;
52 
53 
54  template <class Keyword>
55  bool hasKeyword() const {
56  return hasKeyword( Keyword::keywordName );
57  }
58 
59  template <class Keyword>
60  DeckKeywordConstPtr getKeyword(size_t index) const {
61  return getkeyword( Keyword::keywordName , index );
62  }
63 
64  template <class Keyword>
66  return getKeyword( Keyword::keywordName );
67  }
68 
69  template <class Keyword>
70  const std::vector<DeckKeywordConstPtr>& getKeywordList() const {
71  return getKeywordList( Keyword::keywordName );
72  }
73 
74  protected:
75  std::shared_ptr<UnitSystem> m_defaultUnits;
76  std::shared_ptr<UnitSystem> m_activeUnits;
77 
78  private:
79  std::vector<DeckKeywordConstPtr> m_emptyList;
80  std::vector<DeckKeywordConstPtr> m_keywordList;
81  std::map<std::string, std::vector<DeckKeywordConstPtr> > m_keywordMap;
82  std::map<const DeckKeyword *, size_t> m_keywordIndex;
83  };
84 
85  typedef std::shared_ptr<Deck> DeckPtr;
86  typedef std::shared_ptr<const Deck> DeckConstPtr;
87 }
88 #endif /* DECK_HPP */
89 
void addKeyword(DeckKeywordConstPtr keyword)
std::vector< DeckKeywordConstPtr >::const_iterator end() const
DeckKeywordConstPtr getKeyword() const
Definition: Deck.hpp:65
Definition: Deck.hpp:29
std::shared_ptr< UnitSystem > m_activeUnits
Definition: Deck.hpp:76
std::shared_ptr< const DeckKeyword > DeckKeywordConstPtr
Definition: DeckKeyword.hpp:71
size_t numKeywords(const std::string &keyword) const
Definition: Deck.hpp:31
bool hasKeyword() const
Definition: Deck.hpp:55
std::shared_ptr< const Deck > DeckConstPtr
Definition: Deck.hpp:86
std::shared_ptr< UnitSystem > m_defaultUnits
Definition: Deck.hpp:75
std::vector< DeckKeywordConstPtr >::const_iterator begin() const
const std::vector< DeckKeywordConstPtr > & getKeywordList() const
Definition: Deck.hpp:70
std::shared_ptr< UnitSystem > getDefaultUnitSystem() const
std::shared_ptr< UnitSystem > getActiveUnitSystem() const
size_t getKeywordIndex(DeckKeywordConstPtr keyword) const
void initUnitSystem()
std::shared_ptr< Deck > DeckPtr
Definition: Deck.hpp:85
size_t size() const
DeckKeywordConstPtr getKeyword(size_t index) const
Definition: Deck.hpp:60