opm-common
Parameter.hpp
1 //===========================================================================
2 //
3 // File: Parameter.hpp
4 //
5 // Created: Tue Jun 2 16:00:21 2009
6 //
7 // Author(s): Bård Skaflestad <bard.skaflestad@sintef.no>
8 // Atgeirr F Rasmussen <atgeirr@sintef.no>
9 //
10 // $Date$
11 //
12 // $Revision$
13 //
14 //===========================================================================
15 
16 /*
17  Copyright 2009, 2010 SINTEF ICT, Applied Mathematics.
18  Copyright 2009, 2010 Statoil ASA.
19 
20  This file is part of the Open Porous Media project (OPM).
21 
22  OPM is free software: you can redistribute it and/or modify
23  it under the terms of the GNU General Public License as published by
24  the Free Software Foundation, either version 3 of the License, or
25  (at your option) any later version.
26 
27  OPM is distributed in the hope that it will be useful,
28  but WITHOUT ANY WARRANTY; without even the implied warranty of
29  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30  GNU General Public License for more details.
31 
32  You should have received a copy of the GNU General Public License
33  along with OPM. If not, see <http://www.gnu.org/licenses/>.
34 */
35 
36 #ifndef OPM_PARAMETER_HEADER
37 #define OPM_PARAMETER_HEADER
38 
39 #include <string>
40 
41 #include <opm/common/utility/parameters/ParameterMapItem.hpp>
42 #include <opm/common/utility/parameters/ParameterStrings.hpp>
43 
44 namespace Opm {
47  class Parameter : public ParameterMapItem {
48  public:
51  ~Parameter() override {}
55  std::string getTag() const override { return ID_xmltag__param; }
59  Parameter(const std::string& value, const std::string& type)
60  : value_(value), type_(type) {}
64  const std::string& getValue() const { return value_; }
68  const std::string& getType() const { return type_; }
69 
70  private:
71  std::string value_;
72  std::string type_;
73  };
74 
79  std::string correct_parameter_tag(const ParameterMapItem& item);
80  std::string correct_type(const Parameter& parameter,
81  const std::string& type);
82 
88  template<>
89  struct ParameterMapItemTrait<int> {
90  static int convert(const ParameterMapItem& item,
91  std::string& conversion_error,
92  const bool);
93 
94  static std::string type() {return ID_param_type__int;}
95  };
96 
102  template<>
103  struct ParameterMapItemTrait<double> {
104  static double convert(const ParameterMapItem& item,
105  std::string& conversion_error,
106  const bool);
107 
108  static std::string type() {return ID_param_type__float;}
109  };
110 
116  template<>
117  struct ParameterMapItemTrait<bool> {
118  static bool convert(const ParameterMapItem& item,
119  std::string& conversion_error,
120  const bool);
121 
122  static std::string type() {return ID_param_type__bool;}
123  };
124 
130  template<>
131  struct ParameterMapItemTrait<std::string> {
132  static std::string convert(const ParameterMapItem& item,
133  std::string& conversion_error,
134  const bool);
135 
136  static std::string type() {return ID_param_type__string;}
137  };
138 } // namespace Opm
139 #endif // OPM_PARAMETER_HPP
const std::string & getValue() const
Definition: Parameter.hpp:64
Definition: ParameterMapItem.hpp:64
The parameter handlig system is structured as a tree, where each node inhertis from ParameterMapItem...
Definition: ParameterMapItem.hpp:47
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
Definition: Parameter.hpp:47
std::string correct_parameter_tag(const ParameterMapItem &item)
Definition: Parameter.cpp:47
const std::string & getType() const
Definition: Parameter.hpp:68
~Parameter() override
Definition: Parameter.hpp:51
std::string getTag() const override
Definition: Parameter.hpp:55
Parameter(const std::string &value, const std::string &type)
Definition: Parameter.hpp:59