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