Loading [MathJax]/extensions/tex2jax.js
PISM, A Parallel Ice Sheet Model 2.2.2-d6b3a29ca committed by Constantine Khrulev on 2025-03-28
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
pism_options.hh
Go to the documentation of this file.
1// Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2021, 2023, 2024 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 <memory>
23#include <set>
24#include <string>
25#include <vector>
26
27#include "pism/util/options.hh"
28
29namespace pism {
30
31namespace units {
32class System;
33} // end of namespace units
34
35class Config;
36class Logger;
37
38void show_usage(const Logger &log, const std::string &execname, const std::string &usage);
39
40//! @brief Returns true if PISM should terminate after printing some
41//! messages to stdout.
42bool show_usage_check_req_opts(const Logger &log,
43 const std::string &execname,
44 const std::vector<std::string> &required_options,
45 const std::string &usage);
46
47
48//! Utilities for processing command-line options.
49namespace options {
50
52
53class String : public Option<std::string> {
54public:
55 // there is no reasonable default; if the option is set, it has to
56 // have a non-empty argument
57 String(const std::string& option,
58 const std::string& description);
59 // there is a reasonable default
60 String(const std::string& option,
61 const std::string& description,
62 const std::string& default_value,
64private:
65 int process(const std::string& option,
66 const std::string& description,
67 const std::string& default_value,
68 ArgumentFlag flag);
69};
70
71class Keyword : public Option<std::string> {
72public:
73 Keyword(const std::string& option,
74 const std::string& description,
75 const std::string& choices,
76 const std::string& default_value);
77};
78
79class Integer : public Option<int> {
80public:
81 Integer(const std::string& option,
82 const std::string& description,
83 int default_value);
84};
85
86class Real : public Option<double> {
87public:
88 Real(std::shared_ptr<units::System> system,
89 const std::string& option,
90 const std::string& description,
91 const std::string& units,
92 double default_value);
93};
94
95bool Bool(const std::string& option,
96 const std::string& description);
97
98void deprecated(const std::string &old_name, const std::string &new_name);
99void ignored(const Logger &log, const std::string &name);
100void forbidden(const std::string &name);
101} // end of namespace options
102
103} // end of namespace pism
104
105#endif /* PISM_OPTIONS_H */
A basic logging class.
Definition Logger.hh:40
Template base class used by PISM's option-processing classes.
Definition options.hh:30
int process(const std::string &option, const std::string &description, const std::string &default_value, ArgumentFlag flag)
Definition options.cc:53
void deprecated(const std::string &old_name, const std::string &new_name)
Stop if an option old_name is set, printing a message that new_name should be used instead.
Definition options.cc:196
bool Bool(const std::string &option, const std::string &description)
Definition options.cc:190
void ignored(const Logger &log, const std::string &name)
Print a warning telling the user that an option was ignored.
Definition options.cc:209
void forbidden(const std::string &name)
Stop if an option name is set.
Definition options.cc:220
void show_usage(const Logger &log, const std::string &execname, const std::string &usage)
Print a usage message.
bool show_usage_check_req_opts(const Logger &log, const std::string &execname, const std::vector< std::string > &required_options, const std::string &usage)
In a single call a driver program can provide a usage string to the user and check if required option...