ParserFloatItem.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 PARSERFLOATITEM_HPP
21 #define PARSERFLOATITEM_HPP
22 
23 #include <memory>
24 
25 #include <opm/json/JsonObject.hpp>
26 
29 
31 
32 
33 namespace Opm {
34 
35  class ParserFloatItem : public ParserItem
36  {
37  public:
38  ParserFloatItem(const std::string& itemName);
39  ParserFloatItem(const std::string& itemName, ParserItemSizeEnum sizeType);
40  ParserFloatItem(const std::string& itemName, float defaultValue);
41  ParserFloatItem(const std::string& itemName, ParserItemSizeEnum sizeType, float defaultValue);
42  explicit ParserFloatItem( const Json::JsonObject& jsonConfig);
43 
44  size_t numDimensions() const;
45  bool hasDimension() const;
46  void push_backDimension(const std::string& dimension);
47  const std::string& getDimension(size_t index) const;
48  bool equalDimensions(const ParserItem& other) const;
49 
50  DeckItemPtr scan(RawRecordPtr rawRecord) const;
51  bool equal(const ParserItem& other) const;
52 
53  std::string createCode() const;
54  void inlineClass(std::ostream& os, const std::string& indent) const;
55  std::string inlineClassInit(const std::string& parentClass) const;
56  void setDefault(float defaultValue);
57  float getDefault() const;
58  bool hasDefault() const;
59  size_t dimensionSize() const;
60 
61  private:
62  float m_default;
63  std::vector<std::string> m_dimensions;
64  };
65 
66  typedef std::shared_ptr<const ParserFloatItem> ParserFloatItemConstPtr;
67  typedef std::shared_ptr<ParserFloatItem> ParserFloatItemPtr;
68 }
69 
70 #endif // PARSERFLOATITEM_HPP
void inlineClass(std::ostream &os, const std::string &indent) const
bool hasDimension() const
std::shared_ptr< DeckItem > DeckItemPtr
Definition: DeckItem.hpp:126
Definition: Deck.hpp:29
std::string inlineClassInit(const std::string &parentClass) const
size_t dimensionSize() const
Definition: ParserFloatItem.hpp:35
Definition: JsonObject.hpp:31
ParserItemSizeEnum
Definition: ParserEnums.hpp:37
std::string createCode() const
Definition: ParserItem.hpp:39
ParserItemSizeEnum sizeType() const
std::shared_ptr< ParserFloatItem > ParserFloatItemPtr
Definition: ParserFloatItem.hpp:67
bool equalDimensions(const ParserItem &other) const
bool hasDefault() const
ParserFloatItem(const std::string &itemName)
size_t numDimensions() const
DeckItemPtr scan(RawRecordPtr rawRecord) const
bool equal(const ParserItem &other) const
void push_backDimension(const std::string &dimension)
std::shared_ptr< RawRecord > RawRecordPtr
Definition: RawRecord.hpp:64
void setDefault(float defaultValue)
float getDefault() const
std::shared_ptr< const ParserFloatItem > ParserFloatItemConstPtr
Definition: ParserFloatItem.hpp:66
const std::string & getDimension(size_t index) const