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