tConfigJSON.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
---
tConfigJSON.hh (2198B)
---
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 "Config.hh"
26
27 namespace pism {
28
29 /*! @brief The JSON-based Config implementation.
30 *
31 */
32 class ConfigJSON : public Config {
33 public:
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
41 private:
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);
63 private:
64 json_t *m_data;
65 };
66
67 } // end of namespace pism
68
69 #endif /* _CONFIGJSON_H_ */