Loading [MathJax]/extensions/tex2jax.js
PISM, A Parallel Ice Sheet Model 2.2.1-cd005eec8 committed by Constantine Khrulev on 2025-03-07
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ConfigJSON.hh
Go to the documentation of this file.
1/* Copyright (C) 2014, 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
20#ifndef _CONFIGJSON_H_
21#define _CONFIGJSON_H_
22
23#include <jansson.h>
24
25#include "pism/util/Config.hh"
26
27namespace pism {
28
29/*! @brief The JSON-based Config implementation.
30 *
31 */
32class ConfigJSON : public Config {
33public:
34 ConfigJSON(units::System::Ptr unit_system);
35 virtual ~ConfigJSON();
36
37 void init_from_file(const std::string &filename);
38 void init_from_string(const std::string &string);
39 std::string dump() const;
40
41private:
42 virtual void read_impl(const File &nc);
43 virtual void write_impl(const File &nc) const;
44
45 virtual bool is_set_impl(const std::string &name) const;
46
47 virtual Doubles all_doubles_impl() const;
48 virtual double get_number_impl(const std::string &name) const;
49 virtual std::vector<double> get_numbers_impl(const std::string &name) const;
50
51 virtual void set_number_impl(const std::string &name, double value);
52 virtual void set_numbers_impl(const std::string &name,
53 const std::vector<double> &values);
54
55 virtual Strings all_strings_impl() const;
56 virtual std::string get_string_impl(const std::string &name) const;
57 virtual void set_string_impl(const std::string &name, const std::string &value);
58
59 virtual Flags all_flags_impl() const;
60
61 virtual bool get_flag_impl(const std::string& name) const;
62 virtual void set_flag_impl(const std::string& name, bool value);
63private:
64 json_t *m_data;
65};
66
67} // end of namespace pism
68
69#endif /* _CONFIGJSON_H_ */
virtual Flags all_flags_impl() const
virtual std::string get_string_impl(const std::string &name) const
virtual std::vector< double > get_numbers_impl(const std::string &name) const
virtual double get_number_impl(const std::string &name) const
virtual Doubles all_doubles_impl() const
virtual void set_number_impl(const std::string &name, double value)
virtual void read_impl(const File &nc)
void init_from_file(const std::string &filename)
std::string dump() const
virtual void set_flag_impl(const std::string &name, bool value)
void init_from_string(const std::string &string)
virtual void set_string_impl(const std::string &name, const std::string &value)
virtual ~ConfigJSON()
virtual bool is_set_impl(const std::string &name) const
virtual void set_numbers_impl(const std::string &name, const std::vector< double > &values)
virtual void write_impl(const File &nc) const
virtual Strings all_strings_impl() const
virtual bool get_flag_impl(const std::string &name) const
The JSON-based Config implementation.
Definition ConfigJSON.hh:32
std::map< std::string, std::string > Strings
std::map< std::string, std::vector< double > > Doubles
std::map< std::string, bool > Flags
std::string filename() const
Returns the name of the file used to initialize the database.
A class for storing and accessing PISM configuration flags and parameters.
High-level PISM I/O class.
Definition File.hh:55
std::shared_ptr< System > Ptr
Definition Units.hh:47