DeckDoubleItem.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 DECKDOUBLEITEM_HPP
21 #define DECKDOUBLEITEM_HPP
22 
23 #include <vector>
24 #include <string>
25 #include <deque>
26 #include <memory>
27 
30 
31 namespace Opm {
32 
33  class DeckDoubleItem : public DeckItem {
34  public:
35  DeckDoubleItem(std::string name_, bool scalar = true) : DeckItem(name_, scalar) {}
36  double getRawDouble(size_t index) const;
37  const std::vector<double>& getRawDoubleData() const;
38  double getSIDouble(size_t index) const;
39  const std::vector<double>& getSIDoubleData() const;
40 
41  void push_back(std::deque<double> data , size_t items);
42  void push_back(std::deque<double> data);
43  void push_back(double value);
44  void push_backDefault(double value);
45  // trying to access the data of a "dummy default item" will raise an exception
46  void push_backDummyDefault();
47  void push_backMultiple(double value, size_t numValues);
48  void push_backDimension(std::shared_ptr<const Dimension> activeDimension , std::shared_ptr<const Dimension> defaultDimension);
49 
50  size_t size() const;
51  private:
52  void assertSIData() const;
53 
54  std::vector<double> m_data;
55  // mutable is required because the data is "lazily" converted
56  // to SI units in asserSIData() which needs to be callable by
57  // 'const'-decorated methods
58  mutable std::vector<double> m_SIdata;
59  std::vector<std::shared_ptr<const Dimension> > m_dimensions;
60  };
61 
62  typedef std::shared_ptr<DeckDoubleItem> DeckDoubleItemPtr;
63  typedef std::shared_ptr< const DeckDoubleItem> DeckDoubleItemConstPtr;
64 }
65 #endif /* DECKDOUBLEITEM_HPP */
66 
void push_back(std::deque< double > data, size_t items)
void push_backDefault(double value)
Definition: Deck.hpp:29
DeckDoubleItem(std::string name_, bool scalar=true)
Definition: DeckDoubleItem.hpp:35
const std::vector< double > & getSIDoubleData() const
size_t size() const
std::shared_ptr< DeckDoubleItem > DeckDoubleItemPtr
Definition: DeckDoubleItem.hpp:62
void push_backMultiple(double value, size_t numValues)
void push_backDimension(std::shared_ptr< const Dimension > activeDimension, std::shared_ptr< const Dimension > defaultDimension)
Definition: DeckItem.hpp:31
Definition: DeckDoubleItem.hpp:33
std::shared_ptr< const DeckDoubleItem > DeckDoubleItemConstPtr
Definition: DeckDoubleItem.hpp:63
double getRawDouble(size_t index) const
const std::vector< double > & getRawDoubleData() const
double getSIDouble(size_t index) const
void push_backDummyDefault()