PISM, A Parallel Ice Sheet Model 2.3.0-79cae578d committed by Constantine Khrulev on 2026-03-22
Loading...
Searching...
No Matches
pism_options.hh
Go to the documentation of this file.
1// Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2021, 2023, 2024, 2025 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 maybe_show_usage(const Logger &log, const std::string &execname, const std::string &usage);
43
44
45//! Utilities for processing command-line options.
46namespace options {
47
49
50class String : public Option<std::string> {
51public:
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,
61private:
62 int process(const std::string& option,
63 const std::string& description,
64 const std::string& default_value,
65 ArgumentFlag flag);
66};
67
68class Keyword : public Option<std::string> {
69public:
70 Keyword(const std::string& option,
71 const std::string& description,
72 const std::string& choices,
73 const std::string& default_value);
74};
75
76class Integer : public Option<int> {
77public:
78 Integer(const std::string& option,
79 const std::string& description,
80 int default_value);
81};
82
83class Real : public Option<double> {
84public:
85 Real(std::shared_ptr<units::System> system,
86 const std::string& option,
87 const std::string& description,
88 const std::string& units,
89 double default_value);
90};
91
92bool Bool(const std::string& option,
93 const std::string& description);
94
95void deprecated(const std::string &old_name, const std::string &new_name);
96void ignored(const Logger &log, const std::string &name);
97void forbidden(const std::string &name);
98} // end of namespace options
99
100} // end of namespace pism
101
102#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 maybe_show_usage(const Logger &log, const std::string &execname, const std::string &usage)
In a single call a driver program can provide a usage string to the user and check if required option...