tpism_options.hh - pism - [fork] customized build of PISM, the parallel ice sheet model (tillflux branch)
HTML git clone git://src.adamsgaard.dk/pism
DIR Log
DIR Files
DIR Refs
DIR LICENSE
---
tpism_options.hh (4075B)
---
1 // Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 PISM Authors
2 //
3 // This file is part of PISM.
4 //
5 // PISM is free software; you can redistribute it and/or modify it under the
6 // terms of the GNU General Public License as published by the Free Software
7 // Foundation; either version 3 of the License, or (at your option) any later
8 // version.
9 //
10 // PISM is distributed in the hope that it will be useful, but WITHOUT ANY
11 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with PISM; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19 #ifndef _PISM_OPTIONS_H_
20 #define _PISM_OPTIONS_H_
21
22 #include <string>
23 #include <vector>
24 #include <set>
25
26 #include "pism_utilities.hh"
27
28 #include "options.hh"
29
30 namespace pism {
31
32 class Config;
33 class Logger;
34
35 void show_usage(const Logger &log, const std::string &execname, const std::string &usage);
36
37 //! @brief Returns true if PISM should terminate after printing some
38 //! messages to stdout.
39 bool show_usage_check_req_opts(const Logger &log,
40 const std::string &execname,
41 const std::vector<std::string> &required_options,
42 const std::string &usage);
43
44
45 //! Utilities for processing command-line options.
46 namespace options {
47
48 typedef enum {ALLOW_EMPTY, DONT_ALLOW_EMPTY} ArgumentFlag;
49
50 class String : public Option<std::string> {
51 public:
52 // there is no reasonable default; if the option is set, it has to
53 // have a non-empty argument
54 String(const std::string& option,
55 const std::string& description);
56 // there is a reasonable default
57 String(const std::string& option,
58 const std::string& description,
59 const std::string& default_value,
60 ArgumentFlag flag = DONT_ALLOW_EMPTY);
61 private:
62 int process(const std::string& option,
63 const std::string& description,
64 const std::string& default_value,
65 ArgumentFlag flag);
66 };
67
68 class StringList : public Option<std::vector<std::string> > {
69 public:
70 StringList(const std::string& option,
71 const std::string& description,
72 const std::string& default_value);
73 std::string to_string();
74 const std::string& operator[](size_t index) const;
75 };
76
77 class StringSet : public Option<std::set<std::string> > {
78 public:
79 StringSet(const std::string& option,
80 const std::string& description,
81 const std::string& default_value);
82 std::string to_string();
83 };
84
85 class Keyword : public Option<std::string> {
86 public:
87 Keyword(const std::string& option,
88 const std::string& description,
89 const std::string& choices,
90 const std::string& default_value);
91 };
92
93 class Integer : public Option<int> {
94 public:
95 Integer(const std::string& option,
96 const std::string& description,
97 int default_value);
98 };
99
100 class IntegerList : public Option<std::vector<int> > {
101 public:
102 IntegerList(const std::string& option,
103 const std::string& description,
104 const std::vector<int> &defaults);
105 const int& operator[](size_t index) const;
106 };
107
108 class Real : public Option<double> {
109 public:
110 Real(const std::string& option,
111 const std::string& description,
112 double default_value);
113 };
114
115 class RealList : public Option<std::vector<double> > {
116 public:
117 RealList(const std::string& option,
118 const std::string& description,
119 const std::vector<double> &default_value);
120 const double& operator[](size_t index) const;
121 };
122
123 bool Bool(const std::string& option,
124 const std::string& description);
125
126 void deprecated(const std::string &old_name, const std::string &new_name);
127 void ignored(const Logger &log, const std::string &name);
128 void forbidden(const std::string &name);
129 } // end of namespace options
130
131 } // end of namespace pism
132
133 #endif /* _PISM_OPTIONS_H_ */